feat(hm): add sharedModules, move configurations.nix to hosts.nix
This commit is contained in:
parent
3cf6a49a2a
commit
253b46eee0
2 changed files with 9 additions and 4 deletions
34
nix/modules/hosts.nix
Normal file
34
nix/modules/hosts.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) nixosSystem;
|
||||
inherit (cfg.lib) flattenAttrs;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
cfg = config.flake;
|
||||
hosts = cfg.manifest.hosts or { };
|
||||
mkConfigurations =
|
||||
class: hosts:
|
||||
mapAttrs (
|
||||
name: value:
|
||||
if class == "nixos" then
|
||||
nixosSystem {
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
hostName = name;
|
||||
};
|
||||
modules = [
|
||||
(flattenAttrs cfg.modules.nixos)
|
||||
(value.extraCfg or { })
|
||||
];
|
||||
}
|
||||
else
|
||||
{ }
|
||||
) hosts;
|
||||
in
|
||||
{
|
||||
flake.nixosConfigurations = mkConfigurations "nixos" hosts.nixos;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue