Merge branch 'manual-config-multiple-outputs' into upstream-master

This branch makes the manual config kernel a lot more space efficient by separating out the build and source trees (needed for out-of-tree modules) from the actual bzImage and in-tree modules.

Also some other small improvements along the way.
This commit is contained in:
Shea Levy 2013-03-02 10:04:19 -05:00
commit e4d7e87c14
3 changed files with 159 additions and 127 deletions

View File

@ -75,16 +75,6 @@ let
"INSTALL_PATH=$(out)" "INSTALL_PATH=$(out)"
] ++ (optional isModular "INSTALL_MOD_PATH=$(out)") ] ++ (optional isModular "INSTALL_MOD_PATH=$(out)")
++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware"; ++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware";
in
stdenv.mkDerivation {
name = "linux-${version}";
enableParallelBuilding = true;
passthru = {
inherit version modDirVersion config kernelPatches src;
};
sourceRoot = stdenv.mkDerivation { sourceRoot = stdenv.mkDerivation {
name = "linux-${version}-source"; name = "linux-${version}-source";
@ -108,16 +98,30 @@ stdenv.mkDerivation {
mv $sourceRoot $out mv $sourceRoot $out
''; '';
}; };
in
stdenv.mkDerivation {
name = "linux-${version}";
enableParallelBuilding = true;
outputs = if isModular then [ "out" "dev" ] else null;
passthru = {
inherit version modDirVersion config kernelPatches src;
};
inherit sourceRoot;
unpackPhase = '' unpackPhase = ''
mkdir build mkdir build
export buildRoot="$(pwd)/build" export buildRoot="$(pwd)/build"
ln -sv ${configfile} $buildRoot/.config cd ${sourceRoot}
cd $sourceRoot
''; '';
configurePhase = '' configurePhase = ''
runHook preConfigure runHook preConfigure
ln -sv ${configfile} $buildRoot/.config
make $makeFlags "''${makeFlagsArray[@]}" oldconfig make $makeFlags "''${makeFlagsArray[@]}" oldconfig
runHook postConfigure runHook postConfigure
''; '';
@ -140,17 +144,25 @@ stdenv.mkDerivation {
make modules_install $makeFlags "''${makeFlagsArray[@]}" \ make modules_install $makeFlags "''${makeFlagsArray[@]}" \
$installFlags "''${installFlagsArray[@]}" $installFlags "''${installFlagsArray[@]}"
rm -f $out/lib/modules/${modDirVersion}/build rm -f $out/lib/modules/${modDirVersion}/build
mv $buildRoot $out/lib/modules/${modDirVersion}/build mkdir -p $dev/lib/modules/${modDirVersion}
mv $out/lib/modules/${modDirVersion}/source $dev/lib/modules/${modDirVersion}/source
mv $buildRoot $dev/lib/modules/${modDirVersion}/build
'' else optionalString installsFirmware '' '' else optionalString installsFirmware ''
make firmware_install $makeFlags "''${makeFlagsArray[@]}" \ make firmware_install $makeFlags "''${makeFlagsArray[@]}" \
$installFlags "''${installFlagsArray[@]}" $installFlags "''${installFlagsArray[@]}"
''); '');
postFixup = optionalString isModular '' postFixup = if isModular then ''
if [ -z "$dontStrip" ]; then if [ -z "$dontStrip" ]; then
find $out -name "*.ko" -print0 | xargs -0 -r strip -S find $out -name "*.ko" -print0 | xargs -0 -r strip -S
# Remove all references to the source directory to avoid unneeded
# runtime dependencies
find $out -name "*.ko" -print0 | xargs -0 -r sed -i \
"s|${sourceRoot}|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${sourceRoot.name}|g"
fi fi
''; '' else null;
__ignoreNulls = true;
meta = { meta = {
description = "The Linux kernel"; description = "The Linux kernel";

View File

@ -44,7 +44,8 @@ let
if !allowUnfree && (let l = attrs.meta.license or ""; in l == "unfree" || l == "unfree-redistributable" || l == lib.licenses.proprietary) then if !allowUnfree && (let l = attrs.meta.license or ""; in l == "unfree" || l == "unfree-redistributable" || l == lib.licenses.proprietary) then
throw "package ${attrs.name} has an unfree license, refusing to evaluate" throw "package ${attrs.name} has an unfree license, refusing to evaluate"
else else
(derivation ( let
drv = derivation (
(removeAttrs attrs ["meta" "passthru" "crossAttrs"]) (removeAttrs attrs ["meta" "passthru" "crossAttrs"])
// (let // (let
buildInputs = attrs.buildInputs or []; buildInputs = attrs.buildInputs or [];
@ -68,18 +69,33 @@ let
(crossConfig == null) buildInputs; (crossConfig == null) buildInputs;
propagatedBuildNativeInputs = propagatedBuildNativeInputs ++ propagatedBuildNativeInputs = propagatedBuildNativeInputs ++
lib.optionals (crossConfig == null) propagatedBuildInputs; lib.optionals (crossConfig == null) propagatedBuildInputs;
})) }));
)
outputs = drv.outputs or [ "out" ];
commonAttrs = drv // (builtins.listToAttrs outputsList) //
({ all = map (x: x.value) outputsList;
# The meta attribute is passed in the resulting attribute set, # The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not # but it's not part of the actual derivation, i.e., it's not
# passed to the builder and is not a dependency. But since we # passed to the builder and is not a dependency. But since we
# include it in the result, it *is* available to nix-env for # include it in the result, it *is* available to nix-env for
# queries. # queries.
// { meta = attrs.meta or {}; } meta = attrs.meta or {};
}) //
# Pass through extra attributes that are not inputs, but # Pass through extra attributes that are not inputs, but
# should be made available to Nix expressions using the # should be made available to Nix expressions using the
# derivation (e.g., in assertions). # derivation (e.g., in assertions).
// (attrs.passthru or {}); (attrs.passthru or {});
outputToAttrListElement = outputName:
{ name = outputName;
value = commonAttrs // {
inherit (builtins.getAttr outputName drv) outPath drvPath type outputName;
};
};
outputsList = map outputToAttrListElement outputs;
in (builtins.head outputsList).value;
# Utility flags to test the type of platform. # Utility flags to test the type of platform.
isDarwin = result.system == "x86_64-darwin"; isDarwin = result.system == "x86_64-darwin";

View File

@ -6008,9 +6008,12 @@ let
for a specific kernel. This function can then be called for for a specific kernel. This function can then be called for
whatever kernel you're using. */ whatever kernel you're using. */
linuxPackagesFor = kernel: self: let callPackage = newScope self; in rec { linuxPackagesFor = kernel:
let
callPackage = newScope self;
inherit kernel; self = {
kernel = kernel.dev or kernel;
acpi_call = callPackage ../os-specific/linux/acpi-call {}; acpi_call = callPackage ../os-specific/linux/acpi-call {};
@ -6019,16 +6022,16 @@ let
ati_drivers_x11 = callPackage ../os-specific/linux/ati-drivers { }; ati_drivers_x11 = callPackage ../os-specific/linux/ati-drivers { };
aufs = aufs =
if kernel.features ? aufs2 then if self.kernel.features ? aufs2 then
callPackage ../os-specific/linux/aufs/2.nix { } callPackage ../os-specific/linux/aufs/2.nix { }
else if kernel.features ? aufs3 then else if self.kernel.features ? aufs3 then
callPackage ../os-specific/linux/aufs/3.nix { } callPackage ../os-specific/linux/aufs/3.nix { }
else null; else null;
aufs_util = aufs_util =
if kernel.features ? aufs2 then if self.kernel.features ? aufs2 then
callPackage ../os-specific/linux/aufs-util/2.nix { } callPackage ../os-specific/linux/aufs-util/2.nix { }
else if kernel.features ? aufs3 then else if self.kernel.features ? aufs3 then
callPackage ../os-specific/linux/aufs-util/3.nix { } callPackage ../os-specific/linux/aufs-util/3.nix { }
else null; else null;
@ -6047,8 +6050,8 @@ let
iwlwifi = callPackage ../os-specific/linux/iwlwifi { }; iwlwifi = callPackage ../os-specific/linux/iwlwifi { };
iwlwifi4965ucode = iwlwifi4965ucode =
(if (builtins.compareVersions kernel.version "2.6.27" == 0) (if (builtins.compareVersions self.kernel.version "2.6.27" == 0)
|| (builtins.compareVersions kernel.version "2.6.27" == 1) || (builtins.compareVersions self.kernel.version "2.6.27" == 1)
then iwlwifi4965ucodeV2 then iwlwifi4965ucodeV2
else iwlwifi4965ucodeV1); else iwlwifi4965ucodeV1);
@ -6076,9 +6079,9 @@ let
linuxHeaders = glibc.kernelHeaders; linuxHeaders = glibc.kernelHeaders;
}; };
splashutils = let hasFbConDecor = if kernel ? features splashutils = let hasFbConDecor = if self.kernel ? features
then kernel.features ? fbConDecor then self.kernel.features ? fbConDecor
else kernel.config.isEnabled "FB_CON_DECOR"; else self.kernel.config.isEnabled "FB_CON_DECOR";
in if hasFbConDecor then pkgs.splashutils else null; in if hasFbConDecor then pkgs.splashutils else null;
/* compiles but has to be integrated into the kernel somehow /* compiles but has to be integrated into the kernel somehow
@ -6095,7 +6098,7 @@ let
}; };
systemtap = callPackage ../development/tools/profiling/systemtap { systemtap = callPackage ../development/tools/profiling/systemtap {
linux = kernel; linux = self.kernel;
inherit (gnome) libglademm; inherit (gnome) libglademm;
}; };
@ -6112,16 +6115,17 @@ let
zfs = callPackage ../os-specific/linux/zfs/default.nix { }; zfs = callPackage ../os-specific/linux/zfs/default.nix { };
}; };
in (self // { kernel = self.kernel.out; });
# Build the kernel modules for the some of the kernels. # Build the kernel modules for the some of the kernels.
linuxPackages_2_6_32 = recurseIntoAttrs (linuxPackagesFor linux_2_6_32 pkgs.linuxPackages_2_6_32); linuxPackages_2_6_32 = recurseIntoAttrs (linuxPackagesFor linux_2_6_32);
linuxPackages_2_6_35 = recurseIntoAttrs (linuxPackagesFor linux_2_6_35 pkgs.linuxPackages_2_6_35); linuxPackages_2_6_35 = recurseIntoAttrs (linuxPackagesFor linux_2_6_35);
linuxPackages_3_0 = recurseIntoAttrs (linuxPackagesFor linux_3_0 pkgs.linuxPackages_3_0); linuxPackages_3_0 = recurseIntoAttrs (linuxPackagesFor linux_3_0);
linuxPackages_3_2 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_2 pkgs.linuxPackages_3_2); linuxPackages_3_2 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_2);
linuxPackages_3_2_xen = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_2_xen pkgs.linuxPackages_3_2_xen); linuxPackages_3_2_xen = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_2_xen);
linuxPackages_3_4 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_4 pkgs.linuxPackages_3_4); linuxPackages_3_4 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_4);
linuxPackages_3_7 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_7 pkgs.linuxPackages_3_7); linuxPackages_3_7 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_7);
linuxPackages_3_8 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_8 pkgs.linuxPackages_3_8); linuxPackages_3_8 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_8);
# The current default kernel / kernel modules. # The current default kernel / kernel modules.
linux = linuxPackages.kernel; linux = linuxPackages.kernel;