2014-01-01 15:21:25 +01:00
|
|
|
{ stdenv, perl, linuxManualConfig
|
2008-03-24 20:39:42 +01:00
|
|
|
|
2009-01-15 16:40:23 +01:00
|
|
|
, # The kernel source tarball.
|
|
|
|
src
|
2008-03-24 20:39:42 +01:00
|
|
|
|
2009-01-15 16:40:23 +01:00
|
|
|
, # The kernel version.
|
|
|
|
version
|
|
|
|
|
2013-07-31 23:56:48 +02:00
|
|
|
, # Overrides to the kernel config.
|
|
|
|
extraConfig ? ""
|
|
|
|
|
2011-08-08 22:49:49 +02:00
|
|
|
, # The version number used for the module directory
|
|
|
|
modDirVersion ? version
|
|
|
|
|
2009-01-15 16:40:23 +01:00
|
|
|
, # 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
|
|
|
|
# NixOS to implement kernel-specific behaviour.
|
|
|
|
features ? {}
|
|
|
|
|
|
|
|
, # A list of patches to apply to the kernel. Each element of this list
|
2008-03-24 20:39:42 +01:00
|
|
|
# should be an attribute set {name, patch} where `name' is a
|
|
|
|
# symbolic name and `patch' is the actual patch. The patch may
|
|
|
|
# optionally be compressed with gzip or bzip2.
|
2009-01-15 16:40:23 +01:00
|
|
|
kernelPatches ? []
|
2009-09-11 15:16:18 +02:00
|
|
|
, extraMeta ? {}
|
2009-07-15 23:09:17 +02:00
|
|
|
, ...
|
2008-03-24 20:39:42 +01:00
|
|
|
}:
|
|
|
|
|
2010-02-27 22:48:48 +01:00
|
|
|
assert stdenv.platform.name == "sheevaplug" -> stdenv.platform.uboot != null;
|
2009-11-08 18:19:46 +01:00
|
|
|
|
2008-03-24 20:39:42 +01:00
|
|
|
let
|
|
|
|
|
2009-01-15 16:40:23 +01:00
|
|
|
lib = stdenv.lib;
|
2008-03-24 20:39:42 +01:00
|
|
|
|
2010-02-27 22:48:48 +01:00
|
|
|
kernelConfigFun = baseConfig:
|
|
|
|
let
|
|
|
|
configFromPatches =
|
|
|
|
map ({extraConfig ? "", ...}: extraConfig) kernelPatches;
|
|
|
|
in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches);
|
|
|
|
|
2014-01-01 15:21:25 +01:00
|
|
|
configfile = stdenv.mkDerivation {
|
|
|
|
name = "linux-config-${version}";
|
|
|
|
|
|
|
|
generateConfig = ./generate-config.pl;
|
|
|
|
|
|
|
|
kernelConfig = kernelConfigFun config;
|
|
|
|
|
|
|
|
ignoreConfigErrors = stdenv.platform.name != "pc";
|
|
|
|
|
|
|
|
nativeBuildInputs = [ perl ];
|
|
|
|
|
|
|
|
platformName = stdenv.platform.name;
|
|
|
|
kernelBaseConfig = stdenv.platform.kernelBaseConfig;
|
|
|
|
kernelTarget = stdenv.platform.kernelTarget;
|
|
|
|
autoModules = stdenv.platform.kernelAutoModules;
|
|
|
|
arch = stdenv.platform.kernelArch;
|
|
|
|
|
|
|
|
crossAttrs = let
|
|
|
|
cp = stdenv.cross.platform;
|
|
|
|
in {
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
buildCommand = ''
|
|
|
|
# Get a basic config file for later refinement with $generateConfig.
|
|
|
|
make -C ${kernel.sourceRoot} O=$PWD $kernelBaseConfig ARCH=$arch
|
|
|
|
|
|
|
|
# Create the config file.
|
|
|
|
echo "generating kernel configuration..."
|
|
|
|
echo "$kernelConfig" > kernel-config
|
|
|
|
DEBUG=1 ARCH=$arch KERNEL_CONFIG=kernel-config AUTO_MODULES=$autoModules \
|
|
|
|
SRC=${kernel.sourceRoot} perl -w $generateConfig
|
|
|
|
mv .config $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
kernel = linuxManualConfig {
|
|
|
|
inherit version modDirVersion src kernelPatches;
|
|
|
|
|
|
|
|
configfile = configfile.nativeDrv or configfile;
|
|
|
|
|
|
|
|
crossConfigfile = configfile.crossDrv or configfile;
|
|
|
|
|
|
|
|
config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
|
|
|
|
|
|
|
|
crossConfig = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
|
|
|
|
};
|
|
|
|
|
2013-07-31 23:56:48 +02:00
|
|
|
configWithPlatform = kernelPlatform:
|
|
|
|
import ./common-config.nix { inherit stdenv version kernelPlatform extraConfig; };
|
|
|
|
|
|
|
|
config = configWithPlatform stdenv.platform;
|
|
|
|
configCross = configWithPlatform stdenv.cross.platform;
|
|
|
|
|
2008-05-22 21:29:23 +02:00
|
|
|
passthru = {
|
|
|
|
# Combine the `features' attribute sets of all the kernel patches.
|
2013-07-31 16:54:29 +02:00
|
|
|
features = lib.fold (x: y: (x.features or {}) // y) features kernelPatches;
|
2014-01-01 15:21:25 +01:00
|
|
|
|
|
|
|
meta = kernel.meta // extraMeta;
|
2008-05-22 21:29:23 +02:00
|
|
|
};
|
2011-07-11 16:07:21 +02:00
|
|
|
|
2014-01-01 15:21:25 +01:00
|
|
|
nativeDrv = lib.addPassthru kernel.nativeDrv passthru;
|
2011-07-24 22:24:12 +02:00
|
|
|
|
2014-01-01 15:21:25 +01:00
|
|
|
crossDrv = lib.addPassthru kernel.crossDrv passthru;
|
|
|
|
in if kernel ? crossDrv then nativeDrv // { inherit nativeDrv crossDrv; } else lib.addPassthru kernel passthru
|