diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index d5722bbbd6f4..0b5e64dd6d4d 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -421,18 +421,9 @@ let timeout = 14400; # 4 hours } // extraMeta; }; -in - -stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPatches configfile) // { - inherit pname version; - - enableParallelBuilding = true; - - hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" "pie" ]; # Absolute paths for compilers avoid any PATH-clobbering issues. - makeFlags = [ - "O=$(buildRoot)" + commonMakeFlags = [ "ARCH=${stdenv.hostPlatform.linuxArch}" "CROSS_COMPILE=${stdenv.cc.targetPrefix}" ] ++ lib.optionals (stdenv.isx86_64 && stdenv.cc.bintools.isLLVM) [ @@ -444,5 +435,27 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPat ] ++ (stdenv.hostPlatform.linux-kernel.makeFlags or []) ++ extraMakeFlags; - karch = stdenv.hostPlatform.linuxArch; -} // (optionalAttrs (pos != null) { inherit pos; }))) + finalKernel = stdenv.mkDerivation ( + builtins.foldl' lib.recursiveUpdate {} [ + (drvAttrs config stdenv.hostPlatform.linux-kernel kernelPatches configfile) + { + inherit pname version; + + enableParallelBuilding = true; + + hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" "pie" ]; + + makeFlags = [ + "O=$(buildRoot)" + ] ++ commonMakeFlags; + + passthru.moduleMakeFlags = [ + "KBUILD_OUTPUT=${finalKernel.dev}/lib/modules/${finalKernel.modDirVersion}/build" + ] ++ commonMakeFlags; + + karch = stdenv.hostPlatform.linuxArch; + } + (optionalAttrs (pos != null) { inherit pos; }) + ] + ); +in finalKernel)