Skip to content

Commit febe477

Browse files
committed
linux: default stdenv.hostPlatform.linux-kernel
With this change, we can do a reasonable default build of Linux for configurations that do not have a corresponding platforms.nix entry, and where the user has not explicitly specified the linux-kernel values. This allows us to do best effort builds for obscure architectures (I tested a build for s390x). The platformName binding has not been used since 70cb705 ("Trying to make the linux kernels also cross-build."), so I removed it.
1 parent 0a50127 commit febe477

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pkgs/os-specific/linux/kernel/generic.nix

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
# symbolic name and `patch' is the actual patch. The patch may
4848
# optionally be compressed with gzip or bzip2.
4949
kernelPatches ? []
50-
, ignoreConfigErrors ? stdenv.hostPlatform.linux-kernel.name != "pc"
50+
, ignoreConfigErrors ? stdenv.hostPlatform.linux-kernel.name or "" != "pc"
5151
, extraMeta ? {}
5252

5353
, isZen ? false
5454
, isLibre ? false
5555
, isHardened ? false
5656

5757
# easy overrides to stdenv.hostPlatform.linux-kernel members
58-
, autoModules ? stdenv.hostPlatform.linux-kernel.autoModules
58+
, autoModules ? stdenv.hostPlatform.linux-kernel.autoModules or true
5959
, preferBuiltin ? stdenv.hostPlatform.linux-kernel.preferBuiltin or false
6060
, kernelArch ? stdenv.hostPlatform.linuxArch
6161
, kernelTests ? []
@@ -128,11 +128,10 @@ let
128128
++ lib.optionals (lib.versionAtLeast version "4.16") [ bison flex ]
129129
++ lib.optional (lib.versionAtLeast version "5.2") pahole;
130130

131-
platformName = stdenv.hostPlatform.linux-kernel.name;
132131
# e.g. "defconfig"
133-
kernelBaseConfig = if defconfig != null then defconfig else stdenv.hostPlatform.linux-kernel.baseConfig;
132+
kernelBaseConfig = if defconfig != null then defconfig else stdenv.hostPlatform.linux-kernel.baseConfig or "defconfig";
134133
# e.g. "bzImage"
135-
kernelTarget = stdenv.hostPlatform.linux-kernel.target;
134+
kernelTarget = stdenv.hostPlatform.linux-kernel.target or "vmlinux";
136135

137136
makeFlags = lib.optionals (stdenv.hostPlatform.linux-kernel ? makeFlags) stdenv.hostPlatform.linux-kernel.makeFlags
138137
++ extraMakeFlags;

pkgs/os-specific/linux/kernel/manual-config.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ let
8787

8888
isModular = config.isYes "MODULES";
8989

90-
kernelConf = stdenv.hostPlatform.linux-kernel;
90+
kernelConf = stdenv.hostPlatform.linux-kernel;
91+
target = kernelConf.target or "vmlinux";
9192

9293
buildDTBs = kernelConf.DTB or false;
9394
in
@@ -101,7 +102,7 @@ stdenv.mkDerivation ({
101102

102103
depsBuildBuild = [ buildPackages.stdenv.cc ];
103104
nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr zstd python3Minimal ]
104-
++ optional (kernelConf.target == "uImage") buildPackages.ubootTools
105+
++ optional (target == "uImage") buildPackages.ubootTools
105106
++ optional (lib.versionOlder version "5.8") libelf
106107
++ optionals (lib.versionAtLeast version "4.16") [ bison flex ]
107108
++ optionals (lib.versionAtLeast version "5.2") [ cpio pahole zlib ]
@@ -297,8 +298,8 @@ stdenv.mkDerivation ({
297298
# Some image types need special install targets (e.g. uImage is installed with make uinstall)
298299
installTargets = [
299300
(kernelConf.installTarget or (
300-
/**/ if kernelConf.target == "uImage" then "uinstall"
301-
else if kernelConf.target == "zImage" || kernelConf.target == "Image.gz" then "zinstall"
301+
/**/ if target == "uImage" then "uinstall"
302+
else if target == "zImage" || target == "Image.gz" then "zinstall"
302303
else "install"))
303304
];
304305

0 commit comments

Comments
 (0)