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.
This commit is contained in:
andre4ik3
2026-02-25 23:10:13 +00:00
parent fb20d4ada7
commit 5dd1dff815
10 changed files with 26 additions and 15 deletions
+13
View File
@@ -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 <https://nix-community.github.io/nixos-facter/> for more information.
'';
};
report = mkOption {
type = types.attrsOf types.anything;
default =
+1 -1
View File
@@ -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;
};
}
+1 -1
View File
@@ -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;
@@ -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" ];
};
}
@@ -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;
}
+1 -1
View File
@@ -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;
};
}
@@ -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;
};
}
@@ -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;
};
}
@@ -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);
};
@@ -51,7 +51,7 @@ in
};
};
config = lib.mkIf (config.hardware.facter.reportPath != null) {
config = lib.mkIf config.hardware.facter.enable {
# KVM support
boot.kernelModules =