flake-module: add flake-parts module (#5229)

Add a flake-parts module, output as flakeModules.home-manager and flakeModules.default.

The module defines options for flake.homeModules and flake.homeConfigurations, based on the respective nixos equivalents; flake.nixosModules and flake.nixosConfigurations.
This commit is contained in:
Matt Sturgeon
2025-01-30 18:17:53 +00:00
committed by GitHub
parent 7a45774684
commit a5e196d61f
4 changed files with 78 additions and 0 deletions

32
flake-module.nix Normal file
View File

@@ -0,0 +1,32 @@
{ lib, flake-parts-lib, moduleLocation, ... }:
let inherit (lib) toString mapAttrs mkOption types;
in {
options = {
flake = flake-parts-lib.mkSubmoduleOptions {
homeConfigurations = mkOption {
type = types.lazyAttrsOf types.raw;
default = { };
description = ''
Instantiated Home-Manager configurations.
`homeConfigurations` is for specific installations. If you want to expose
reusable configurations, add them to `homeModules` in the form of modules, so
that you can reference them in this or another flake's `homeConfigurations`.
'';
};
homeModules = mkOption {
type = types.lazyAttrsOf types.unspecified;
default = { };
apply = mapAttrs (k: v: {
_file = "${toString moduleLocation}#homeModules.${k}";
imports = [ v ];
});
description = ''
Home-Manager modules.
You may use this for reusable pieces of configuration, service modules, etc.
'';
};
};
};
}