From 6aed492cc05d721e47a25f6f05cf0fc32f212102 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Thu, 9 Dec 2021 19:52:18 -0500 Subject: [PATCH] hardware: make imports cleaner --- modules/hardware.nix | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/modules/hardware.nix b/modules/hardware.nix index 2b3ac22..838d4b0 100644 --- a/modules/hardware.nix +++ b/modules/hardware.nix @@ -1,32 +1,31 @@ -{ config, pkgs, lib, modulesPath, ... }: +{ config, lib, modulesPath, ... }: let - inherit (pkgs) callPackage; - - hardwareFor = name: cfg: lib.mkIf (config.sconfig.hardware == name) cfg; + hardwareFor = name: cfg: + lib.mkIf + (config.sconfig.hardware == name) + (lib.mkMerge cfg); hardwareModules = [ (hardwareFor "qemu" - { - inherit (callPackage "${modulesPath}/profiles/qemu-guest.nix" { }) boot; - services.qemuGuest.enable = true; - }) + [ + (import "${modulesPath}/profiles/qemu-guest.nix" { }) + { services.qemuGuest.enable = true; } + ]) (hardwareFor "vmware" - { - virtualisation.vmware.guest.enable = true; - boot.initrd.availableKernelModules = [ "mptspi" ]; - }) + [ + { virtualisation.vmware.guest.enable = true; } + { boot.initrd.availableKernelModules = [ "mptspi" ]; } + ]) (hardwareFor "physical" - { - hardware.cpu.amd.updateMicrocode = true; - hardware.cpu.intel.updateMicrocode = true; - - # /nixos/modules/installer/scan/not-detected.nix - hardware.enableRedistributableFirmware = true; - }) + [ + (import "${modulesPath}/installer/scan/not-detected.nix" { inherit lib; }) + { hardware.cpu.amd.updateMicrocode = true; } + { hardware.cpu.intel.updateMicrocode = true; } + ]) ]; in