Fixing the kernel expressions to allow normal and cross-building, depending

on the native and cross platforms.

I thought I already did that today in a previous commit, but I did all wrong.

svn path=/nixpkgs/trunk/; revision=20280
This commit is contained in:
Lluís Batlle i Rossell 2010-02-27 21:48:48 +00:00
parent 305a7a2ddf
commit 289d728337
3 changed files with 39 additions and 34 deletions

View File

@ -9,6 +9,9 @@
, # The kernel configuration.
config
, # The kernel configuration when cross building.
configCross ? {}
, # An attribute set whose attributes express the availability of
# certain features in this kernel. E.g. `{iwlwifi = true;}'
# indicates a kernel that provides Intel wireless support. Used in
@ -33,13 +36,6 @@
, preConfigure ? ""
, extraMeta ? {}
, platform ? {
name = "pc";
uboot = null;
kernelBaseConfig = "defconfig";
kernelAutoModules = true;
kernelTarget = "bzImage";
}
, ubootChooser ? null
, ...
}:
@ -47,12 +43,18 @@
assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"
|| stdenv.system == "armv5tel-linux";
assert platform.name == "sheevaplug" -> platform.uboot != null;
assert stdenv.platform.name == "sheevaplug" -> stdenv.platform.uboot != null;
let
lib = stdenv.lib;
kernelConfigFun = baseConfig:
let
configFromPatches =
map ({extraConfig ? "", ...}: extraConfig) kernelPatches;
in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches);
in
stdenv.mkDerivation {
@ -69,34 +71,49 @@ stdenv.mkDerivation {
generateConfig = ./generate-config.pl;
inherit preConfigure src module_init_tools localVersion;
autoModules = platform.kernelAutoModules;
patches = map (p: p.patch) kernelPatches;
kernelConfig =
let
configFromPatches =
map ({extraConfig ? "", ...}: extraConfig) kernelPatches;
in lib.concatStringsSep "\n" ([config] ++ configFromPatches);
kernelConfig = kernelConfigFun config;
# For UML and non-PC, just ignore all options that don't apply (We are lazy).
ignoreConfigErrors = (userModeLinux || platform.name != "pc");
ignoreConfigErrors = (userModeLinux || stdenv.platform.name != "pc");
buildNativeInputs = [ perl mktemp ];
buildInputs = lib.optional (platform.uboot != null) (ubootChooser platform.uboot);
buildInputs = lib.optional (stdenv.platform.uboot != null)
(ubootChooser stdenv.platform.uboot);
platformName = platform.name;
kernelBaseConfig = platform.kernelBaseConfig;
kernelTarget = platform.kernelTarget;
platformName = stdenv.platform.name;
kernelBaseConfig = stdenv.platform.kernelBaseConfig;
kernelTarget = stdenv.platform.kernelTarget;
autoModules = stdenv.platform.kernelAutoModules;
arch =
if xen then "xen" else
if userModeLinux then "um" else
if platform ? kernelArch then platform.kernelArch else
if stdenv.system == "i686-linux" then "i386" else
if stdenv.system == "x86_64-linux" then "x86_64" else
abort "Platform ${stdenv.system} is not supported.";
crossAttrs = let
cp = stdenv.cross.platform;
in
assert cp.name == "sheevaplug" -> cp.uboot != null;
{
arch = cp.kernelArch;
platformName = cp.name;
kernelBaseConfig = cp.kernelBaseConfig;
kernelTarget = cp.kernelTarget;
autoModules = cp.kernelAutoModules;
# Just ignore all options that don't apply (We are lazy).
ignoreConfigErrors = true;
kernelConfig = kernelConfigFun configCross;
buildInputs = lib.optional (cp.uboot != null) (ubootChooser cp.uboot);
};
meta = {
description =
(if userModeLinux then

View File

@ -207,13 +207,7 @@ import ./generic.nix (
};
config = configWithPlatform stdenv.platform;
platform = stdenv.platform;
crossAttrs = {
config = configWithPlatform stdenv.cross.platform;
platform = stdenv.cross.platform;
};
configCross = configWithPlatform stdenv.cross.platform;
features.iwlwifi = true;
}

View File

@ -205,13 +205,7 @@ import ./generic.nix (
};
config = configWithPlatform stdenv.platform;
platform = stdenv.platform;
crossAttrs = {
config = configWithPlatform stdenv.cross.platform;
platform = stdenv.cross.platform;
};
configCross = configWithPlatform stdenv.cross.platform;
features.iwlwifi = true;
}