Unify the machine configuration centrally

This commit is contained in:
Manuel Thalmann 2024-05-11 01:22:32 +02:00
parent 34bdf1ca0b
commit 27150198e0

View file

@ -35,7 +35,14 @@
}; };
}; };
machines = builtins.mapAttrs (name: value: defaultMachine // value) machineDefinitions; machines = builtins.mapAttrs (
name: machineDefinition:
defaultMachine // machineDefinition // {
config = { ... }@args:
((defaultMachine.config args) // (machineDefinition.config args));
})
machineDefinitions;
tryFiles = import ./lib/utils/try-files.nix { inherit lib; }; tryFiles = import ./lib/utils/try-files.nix { inherit lib; };
in in
flake-utils.lib.eachDefaultSystem ( flake-utils.lib.eachDefaultSystem (
@ -83,10 +90,9 @@
config._module.args = { config._module.args = {
inherit hostname; inherit hostname;
machineConfig = (defaultMachine.config args) // machineConfig = (config args) // {
(config args) // { inherit hostname;
inherit hostname; };
};
}; };
}) })
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
@ -104,10 +110,6 @@
lib.attrsets.concatMapAttrs ( lib.attrsets.concatMapAttrs (
hostname: machine: hostname: machine:
let let
machineConfig = { ... }@args:
(defaultMachine.config args) //
(machine.config args);
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit (machine) system; inherit (machine) system;
}; };
@ -136,7 +138,7 @@
] ++ (lib.optional (userConfigPath != null) userConfigPath); ] ++ (lib.optional (userConfigPath != null) userConfigPath);
}; };
}) })
(machineConfig { inherit pkgs; }).users) (machine.config { inherit pkgs; }).users)
machines; machines;
}); });
} }