about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/generic.nix
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2010-02-27 21:48:48 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2010-02-27 21:48:48 +0000
commit289d728337730527f476f343c12f62b60a56f50b (patch)
treeb66e620aa2d5a635229c29790c80dc758a4beaaa /pkgs/os-specific/linux/kernel/generic.nix
parent305a7a2ddfadcb93103375ab4a36838d737093d1 (diff)
downloadnixlib-289d728337730527f476f343c12f62b60a56f50b.tar
nixlib-289d728337730527f476f343c12f62b60a56f50b.tar.gz
nixlib-289d728337730527f476f343c12f62b60a56f50b.tar.bz2
nixlib-289d728337730527f476f343c12f62b60a56f50b.tar.lz
nixlib-289d728337730527f476f343c12f62b60a56f50b.tar.xz
nixlib-289d728337730527f476f343c12f62b60a56f50b.tar.zst
nixlib-289d728337730527f476f343c12f62b60a56f50b.zip
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
Diffstat (limited to 'pkgs/os-specific/linux/kernel/generic.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix57
1 files changed, 37 insertions, 20 deletions
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index f54af384816b..13b3cdcfb94f 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -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