refactor: extract machine setup

mandlm 2022-08-18 21:55:47 +02:00
parent 07484604d4
commit 66aa9cd407
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
1 changed files with 24 additions and 68 deletions

View File

@ -12,77 +12,33 @@
let let
user = "mandlm"; user = "mandlm";
theme = "dark"; # dark or light theme = "dark"; # dark or light
buildMachineConfig = machineName: nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
modules = [
./configuration.nix
./users.nix
./machines/${machineName}/configuration.nix
./machines/${machineName}/hardware-configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user theme; };
home-manager.users.${user} = {
imports = [ ./home-${user}.nix ];
};
}
];
};
in in
{ {
nixosConfigurations = { nixosConfigurations = {
nixos-vm = nixpkgs.lib.nixosSystem { nixos-vm = buildMachineConfig ("nixos-vm");
system = "x86_64-linux"; apache = buildMachineConfig ("apache");
specialArgs = inputs; p330 = buildMachineConfig ("p330");
modules = [
./configuration.nix
./users.nix
./machines/nixos-vm/configuration.nix
./machines/nixos-vm/hardware-configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user theme; };
home-manager.users.${user} = {
imports = [ ./home-${user}.nix ];
};
}
];
};
apache = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
modules = [
./configuration.nix
./users.nix
./machines/apache/configuration.nix
./machines/apache/hardware-configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user theme; };
home-manager.users.${user} = {
imports = [
./home-${user}.nix
./machines/apache/home-${user}.nix
];
};
}
];
};
p330 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
modules = [
./configuration.nix
./users.nix
./machines/p330/configuration.nix
./machines/p330/hardware-configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit user theme; };
home-manager.users.${user} = {
imports = [
./home-${user}.nix
./machines/p330/home-${user}.nix
];
};
}
];
};
}; };
}; };
} }