From 5dd1dff8154e1709cfedfeded8e4396b80815d1d Mon Sep 17 00:00:00 2001 From: andre4ik3 Date: Wed, 25 Feb 2026 23:10:13 +0000 Subject: [PATCH] nixos/facter: add enable option The option defaults to `report != { }` instead of `reportPath != null`, because since the report may be set externally using `report`, guarding for `reportPath != null` breaks setups that set it externally, since none of the modules take effect any longer. --- nixos/modules/hardware/facter/default.nix | 13 +++++++++++++ nixos/modules/hardware/facter/disk.nix | 2 +- nixos/modules/hardware/facter/firmware.nix | 2 +- nixos/modules/hardware/facter/graphics/amd.nix | 2 +- nixos/modules/hardware/facter/graphics/default.nix | 2 +- nixos/modules/hardware/facter/keyboard.nix | 2 +- .../modules/hardware/facter/networking/default.nix | 12 +++++------- nixos/modules/hardware/facter/networking/initrd.nix | 2 +- nixos/modules/hardware/facter/networking/intel.nix | 2 +- nixos/modules/hardware/facter/virtualisation.nix | 2 +- 10 files changed, 26 insertions(+), 15 deletions(-) diff --git a/nixos/modules/hardware/facter/default.nix b/nixos/modules/hardware/facter/default.nix index 91bb328c508b..a748be44d411 100644 --- a/nixos/modules/hardware/facter/default.nix +++ b/nixos/modules/hardware/facter/default.nix @@ -23,6 +23,19 @@ meta.maintainers = with lib.maintainers; [ mic92 ]; options.hardware.facter = with lib; { + enable = mkOption { + type = types.bool; + default = config.hardware.facter.report != { }; + defaultText = literalExpression '' + config.hardware.facter.report != { } + ''; + description = '' + Whether to enable automatic hardware configuration using a report generated by nixos-facter. + + See for more information. + ''; + }; + report = mkOption { type = types.attrsOf types.anything; default = diff --git a/nixos/modules/hardware/facter/disk.nix b/nixos/modules/hardware/facter/disk.nix index 4158bd171bb9..fe4e8898fb56 100644 --- a/nixos/modules/hardware/facter/disk.nix +++ b/nixos/modules/hardware/facter/disk.nix @@ -22,7 +22,7 @@ in ''; }; - config = lib.mkIf (config.hardware.facter.reportPath != null) { + config = lib.mkIf config.hardware.facter.enable { boot.initrd.availableKernelModules = config.hardware.facter.detected.boot.disk.kernelModules; }; } diff --git a/nixos/modules/hardware/facter/firmware.nix b/nixos/modules/hardware/facter/firmware.nix index b614cab85253..db909c5d1a85 100644 --- a/nixos/modules/hardware/facter/firmware.nix +++ b/nixos/modules/hardware/facter/firmware.nix @@ -8,7 +8,7 @@ let hasIntelCpu = facterLib.hasIntelCpu report; in { - config = lib.mkIf (config.hardware.facter.reportPath != null && isBaremetal) { + config = lib.mkIf (config.hardware.facter.enable && isBaremetal) { # none (e.g. bare-metal) # provide firmware for devices that might not have been detected by nixos-facter hardware.enableRedistributableFirmware = lib.mkDefault true; diff --git a/nixos/modules/hardware/facter/graphics/amd.nix b/nixos/modules/hardware/facter/graphics/amd.nix index b2ec114677a0..fd1b670edac1 100644 --- a/nixos/modules/hardware/facter/graphics/amd.nix +++ b/nixos/modules/hardware/facter/graphics/amd.nix @@ -12,7 +12,7 @@ in defaultText = "hardware dependent"; }; }; - config = lib.mkIf (config.hardware.facter.reportPath != null && cfg.enable) { + config = lib.mkIf (config.hardware.facter.enable && cfg.enable) { services.xserver.videoDrivers = [ "modesetting" ]; }; } diff --git a/nixos/modules/hardware/facter/graphics/default.nix b/nixos/modules/hardware/facter/graphics/default.nix index cd29040ce67d..f294c3b2ae5e 100644 --- a/nixos/modules/hardware/facter/graphics/default.nix +++ b/nixos/modules/hardware/facter/graphics/default.nix @@ -28,7 +28,7 @@ in }; }; - config = lib.mkIf (config.hardware.facter.reportPath != null && cfg.enable) ( + config = lib.mkIf (config.hardware.facter.enable && cfg.enable) ( { boot.initrd.kernelModules = config.hardware.facter.detected.boot.graphics.kernelModules; } diff --git a/nixos/modules/hardware/facter/keyboard.nix b/nixos/modules/hardware/facter/keyboard.nix index 62baf5bd32f1..98ae12ba3a55 100644 --- a/nixos/modules/hardware/facter/keyboard.nix +++ b/nixos/modules/hardware/facter/keyboard.nix @@ -15,7 +15,7 @@ in ''; }; - config = lib.mkIf (config.hardware.facter.reportPath != null) { + config = lib.mkIf config.hardware.facter.enable { boot.initrd.availableKernelModules = config.hardware.facter.detected.boot.keyboard.kernelModules; }; } diff --git a/nixos/modules/hardware/facter/networking/default.nix b/nixos/modules/hardware/facter/networking/default.nix index 7f662d8785a0..1ad1229cb44e 100644 --- a/nixos/modules/hardware/facter/networking/default.nix +++ b/nixos/modules/hardware/facter/networking/default.nix @@ -60,12 +60,10 @@ in ]; }; }; - config = - lib.mkIf (config.hardware.facter.reportPath != null && config.hardware.facter.detected.dhcp.enable) - { - networking.useDHCP = lib.mkDefault true; + config = lib.mkIf (config.hardware.facter.enable && config.hardware.facter.detected.dhcp.enable) { + networking.useDHCP = lib.mkDefault true; - # Per-interface DHCP configuration - networking.interfaces = perInterfaceConfig; - }; + # Per-interface DHCP configuration + networking.interfaces = perInterfaceConfig; + }; } diff --git a/nixos/modules/hardware/facter/networking/initrd.nix b/nixos/modules/hardware/facter/networking/initrd.nix index 8c3135354f93..c26be93a35d7 100644 --- a/nixos/modules/hardware/facter/networking/initrd.nix +++ b/nixos/modules/hardware/facter/networking/initrd.nix @@ -14,7 +14,7 @@ in ''; }; - config = lib.mkIf (config.hardware.facter.reportPath != null && config.boot.initrd.network.enable) { + config = lib.mkIf (config.hardware.facter.enable && config.boot.initrd.network.enable) { boot.initrd.kernelModules = config.hardware.facter.detected.boot.initrd.networking.kernelModules; }; } diff --git a/nixos/modules/hardware/facter/networking/intel.nix b/nixos/modules/hardware/facter/networking/intel.nix index a28e8ecf580d..2710c45ab46a 100644 --- a/nixos/modules/hardware/facter/networking/intel.nix +++ b/nixos/modules/hardware/facter/networking/intel.nix @@ -49,7 +49,7 @@ in }; }; - config = lib.mkIf (config.hardware.facter.reportPath != null) { + config = lib.mkIf config.hardware.facter.enable { networking.enableIntel2200BGFirmware = lib.mkIf cfg._2200BG.enable (lib.mkDefault true); hardware.enableRedistributableFirmware = lib.mkIf cfg._3945ABG.enable (lib.mkDefault true); }; diff --git a/nixos/modules/hardware/facter/virtualisation.nix b/nixos/modules/hardware/facter/virtualisation.nix index 6acdd62516f9..cf34ca5eea4d 100644 --- a/nixos/modules/hardware/facter/virtualisation.nix +++ b/nixos/modules/hardware/facter/virtualisation.nix @@ -51,7 +51,7 @@ in }; }; - config = lib.mkIf (config.hardware.facter.reportPath != null) { + config = lib.mkIf config.hardware.facter.enable { # KVM support boot.kernelModules =