From b370a9d7dbc2f79b338558cacddfb19a4dd9b131 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Sun, 6 Jul 2025 01:55:24 +0800 Subject: [PATCH] feat(hostSpec): add module to define hosts in flake --- modules/hostSpec/default.nix | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 modules/hostSpec/default.nix diff --git a/modules/hostSpec/default.nix b/modules/hostSpec/default.nix new file mode 100644 index 0000000..5bb06c6 --- /dev/null +++ b/modules/hostSpec/default.nix @@ -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; + }; +}