nixos/facter: add reportPath guard to all modules

Add lib.mkIf condition checking if config.hardware.facter.reportPath != null
to all facter modules. This shortcuts the module effects when no facter
report is available, preventing unnecessary evaluation and potential errors
when the report is not provided.
This commit is contained in:
Jörg Thalheim
2025-11-05 22:57:03 +01:00
parent 79d683f4ad
commit 3e758c612d
10 changed files with 16 additions and 14 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ in
'';
};
config = {
config = lib.mkIf (config.hardware.facter.reportPath != null) {
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 isBaremetal {
config = lib.mkIf (config.hardware.facter.reportPath != null && 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 cfg.enable {
config = lib.mkIf (config.hardware.facter.reportPath != null && cfg.enable) {
services.xserver.videoDrivers = [ "modesetting" ];
};
}
@@ -28,7 +28,7 @@ in
};
};
config = lib.mkIf cfg.enable (
config = lib.mkIf (config.hardware.facter.reportPath != null && cfg.enable) (
{
boot.initrd.kernelModules = config.hardware.facter.detected.boot.graphics.kernelModules;
}
+1 -1
View File
@@ -15,7 +15,7 @@ in
'';
};
config = {
config = lib.mkIf (config.hardware.facter.reportPath != null) {
boot.initrd.availableKernelModules = config.hardware.facter.detected.boot.keyboard.kernelModules;
};
}
@@ -60,10 +60,12 @@ in
];
};
};
config = lib.mkIf config.hardware.facter.detected.dhcp.enable {
networking.useDHCP = lib.mkDefault true;
config =
lib.mkIf (config.hardware.facter.reportPath != null && 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.boot.initrd.network.enable {
config = lib.mkIf (config.hardware.facter.reportPath != null && config.boot.initrd.network.enable) {
boot.initrd.kernelModules = config.hardware.facter.detected.boot.initrd.networking.kernelModules;
};
}
@@ -49,7 +49,7 @@ in
};
};
config = {
config = lib.mkIf (config.hardware.facter.reportPath != null) {
networking.enableIntel2200BGFirmware = lib.mkIf cfg._2200BG.enable (lib.mkDefault true);
hardware.enableRedistributableFirmware = lib.mkIf cfg._3945ABG.enable (lib.mkDefault true);
};
+1 -1
View File
@@ -6,7 +6,7 @@
}:
{
# Skip setting hostPlatform if it's read-only
nixpkgs =
config.nixpkgs =
lib.optionalAttrs
(config.hardware.facter.report.system or null != null && !options.nixpkgs.hostPlatform.readOnly)
{
@@ -51,7 +51,7 @@ in
};
};
config = {
config = lib.mkIf (config.hardware.facter.reportPath != null) {
# KVM support
boot.kernelModules =