Skip to content

Commit

Permalink
linux: default stdenv.hostPlatform.linux-kernel
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alyssais committed May 22, 2023
1 parent 0a50127 commit febe477
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 4 additions & 5 deletions pkgs/os-specific/linux/kernel/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
# symbolic name and `patch' is the actual patch. The patch may
# optionally be compressed with gzip or bzip2.
kernelPatches ? []
, ignoreConfigErrors ? stdenv.hostPlatform.linux-kernel.name != "pc"
, ignoreConfigErrors ? stdenv.hostPlatform.linux-kernel.name or "" != "pc"
, extraMeta ? {}

, isZen ? false
, isLibre ? false
, isHardened ? false

# easy overrides to stdenv.hostPlatform.linux-kernel members
, autoModules ? stdenv.hostPlatform.linux-kernel.autoModules
, autoModules ? stdenv.hostPlatform.linux-kernel.autoModules or true
, preferBuiltin ? stdenv.hostPlatform.linux-kernel.preferBuiltin or false
, kernelArch ? stdenv.hostPlatform.linuxArch
, kernelTests ? []
Expand Down Expand Up @@ -128,11 +128,10 @@ let
++ lib.optionals (lib.versionAtLeast version "4.16") [ bison flex ]
++ lib.optional (lib.versionAtLeast version "5.2") pahole;

platformName = stdenv.hostPlatform.linux-kernel.name;
# e.g. "defconfig"
kernelBaseConfig = if defconfig != null then defconfig else stdenv.hostPlatform.linux-kernel.baseConfig;
kernelBaseConfig = if defconfig != null then defconfig else stdenv.hostPlatform.linux-kernel.baseConfig or "defconfig";
# e.g. "bzImage"
kernelTarget = stdenv.hostPlatform.linux-kernel.target;
kernelTarget = stdenv.hostPlatform.linux-kernel.target or "vmlinux";

makeFlags = lib.optionals (stdenv.hostPlatform.linux-kernel ? makeFlags) stdenv.hostPlatform.linux-kernel.makeFlags
++ extraMakeFlags;
Expand Down
9 changes: 5 additions & 4 deletions pkgs/os-specific/linux/kernel/manual-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ let

isModular = config.isYes "MODULES";

kernelConf = stdenv.hostPlatform.linux-kernel;
kernelConf = stdenv.hostPlatform.linux-kernel;
target = kernelConf.target or "vmlinux";

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

depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl bc nettools openssl rsync gmp libmpc mpfr zstd python3Minimal ]
++ optional (kernelConf.target == "uImage") buildPackages.ubootTools
++ optional (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 ]
Expand Down Expand Up @@ -297,8 +298,8 @@ stdenv.mkDerivation ({
# Some image types need special install targets (e.g. uImage is installed with make uinstall)
installTargets = [
(kernelConf.installTarget or (
/**/ if kernelConf.target == "uImage" then "uinstall"
else if kernelConf.target == "zImage" || kernelConf.target == "Image.gz" then "zinstall"
/**/ if target == "uImage" then "uinstall"
else if target == "zImage" || target == "Image.gz" then "zinstall"
else "install"))
];

Expand Down

0 comments on commit febe477

Please sign in to comment.