From 1c1e0abbd6feafaaaac64ea2b6e31c20d09ab334 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 23 Mar 2024 21:35:29 +0100 Subject: [PATCH] Don't represent vm status via cpu type --- hosts/vbox_nix/default.nix | 3 ++- options/device/hardware.nix | 11 +++++++++-- system/hardware/cpu/amd.nix | 2 +- system/hardware/cpu/intel.nix | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/hosts/vbox_nix/default.nix b/hosts/vbox_nix/default.nix index f4e27e9..761ab18 100644 --- a/hosts/vbox_nix/default.nix +++ b/hosts/vbox_nix/default.nix @@ -24,7 +24,8 @@ username = "itsdrike"; }; device = { - cpu.type = "vm-amd"; + virtual-machine = true; + cpu.type = "amd"; }; }; } diff --git a/options/device/hardware.nix b/options/device/hardware.nix index 3fa6d8a..b90d42b 100644 --- a/options/device/hardware.nix +++ b/options/device/hardware.nix @@ -3,14 +3,21 @@ in { options.myOptions.device = { cpu.type = mkOption { - type = with types; nullOr (enum [ "intel" "vm-intel" "amd" "vm-amd" ]); + type = with types; nullOr (enum [ "intel" "amd" ]); default = null; description = '' The manifaturer/type of the primary system CPU. Determines which ucode services will be enabled and provides additional kernel packages. - If running in a virtual machine with forwarded/shared cores, use the `vm-` prefix. + If running in a virtual machine with forwarded/shared cores (CPU passthrough), use the + cpu type of the host machine. ''; }; + + virtual-machine = mkOption { + type = lib.types.bool; + default = false; + description = "Is this system a virtual machine?"; + }; }; } diff --git a/system/hardware/cpu/amd.nix b/system/hardware/cpu/amd.nix index bedbe5b..6ef2db0 100644 --- a/system/hardware/cpu/amd.nix +++ b/system/hardware/cpu/amd.nix @@ -3,7 +3,7 @@ let dev = config.myOptions.device; in { - config = lib.mkIf (builtins.elem dev.cpu.type [ "amd" "vm-amd" ]) { + config = lib.mkIf (dev.cpu.type == "amd") { hardware.cpu.amd.updateMicrocode = true; }; } diff --git a/system/hardware/cpu/intel.nix b/system/hardware/cpu/intel.nix index ed7814d..9fd113b 100644 --- a/system/hardware/cpu/intel.nix +++ b/system/hardware/cpu/intel.nix @@ -3,7 +3,7 @@ let dev = config.myOptions.device; in { - config = lib.mkIf (builtins.elem dev.cpu.type [ "intel" "vm-intel" ]) { + config = lib.mkIf (dev.cpu.type == "intel") { hardware.cpu.intel.updateMicrocode = true; }; }