diff --git a/flake.nix b/flake.nix index 7afdb8c..5ee2ab9 100644 --- a/flake.nix +++ b/flake.nix @@ -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"); }; }; }