feat(hostSpec): add module to define hosts in flake

This commit is contained in:
Mohammad Rafiq 2025-07-06 01:55:24 +08:00
parent 09f9a33620
commit b370a9d7db
No known key found for this signature in database

View 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;
};
}