refactor: extract machine setup

This commit is contained in:
mandlm 2022-08-18 21:55:47 +02:00
parent 07484604d4
commit 66aa9cd407
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7

View File

@ -12,77 +12,33 @@
let
user = "mandlm";
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
{
nixosConfigurations = {
nixos-vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
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
];
};
}
];
};
nixos-vm = buildMachineConfig ("nixos-vm");
apache = buildMachineConfig ("apache");
p330 = buildMachineConfig ("p330");
};
};
}