kernel: Make lazier (fix infinite recursion)

+15 -4
+7 -3
pkgs/os-specific/linux/kernel/generic.nix
··· 213 }; # end of configfile derivation 214 215 kernel = (callPackage ./manual-config.nix { inherit lib stdenv buildPackages; }) (basicArgs // { 216 - inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile; 217 pos = builtins.unsafeGetAttrPos "version" args; 218 219 - config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; } // lib.optionalAttrs withRust { CONFIG_RUST = "y"; }; 220 - } // lib.optionalAttrs (modDirVersion != null) { inherit modDirVersion; }); 221 222 in 223 kernel.overrideAttrs (finalAttrs: previousAttrs: {
··· 213 }; # end of configfile derivation 214 215 kernel = (callPackage ./manual-config.nix { inherit lib stdenv buildPackages; }) (basicArgs // { 216 + inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile modDirVersion; 217 pos = builtins.unsafeGetAttrPos "version" args; 218 219 + config = { 220 + CONFIG_MODULES = "y"; 221 + CONFIG_FW_LOADER = "m"; 222 + CONFIG_RUST = lib.mkIf withRust "y"; 223 + }; 224 + }); 225 226 in 227 kernel.overrideAttrs (finalAttrs: previousAttrs: {
+8 -1
pkgs/os-specific/linux/kernel/manual-config.nix
··· 26 extraMakeFlags ? [], 27 # The name of the kernel module directory 28 # Needs to be X.Y.Z[-extra], so pad with zeros if needed. 29 - modDirVersion ? lib.versions.pad 3 version, 30 # The kernel source (tarball, git checkout, etc.) 31 src, 32 # a list of { name=..., patch=..., extraConfig=...} patches ··· 54 }: 55 56 let 57 inherit (lib) 58 hasAttr getAttr optional optionals optionalString optionalAttrs maintainers platforms; 59
··· 26 extraMakeFlags ? [], 27 # The name of the kernel module directory 28 # Needs to be X.Y.Z[-extra], so pad with zeros if needed. 29 + modDirVersion ? null /* derive from version */, 30 # The kernel source (tarball, git checkout, etc.) 31 src, 32 # a list of { name=..., patch=..., extraConfig=...} patches ··· 54 }: 55 56 let 57 + # Provide defaults. Note that we support `null` so that callers don't need to use optionalAttrs, 58 + # which can lead to unnecessary strictness and infinite recursions. 59 + modDirVersion_ = if modDirVersion == null then lib.versions.pad 3 version else modDirVersion; 60 + in 61 + let 62 + # Shadow the un-defaulted parameter; don't want null. 63 + modDirVersion = modDirVersion_; 64 inherit (lib) 65 hasAttr getAttr optional optionals optionalString optionalAttrs maintainers platforms; 66