move hardware profiles

This commit is contained in:
Sean Buckley 2021-12-10 01:34:46 -05:00
parent 6aed492cc0
commit a38cebe6f3
9 changed files with 50 additions and 53 deletions

View file

@ -5,8 +5,8 @@
let let
mypkgs = import ./pkgs; mypkgs = import ./pkgs;
getHosts = import lib/hosts.nix;
morphHosts = import lib/morph.nix; morphHosts = import lib/morph.nix;
hardware = import lib/hardware.nix;
forAllSystems = f: builtins.listToAttrs (map forAllSystems = f: builtins.listToAttrs (map
(name: { inherit name; value = f name; }) (name: { inherit name; value = f name; })
@ -23,7 +23,7 @@
in in
{ {
lib = { inherit forAllSystems getHosts morphHosts; }; lib = { inherit forAllSystems morphHosts hardware; };
nixosModules = nixosModules =
{ inherit pins; } // { inherit pins; } //
@ -39,13 +39,7 @@
nixpkgs.overlays = [ (_: mypkgs) ]; nixpkgs.overlays = [ (_: mypkgs) ];
}; };
nixosConfigurations = nixosConfigurations = import ./hosts nixpkgs hardware self.nixosModule;
builtins.mapAttrs
(_: nixpkgs.lib.nixosSystem)
(getHosts {
inherit (self) nixosModule;
path = ./hosts;
});
packages = forAllSystems packages = forAllSystems
(system: mypkgs nixpkgs.legacyPackages.${system}); (system: mypkgs nixpkgs.legacyPackages.${system});

17
hosts/default.nix Normal file
View file

@ -0,0 +1,17 @@
nixpkgs: hardware: nixosModule:
with hardware;
let
sys = args: nixpkgs.lib.nixosSystem {
system = builtins.head args;
modules = [ nixosModule ] ++ builtins.tail args;
};
in
{
cube = sys [ "x86_64-linux" physical ./x86_64-linux/cube ];
hp = sys [ "x86_64-linux" physical ./x86_64-linux/hp ];
lenny = sys [ "x86_64-linux" physical ./x86_64-linux/lenny ];
nixdev = sys [ "x86_64-linux" qemu ./x86_64-linux/nixdev ];
slate = sys [ "x86_64-linux" physical ./x86_64-linux/slate ];
}

View file

@ -1,9 +1,10 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
networking.hostName = "cube";
sconfig = { sconfig = {
gnome = true; gnome = true;
profile = "desktop"; profile = "desktop";
hardware = "physical";
}; };
environment.etc = environment.etc =

View file

@ -1,5 +1,7 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
networking.hostName = "hp";
services = { services = {
openssh.enable = true; openssh.enable = true;
}; };
@ -21,7 +23,6 @@
sconfig = { sconfig = {
gnome = true; gnome = true;
profile = "desktop"; profile = "desktop";
hardware = "physical";
}; };
environment.systemPackages = [ pkgs.vmware-horizon-client ]; environment.systemPackages = [ pkgs.vmware-horizon-client ];

View file

@ -1,5 +1,7 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
networking.hostName = "lenny";
services = { services = {
openssh.enable = true; openssh.enable = true;
}; };
@ -21,7 +23,6 @@
sconfig = { sconfig = {
gnome = true; gnome = true;
profile = "desktop"; profile = "desktop";
hardware = "physical";
}; };
environment.systemPackages = [ pkgs.vmware-horizon-client ]; environment.systemPackages = [ pkgs.vmware-horizon-client ];

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
networking.hostName = "nixdev";
sconfig = { sconfig = {
gnome = true; gnome = true;
hardware = "qemu";
profile = "desktop"; profile = "desktop";
}; };

View file

@ -1,8 +1,9 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
networking.hostName = "slate";
sconfig = { sconfig = {
profile = "desktop"; profile = "desktop";
hardware = "physical";
gnome = true; gnome = true;
}; };

20
lib/hardware.nix Normal file
View file

@ -0,0 +1,20 @@
{
physical = { lib, modulesPath, ... }: lib.mkMerge
[
(import "${modulesPath}/installer/scan/not-detected.nix" { inherit lib; })
{ hardware.cpu.amd.updateMicrocode = true; }
{ hardware.cpu.intel.updateMicrocode = true; }
];
qemu = { lib, modulesPath, ... }: lib.mkMerge
[
(import "${modulesPath}/profiles/qemu-guest.nix" { })
{ services.qemuGuest.enable = true; }
];
vmware = { lib, modulesPath, ... }: lib.mkMerge
[
{ virtualisation.vmware.guest.enable = true; }
{ boot.initrd.availableKernelModules = [ "mptspi" ]; }
];
}

View file

@ -1,39 +0,0 @@
{ config, lib, modulesPath, ... }:
let
hardwareFor = name: cfg:
lib.mkIf
(config.sconfig.hardware == name)
(lib.mkMerge cfg);
hardwareModules =
[
(hardwareFor "qemu"
[
(import "${modulesPath}/profiles/qemu-guest.nix" { })
{ services.qemuGuest.enable = true; }
])
(hardwareFor "vmware"
[
{ virtualisation.vmware.guest.enable = true; }
{ boot.initrd.availableKernelModules = [ "mptspi" ]; }
])
(hardwareFor "physical"
[
(import "${modulesPath}/installer/scan/not-detected.nix" { inherit lib; })
{ hardware.cpu.amd.updateMicrocode = true; }
{ hardware.cpu.intel.updateMicrocode = true; }
])
];
in
with lib;
{
options.sconfig.hardware = mkOption {
type = types.enum [ "physical" "vmware" "qemu" ];
};
config = mkMerge hardwareModules;
}