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; };
in
flake-utils.lib.eachDefaultSystem (
@ -83,10 +90,9 @@
config._module.args = {
inherit hostname;
machineConfig = (defaultMachine.config args) //
(config args) // {
inherit hostname;
};
machineConfig = (config args) // {
inherit hostname;
};
};
})
home-manager.nixosModules.home-manager
@ -104,10 +110,6 @@
lib.attrsets.concatMapAttrs (
hostname: machine:
let
machineConfig = { ... }@args:
(defaultMachine.config args) //
(machine.config args);
pkgs = import nixpkgs {
inherit (machine) system;
};
@ -136,7 +138,7 @@
] ++ (lib.optional (userConfigPath != null) userConfigPath);
};
})
(machineConfig { inherit pkgs; }).users)
(machine.config { inherit pkgs; }).users)
machines;
});
}