kernel: Make lazier (fix infinite recursion)

This commit is contained in:
Robert Hensing 2024-04-25 16:33:58 +02:00
parent 74dbae8968
commit 3e83fe9aa5
2 changed files with 15 additions and 4 deletions

View File

@ -213,11 +213,15 @@ let
}; # end of configfile derivation
kernel = (callPackage ./manual-config.nix { inherit lib stdenv buildPackages; }) (basicArgs // {
inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile;
inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile modDirVersion;
pos = builtins.unsafeGetAttrPos "version" args;
config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; } // lib.optionalAttrs withRust { CONFIG_RUST = "y"; };
} // lib.optionalAttrs (modDirVersion != null) { inherit modDirVersion; });
config = {
CONFIG_MODULES = "y";
CONFIG_FW_LOADER = "m";
CONFIG_RUST = lib.mkIf withRust "y";
};
});
in
kernel.overrideAttrs (finalAttrs: previousAttrs: {

View File

@ -26,7 +26,7 @@ in lib.makeOverridable ({
extraMakeFlags ? [],
# The name of the kernel module directory
# Needs to be X.Y.Z[-extra], so pad with zeros if needed.
modDirVersion ? lib.versions.pad 3 version,
modDirVersion ? null /* derive from version */,
# The kernel source (tarball, git checkout, etc.)
src,
# a list of { name=..., patch=..., extraConfig=...} patches
@ -54,6 +54,13 @@ in lib.makeOverridable ({
}:
let
# Provide defaults. Note that we support `null` so that callers don't need to use optionalAttrs,
# which can lead to unnecessary strictness and infinite recursions.
modDirVersion_ = if modDirVersion == null then lib.versions.pad 3 version else modDirVersion;
in
let
# Shadow the un-defaulted parameter; don't want null.
modDirVersion = modDirVersion_;
inherit (lib)
hasAttr getAttr optional optionals optionalString optionalAttrs maintainers platforms;