linuxManualConfig: get rid of drvAttrs
This is an attempt to make linuxManualConfig look a lot more like a normal package. Previously, about half the attributes passed to mkDerivation come from calling a "drvAttrs" function, which just served to alias some variables through function parameters. There wasn't really a system for which attributes came from drvAttrs, and which did not. I've also made a few other minor changes, like re-ordering attributes to be more idiomatic, and using variables that were moved out of drvAttrs in the definitions of attributes that weren't in drvAttrs before. I've limited my changes here to what I can confidently do without causing any rebuilds.
This commit is contained in:
parent
4efd34323c
commit
f521f46133
|
@ -52,6 +52,10 @@ in lib.makeOverridable ({
|
|||
features ? null, lib ? lib_, stdenv ? stdenv_,
|
||||
}:
|
||||
|
||||
let
|
||||
config_ = config;
|
||||
in
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
hasAttr getAttr optional optionals optionalString optionalAttrs maintainers platforms;
|
||||
|
@ -65,8 +69,6 @@ let
|
|||
(buildPackages.deterministic-uname.override { inherit modDirVersion; })
|
||||
] ++ optional (lib.versionAtLeast version "5.13") zstd;
|
||||
|
||||
drvAttrs = config_: kernelConf: kernelPatches: configfile:
|
||||
let
|
||||
config = let attrName = attr: "CONFIG_" + attr; in {
|
||||
isSet = attr: hasAttr (attrName attr) config;
|
||||
|
||||
|
@ -85,20 +87,26 @@ let
|
|||
|
||||
isModular = config.isYes "MODULES";
|
||||
|
||||
kernelConf = stdenv.hostPlatform.linux-kernel;
|
||||
|
||||
buildDTBs = kernelConf.DTB or false;
|
||||
in
|
||||
|
||||
in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // {
|
||||
passthru = rec {
|
||||
inherit version modDirVersion config kernelPatches configfile
|
||||
moduleBuildDependencies stdenv;
|
||||
inherit isZen isHardened isLibre;
|
||||
isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true;
|
||||
baseVersion = lib.head (lib.splitString "-rc" version);
|
||||
kernelOlder = lib.versionOlder baseVersion;
|
||||
kernelAtLeast = lib.versionAtLeast baseVersion;
|
||||
};
|
||||
assert lib.versionOlder version "5.8" -> libelf != null;
|
||||
assert lib.versionAtLeast version "5.8" -> elfutils != null;
|
||||
|
||||
inherit src;
|
||||
stdenv.mkDerivation ({
|
||||
pname = "linux";
|
||||
inherit version src;
|
||||
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr zstd python3Minimal ]
|
||||
++ optional (kernelConf.target == "uImage") buildPackages.ubootTools
|
||||
++ optional (lib.versionOlder version "5.8") libelf
|
||||
++ optionals (lib.versionAtLeast version "4.16") [ bison flex ]
|
||||
++ optionals (lib.versionAtLeast version "5.2") [ cpio pahole zlib ]
|
||||
++ optional (lib.versionAtLeast version "5.8") elfutils
|
||||
;
|
||||
|
||||
patches =
|
||||
map (p: p.patch) kernelPatches
|
||||
|
@ -198,6 +206,22 @@ let
|
|||
cd $buildRoot
|
||||
'';
|
||||
|
||||
hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" "pie" ];
|
||||
|
||||
# Absolute paths for compilers avoid any PATH-clobbering issues.
|
||||
makeFlags = [
|
||||
"O=$(buildRoot)"
|
||||
"CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
|
||||
"HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
|
||||
"HOSTLD=${buildPackages.stdenv.cc.bintools}/bin/${buildPackages.stdenv.cc.targetPrefix}ld"
|
||||
"ARCH=${stdenv.hostPlatform.linuxArch}"
|
||||
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
||||
] ++ (kernelConf.makeFlags or [])
|
||||
++ extraMakeFlags;
|
||||
|
||||
karch = stdenv.hostPlatform.linuxArch;
|
||||
|
||||
buildFlags = [
|
||||
"DTC_FLAGS=-@"
|
||||
"KBUILD_BUILD_VERSION=1-NixOS"
|
||||
|
@ -354,6 +378,18 @@ let
|
|||
stripDebugList="$(cd $dev && echo lib/modules/*/build/*/)"
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
passthru = rec {
|
||||
inherit version modDirVersion config kernelPatches configfile
|
||||
moduleBuildDependencies stdenv;
|
||||
inherit isZen isHardened isLibre;
|
||||
isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true;
|
||||
baseVersion = lib.head (lib.splitString "-rc" version);
|
||||
kernelOlder = lib.versionOlder baseVersion;
|
||||
kernelAtLeast = lib.versionAtLeast baseVersion;
|
||||
};
|
||||
|
||||
requiredSystemFeatures = [ "big-parallel" ];
|
||||
|
||||
meta = {
|
||||
|
@ -371,40 +407,8 @@ let
|
|||
platforms = platforms.linux;
|
||||
timeout = 14400; # 4 hours
|
||||
} // extraMeta;
|
||||
};
|
||||
in
|
||||
|
||||
assert lib.versionOlder version "5.8" -> libelf != null;
|
||||
assert lib.versionAtLeast version "5.8" -> elfutils != null;
|
||||
|
||||
stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPatches configfile) // {
|
||||
pname = "linux";
|
||||
inherit version;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr zstd python3Minimal ]
|
||||
++ optional (stdenv.hostPlatform.linux-kernel.target == "uImage") buildPackages.ubootTools
|
||||
++ optional (lib.versionOlder version "5.8") libelf
|
||||
++ optionals (lib.versionAtLeast version "4.16") [ bison flex ]
|
||||
++ optionals (lib.versionAtLeast version "5.2") [ cpio pahole zlib ]
|
||||
++ optional (lib.versionAtLeast version "5.8") elfutils
|
||||
;
|
||||
|
||||
hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" "pie" ];
|
||||
|
||||
# Absolute paths for compilers avoid any PATH-clobbering issues.
|
||||
makeFlags = [
|
||||
"O=$(buildRoot)"
|
||||
"CC=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
|
||||
"HOSTCC=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc"
|
||||
"HOSTLD=${buildPackages.stdenv.cc.bintools}/bin/${buildPackages.stdenv.cc.targetPrefix}ld"
|
||||
"ARCH=${stdenv.hostPlatform.linuxArch}"
|
||||
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
||||
] ++ (stdenv.hostPlatform.linux-kernel.makeFlags or [])
|
||||
++ extraMakeFlags;
|
||||
|
||||
karch = stdenv.hostPlatform.linuxArch;
|
||||
} // (optionalAttrs (pos != null) { inherit pos; })))
|
||||
} // optionalAttrs (pos != null) {
|
||||
inherit pos;
|
||||
} // optionalAttrs isModular {
|
||||
outputs = [ "out" "dev" ];
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue