feat(hostSpec): add module to define hosts in flake
This commit is contained in:
parent
09f9a33620
commit
b370a9d7db
1 changed files with 29 additions and 0 deletions
29
modules/hostSpec/default.nix
Normal file
29
modules/hostSpec/default.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (builtins) mapAttrs;
|
||||
inherit (lib) mkOption;
|
||||
inherit (lib.types) lazyAttrsOf submodule;
|
||||
cfg = config.hostSpec;
|
||||
hostOptions = submodule { };
|
||||
mkSystem =
|
||||
hostName: _hostConfig:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [ { networking = { inherit hostName; }; } ];
|
||||
};
|
||||
in
|
||||
{
|
||||
options.hostSpec.hosts = mkOption {
|
||||
type = lazyAttrsOf hostOptions;
|
||||
default = { };
|
||||
};
|
||||
|
||||
config = {
|
||||
flake.nixosConfigurations = mapAttrs mkSystem cfg.hosts;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue