add a function to the flake to create a computer

credits to @christianharke
This commit is contained in:
Andreas Zweili 2022-01-03 19:30:38 +01:00
parent 44ae2dcdca
commit 957fde671a
2 changed files with 77 additions and 65 deletions

139
flake.nix
View File

@ -39,71 +39,86 @@
overlay-unstable overlay-unstable
]; ];
}; };
mkComputer = configurationNix: extraModules: nixpkgs.lib.nixosSystem {
inherit system pkgs;
specialArgs = { inherit system inputs; };
modules = (
[
# System configuration for this host
configurationNix
# Common configuration
./modules/common.nix
] ++ extraModules
);
};
in in
{ {
nixosConfigurations.gwyn = nixpkgs.lib.nixosSystem { nixosConfigurations = {
inherit system pkgs; gwyn = nixpkgs.lib.nixosSystem {
modules = [ inherit system pkgs;
./systems/gwyn/configuration.nix modules = [
nixos-hardware.nixosModules.dell-precision-5530 ./systems/gwyn/configuration.nix
nixos-hardware.nixosModules.common-gpu-nvidia nixos-hardware.nixosModules.dell-precision-5530
home-manager.nixosModules.home-manager nixos-hardware.nixosModules.common-gpu-nvidia
{ home-manager.nixosModules.home-manager
home-manager.useGlobalPkgs = true; {
home-manager.useUserPackages = true; home-manager.useGlobalPkgs = true;
home-manager.users.${username} = import ./home-manager/desktop.nix home-manager.useUserPackages = true;
{ home-manager.users.${username} = import ./home-manager/desktop.nix
inherit inputs system pkgs; {
}; inherit inputs system pkgs;
} };
]; }
}; ];
nixosConfigurations.staubfinger = nixpkgs.lib.nixosSystem { };
inherit system pkgs; staubfinger = nixpkgs.lib.nixosSystem {
modules = [ inherit system pkgs;
./systems/staubfinger/configuration.nix modules = [
nixos-hardware.nixosModules.common-pc-laptop ./systems/staubfinger/configuration.nix
nixos-hardware.nixosModules.common-pc-laptop-ssd nixos-hardware.nixosModules.common-pc-laptop
home-manager.nixosModules.home-manager nixos-hardware.nixosModules.common-pc-laptop-ssd
{ home-manager.nixosModules.home-manager
home-manager.useGlobalPkgs = true; {
home-manager.useUserPackages = true; home-manager.useGlobalPkgs = true;
home-manager.users.${username} = import ./home-manager/desktop.nix home-manager.useUserPackages = true;
{ home-manager.users.${username} = import ./home-manager/desktop.nix
inherit inputs system pkgs; {
}; inherit inputs system pkgs;
} };
]; }
}; ];
nixosConfigurations.nixos-vm = nixpkgs.lib.nixosSystem { };
inherit system pkgs; nixos-vm = nixpkgs.lib.nixosSystem {
modules = [ inherit system pkgs;
./systems/vm/configuration.nix modules = [
home-manager.nixosModules.home-manager ./systems/vm/configuration.nix
{ home-manager.nixosModules.home-manager
home-manager.useGlobalPkgs = true; {
home-manager.useUserPackages = true; home-manager.useGlobalPkgs = true;
home-manager.users.${username} = import ./home-manager/desktop.nix home-manager.useUserPackages = true;
{ home-manager.users.${username} = import ./home-manager/desktop.nix
inherit inputs system pkgs; {
}; inherit inputs system pkgs;
} };
]; }
}; ];
nixosConfigurations.nixos-test-vm = nixpkgs.lib.nixosSystem { };
inherit system pkgs; nixos-test-vm = mkComputer
modules = [
./systems/proxmox-vm/configuration.nix ./systems/proxmox-vm/configuration.nix
home-manager.nixosModules.home-manager [
{ ./modules/docker.nix
home-manager.useGlobalPkgs = true; ./modules/code-server
home-manager.useUserPackages = true; home-manager.nixosModules.home-manager
home-manager.users.${username} = import ./home-manager/headless.nix {
{ home-manager.useGlobalPkgs = true;
inherit inputs system pkgs; home-manager.useUserPackages = true;
}; home-manager.users.${username} = import ./home-manager/headless.nix
} {
]; inherit inputs system pkgs;
};
}
];
}; };
}; };
} }

View File

@ -4,9 +4,6 @@
imports = imports =
[ [
# Include the results of the hardware scan. # Include the results of the hardware scan.
../../modules/common.nix
../../modules/docker.nix
../../modules/code-server
./hardware-configuration.nix ./hardware-configuration.nix
]; ];