Use more reasonable variable names

This commit is contained in:
Manuel Thalmann 2024-05-11 01:19:06 +02:00
parent ba93800317
commit 34bdf1ca0b

View file

@ -30,12 +30,12 @@
}; };
}; };
machines = { machineDefinitions = {
nixos.config = { ... }: { nixos.config = { ... }: {
}; };
}; };
systems = builtins.mapAttrs (name: value: defaultMachine // value) machines; machines = builtins.mapAttrs (name: value: defaultMachine // value) 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 (
@ -74,41 +74,39 @@
) // { ) // {
nixosConfigurations = nixosConfigurations =
builtins.mapAttrs ( builtins.mapAttrs (
name: { system, config }: nixpkgs.lib.nixosSystem { hostname: { system, config }: nixpkgs.lib.nixosSystem {
inherit system; inherit system;
modules = [ modules = [
( (
{ pkgs, ... }@args: { { pkgs, ... }@args: {
config._module.args = { config._module.args = {
hostname = name; inherit hostname;
machineConfig = (defaultMachine.config args) // machineConfig = (defaultMachine.config args) //
(config args) // { (config args) // {
inherit name; inherit hostname;
}; };
}; };
}) })
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops sops-nix.nixosModules.sops
./lib/configuration.nix ./lib/configuration.nix
(tryFiles [ ./lib/machines/${name}.nix ] ./lib/hardware/base.nix) (tryFiles [ ./lib/machines/${hostname}.nix ] ./lib/hardware/base.nix)
]; ];
}) })
systems; machines;
homeConfigurations = homeConfigurations =
let let
lib = nixpkgs.lib; lib = nixpkgs.lib;
in in
lib.attrsets.concatMapAttrs ( lib.attrsets.concatMapAttrs (
hostname: machineDeclaration: hostname: machine:
let let
machine = machineDeclaration // defaultMachine // { machineConfig = { ... }@args:
config = { ... }@args: ( (defaultMachine.config args) //
(defaultMachine.config args) // (machine.config args);
(machineDeclaration.config args));
};
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit (machine) system; inherit (machine) system;
@ -138,7 +136,7 @@
] ++ (lib.optional (userConfigPath != null) userConfigPath); ] ++ (lib.optional (userConfigPath != null) userConfigPath);
}; };
}) })
(machine.config { inherit pkgs; }).users) (machineConfig { inherit pkgs; }).users)
machines; machines;
}); });
} }