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
mypkgs = import ./pkgs;
getHosts = import lib/hosts.nix;
morphHosts = import lib/morph.nix;
hardware = import lib/hardware.nix;
forAllSystems = f: builtins.listToAttrs (map
(name: { inherit name; value = f name; })
@ -23,7 +23,7 @@
in
{
lib = { inherit forAllSystems getHosts morphHosts; };
lib = { inherit forAllSystems morphHosts hardware; };
nixosModules =
{ inherit pins; } //
@ -39,13 +39,7 @@
nixpkgs.overlays = [ (_: mypkgs) ];
};
nixosConfigurations =
builtins.mapAttrs
(_: nixpkgs.lib.nixosSystem)
(getHosts {
inherit (self) nixosModule;
path = ./hosts;
});
nixosConfigurations = import ./hosts nixpkgs hardware self.nixosModule;
packages = forAllSystems
(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, ... }:
{
networking.hostName = "cube";
sconfig = {
gnome = true;
profile = "desktop";
hardware = "physical";
};
environment.etc =

View file

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

View file

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

View file

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

View file

@ -1,8 +1,9 @@
{ pkgs, ... }:
{
networking.hostName = "slate";
sconfig = {
profile = "desktop";
hardware = "physical";
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;
}