From bf7467cbb1f08470854db73ee2c07d9f896aefc8 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 01:23:51 -0400 Subject: [PATCH 01/18] Add first attempt at linux/kernel/manual-config. The goal of this function is to make it possible to build a kernel with a user provided .config. As a secondary goal, it will extract NixOS-relevant features from the config automatically. As a tertiary goal, the build will aim to be simpler than the current generic kernel builder.sh. Unfortunately, that simplicity is offset by the complexity of the feature extraction, especially since nix segfaults when trying to split the file into lines (so an import from a derivation is used) --- .../linux/kernel/manual-config.nix | 81 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 ++ 2 files changed, 86 insertions(+) create mode 100644 pkgs/os-specific/linux/kernel/manual-config.nix diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix new file mode 100644 index 000000000000..8cf8b6502166 --- /dev/null +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -0,0 +1,81 @@ +{ stdenv, runCommand }: + +{ version, modDirVersion ? version, src, patches ? [], config }: + +with stdenv.lib; + +let + + # Function to parse the config file to get the features supported + readFeatures = config: + let + # !!! Original causes recursion too deep, need to import from derivation + # linesWithComments = splitString "\n" (builtins.readFile config); + lines = import "${runCommand "lines.nix" {} '' + echo "[" >> $out + while read line; do + if [ -n "$line" ] && [ `expr index "$line" "#"` -ne 1 ]; then + echo "${"''"}" >> $out + echo $(echo $line | sed "s@${"''"}@\$\{\"${"''"}\"}@g")"${"''"}" >> $out + fi + done < ${config} + echo "]" >> $out + ''}"; + + nvpairs = map (s: let split = splitString "=" s; fst = head split; in { + name = substring (stringLength "CONFIG_") (stringLength fst) fst; + value = head (tail split); + }) lines; + + configAttrs = listToAttrs nvpairs; + + getValue = option: + if hasAttr option configAttrs then getAttr option configAttrs else null; + + isYes = option: (getValue option) == "y"; + in + + { + modular = isYes "MODULES"; + }; + + features = readFeatures config; + +in + +stdenv.mkDerivation ({ + name = "linux-${version}"; + + enableParallelBuilding = true; + + passthru = { + inherit version modDirVersion features; + }; + + inherit patches src; + + postPatch = '' + for mf in $(find -name Makefile); do + echo "stripping FHS paths in \`$mf'..." + sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g' + done + ''; + + configurePhase = '' + runHook preConfigure + ln -sv ${config} .config + make oldconfig + runHook postConfigure + ''; + + INSTALL_PATH = "$out"; +} // optionalAttrs features.modular { + MODLIB = "$out/lib/modules/${modDirVersion}"; + + INSTALL_MOD_STRIP = "1"; + + postInstall = '' + make modules_install $makeFlags "$\{makeFlagsArray[@]}" \ + $installFlags "$\{installFlagsArray[@]}" + ''; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 76918d081db0..0ca0f90768a3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5856,6 +5856,11 @@ let linux = linuxPackages.kernel; linuxPackages = linuxPackages_3_2; + # A function to build a manually-configured kernel + linuxManualConfig = import ../os-specific/linux/kernel/manual-config.nix { + inherit stdenv runCommand; + }; + keyutils = callPackage ../os-specific/linux/keyutils { }; libselinux = callPackage ../os-specific/linux/libselinux { }; From ff728a63650a2544351b5114912589c8e7faf21f Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 01:29:56 -0400 Subject: [PATCH 02/18] The kernel build needs hostname and perl --- pkgs/os-specific/linux/kernel/manual-config.nix | 4 +++- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 8cf8b6502166..783a41337551 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,4 +1,4 @@ -{ stdenv, runCommand }: +{ stdenv, runCommand, nettools, perl }: { version, modDirVersion ? version, src, patches ? [], config }: @@ -69,6 +69,8 @@ stdenv.mkDerivation ({ ''; INSTALL_PATH = "$out"; + + buildNativeInputs = [ perl nettools ]; } // optionalAttrs features.modular { MODLIB = "$out/lib/modules/${modDirVersion}"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0ca0f90768a3..190c380fccb6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5858,7 +5858,7 @@ let # A function to build a manually-configured kernel linuxManualConfig = import ../os-specific/linux/kernel/manual-config.nix { - inherit stdenv runCommand; + inherit stdenv runCommand nettools perl; }; keyutils = callPackage ../os-specific/linux/keyutils { }; From dfa750732d34740577c2907be70450ad23aa37c4 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 01:34:27 -0400 Subject: [PATCH 03/18] linux/kernel/manual-config: Properly set env vars referencing $out --- pkgs/os-specific/linux/kernel/manual-config.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 783a41337551..79c8061bb10d 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -68,11 +68,11 @@ stdenv.mkDerivation ({ runHook postConfigure ''; - INSTALL_PATH = "$out"; + INSTALL_PATH = "$(out)"; buildNativeInputs = [ perl nettools ]; } // optionalAttrs features.modular { - MODLIB = "$out/lib/modules/${modDirVersion}"; + MODLIB = "$(out)/lib/modules/${modDirVersion}"; INSTALL_MOD_STRIP = "1"; From aa40e0ff5965c7d195026d193f216d58c3263b46 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 01:57:59 -0400 Subject: [PATCH 04/18] linux/kernel/manual-config: The default 'make install' tries to do something with LILO, so install the kernel manually --- pkgs/os-specific/linux/kernel/manual-config.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 79c8061bb10d..34bcaba3f316 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -71,6 +71,16 @@ stdenv.mkDerivation ({ INSTALL_PATH = "$(out)"; buildNativeInputs = [ perl nettools ]; + + installPhase = '' + runHook preInstall + mkdir $out + mv -v System.map $out + # !!! Assumes x86 + mv -v arch/x86/boot/bzImage $out + mv -v vmlinux $out + runHook postInstall + ''; } // optionalAttrs features.modular { MODLIB = "$(out)/lib/modules/${modDirVersion}"; From 471b4bc9bb9e67caec7fb11bb7f01c6c7b2b0d85 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 02:49:31 -0400 Subject: [PATCH 05/18] MODLIB needs to be passed directly to make --- pkgs/os-specific/linux/kernel/manual-config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 34bcaba3f316..131ff74bcf1c 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -82,7 +82,7 @@ stdenv.mkDerivation ({ runHook postInstall ''; } // optionalAttrs features.modular { - MODLIB = "$(out)/lib/modules/${modDirVersion}"; + makeFlags = [ "MODLIB=\"$(out)/lib/modules/${modDirVersion}\"" ]; INSTALL_MOD_STRIP = "1"; From 5a9d9f4f457e98df5a017a295f7c4e9c1c5f5128 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 02:57:58 -0400 Subject: [PATCH 06/18] linux/kernel/manual-config: Properly escape makeFlagsArray and installFlagsArray --- pkgs/os-specific/linux/kernel/manual-config.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 131ff74bcf1c..83740b6285e7 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -87,7 +87,7 @@ stdenv.mkDerivation ({ INSTALL_MOD_STRIP = "1"; postInstall = '' - make modules_install $makeFlags "$\{makeFlagsArray[@]}" \ - $installFlags "$\{installFlagsArray[@]}" + make modules_install $makeFlags "''${makeFlagsArray[@]}" \ + $installFlags "''${installFlagsArray[@]}" ''; }) From a36456ca255883520fd07fa5a0b8a23bd08196a3 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 03:09:44 -0400 Subject: [PATCH 07/18] linux/kernel-manual-config: Simplify the lines.nix runCommand now that I know how to escape properly --- pkgs/os-specific/linux/kernel/manual-config.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 83740b6285e7..87550401f78a 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -14,9 +14,9 @@ let lines = import "${runCommand "lines.nix" {} '' echo "[" >> $out while read line; do - if [ -n "$line" ] && [ `expr index "$line" "#"` -ne 1 ]; then - echo "${"''"}" >> $out - echo $(echo $line | sed "s@${"''"}@\$\{\"${"''"}\"}@g")"${"''"}" >> $out + if [ -n "$line" ] && [ "#" != ''${line:0:1} ]; then + echo "'''" >> $out + echo $(echo $line | sed "s/'''/''''/g")"'''" >> $out fi done < ${config} echo "]" >> $out From e42a6c5f464b7f77a60ffbbcf0cdaed739d553eb Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 03:27:09 -0400 Subject: [PATCH 08/18] linux/kernel/manual-config: Move the build directory to $out instead of symlinking it --- pkgs/os-specific/linux/kernel/manual-config.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 87550401f78a..651f9b14e778 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -65,6 +65,7 @@ stdenv.mkDerivation ({ runHook preConfigure ln -sv ${config} .config make oldconfig + rm .config.old runHook postConfigure ''; @@ -89,5 +90,9 @@ stdenv.mkDerivation ({ postInstall = '' make modules_install $makeFlags "''${makeFlagsArray[@]}" \ $installFlags "''${installFlagsArray[@]}" + rm -f $out/lib/modules/${modDirVersion}/{build,source} + cd .. + mv $sourceRoot $out/lib/modules/${modDirVersion}/build + ln -sv $out/lib/modules/${modDirVersion}/{build,source} ''; }) From 48b5e8eee7e1b86ca06417875627f032d5107ee4 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 03:49:52 -0400 Subject: [PATCH 09/18] linux/kernel/manual-config: Build in a separate directory and move the build and source trees into $out --- .../linux/kernel/manual-config.nix | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 651f9b14e778..b4dbb786016c 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -41,6 +41,9 @@ let features = readFeatures config; + commonMakeFlags = [ + "O=../build" + ]; in stdenv.mkDerivation ({ @@ -54,8 +57,8 @@ stdenv.mkDerivation ({ inherit patches src; - postPatch = '' - for mf in $(find -name Makefile); do + prePatch = '' + for mf in $(find -name Makefile -o -name Makefile.include); do echo "stripping FHS paths in \`$mf'..." sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g' done @@ -63,9 +66,11 @@ stdenv.mkDerivation ({ configurePhase = '' runHook preConfigure - ln -sv ${config} .config - make oldconfig - rm .config.old + mkdir ../build + make $makeFlags "''${makeFlagsArray[@]}" mrproper + ln -sv ${config} ../build/.config + make $makeFlags "''${makeFlagsArray[@]}" oldconfig + rm ../build/.config.old runHook postConfigure ''; @@ -76,14 +81,18 @@ stdenv.mkDerivation ({ installPhase = '' runHook preInstall mkdir $out - mv -v System.map $out + mv -v ../build/System.map $out # !!! Assumes x86 - mv -v arch/x86/boot/bzImage $out - mv -v vmlinux $out + mv -v ../build/arch/x86/boot/bzImage $out + mv -v ../build/vmlinux $out runHook postInstall ''; + + makeFlags = commonMakeFlags; } // optionalAttrs features.modular { - makeFlags = [ "MODLIB=\"$(out)/lib/modules/${modDirVersion}\"" ]; + makeFlags = commonMakeFlags ++ [ + "MODLIB=\"$(out)/lib/modules/${modDirVersion}\"" + ]; INSTALL_MOD_STRIP = "1"; @@ -92,7 +101,7 @@ stdenv.mkDerivation ({ $installFlags "''${installFlagsArray[@]}" rm -f $out/lib/modules/${modDirVersion}/{build,source} cd .. - mv $sourceRoot $out/lib/modules/${modDirVersion}/build - ln -sv $out/lib/modules/${modDirVersion}/{build,source} + mv $sourceRoot $out/lib/modules/${modDirVersion}/source + mv build $out/lib/modules/${modDirVersion}/build ''; }) From 4f713d27f7a58e1e5c2a7f0f138c97b76dea3979 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 03:57:50 -0400 Subject: [PATCH 10/18] kmod: Bump to version 9 --- pkgs/os-specific/linux/kmod/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kmod/default.nix b/pkgs/os-specific/linux/kmod/default.nix index 89d4c463cc70..afa19491ce5e 100644 --- a/pkgs/os-specific/linux/kmod/default.nix +++ b/pkgs/os-specific/linux/kmod/default.nix @@ -1,11 +1,11 @@ { stdenv, fetchurl, xz, zlib, pkgconfig }: stdenv.mkDerivation rec { - name = "kmod-8"; + name = "kmod-9"; src = fetchurl { url = "mirror://kernel/linux/utils/kernel/kmod/${name}.tar.xz"; - sha256 = "0kbkjzcyhkwgcplwa29n0f03ccwpg4df83pdl5nkvsk2rzgx3xrm"; + sha256 = "1kyfplx0gygzxp5dn81yk3cn8zzraqm497vis04r1g1dnry2c1q6"; }; # Disable xz/zlib support to prevent needing them in the initrd. From 6e3b17feece1364a341af7eb11c18b4eaa8556bb Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:01:40 -0400 Subject: [PATCH 11/18] linux/kernel/manual-config: Run depmod after build --- pkgs/os-specific/linux/kernel/manual-config.nix | 3 ++- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index b4dbb786016c..fe9769a00ade 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,4 +1,4 @@ -{ stdenv, runCommand, nettools, perl }: +{ stdenv, runCommand, nettools, perl, kmod }: { version, modDirVersion ? version, src, patches ? [], config }: @@ -62,6 +62,7 @@ stdenv.mkDerivation ({ echo "stripping FHS paths in \`$mf'..." sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g' done + sed -i -e 's|/sbin/depmod|${kmod}/sbin/depmod|' Makefile ''; configurePhase = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 190c380fccb6..d8223f2e0ffd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5858,7 +5858,7 @@ let # A function to build a manually-configured kernel linuxManualConfig = import ../os-specific/linux/kernel/manual-config.nix { - inherit stdenv runCommand nettools perl; + inherit stdenv runCommand nettools perl kmod; }; keyutils = callPackage ../os-specific/linux/keyutils { }; From 6b18ab5365f8cb4c6cd66f69ad1f083a91da22f0 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:07:43 -0400 Subject: [PATCH 12/18] linux/kernel/manual-config: Remove useless INSTALL_MOD_STRIP variable --- pkgs/os-specific/linux/kernel/manual-config.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index fe9769a00ade..aa23656171d6 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -95,8 +95,6 @@ stdenv.mkDerivation ({ "MODLIB=\"$(out)/lib/modules/${modDirVersion}\"" ]; - INSTALL_MOD_STRIP = "1"; - postInstall = '' make modules_install $makeFlags "''${makeFlagsArray[@]}" \ $installFlags "''${installFlagsArray[@]}" From 6bb20c7ba21071f020a312370c03f145b35546d9 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:23:28 -0400 Subject: [PATCH 13/18] linux/kernel/manual-config: Strip modules after install --- pkgs/os-specific/linux/kernel/manual-config.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index aa23656171d6..d6cf3bf76125 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -103,4 +103,10 @@ stdenv.mkDerivation ({ mv $sourceRoot $out/lib/modules/${modDirVersion}/source mv build $out/lib/modules/${modDirVersion}/build ''; + + postFixup = '' + if [ -z "$dontStrip" ]; then + find $out -name "*.ko" -print0 | xargs -0 strip -S + fi + ''; }) From a9a70856845625bd6b9f988d07553774f88d18d4 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:31:40 -0400 Subject: [PATCH 14/18] linux/kernel/manual-config: Allow manually specifying features, cleanup --- .../linux/kernel/manual-config.nix | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index d6cf3bf76125..730983d895fe 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,7 +1,5 @@ { stdenv, runCommand, nettools, perl, kmod }: -{ version, modDirVersion ? version, src, patches ? [], config }: - with stdenv.lib; let @@ -39,13 +37,25 @@ let modular = isYes "MODULES"; }; - features = readFeatures config; - - commonMakeFlags = [ - "O=../build" - ]; in +{ + # The kernel version + version, + # The version of the kernel module directory + modDirVersion ? version, + # The kernel source (tarball, git checkout, etc.) + src, + # Any patches + patches ? [], + # The kernel .config file + config, + # Manually specified features the kernel supports + features ? readFeatures config +}: + +let commonMakeFlags = [ "O=../build" ]; in + stdenv.mkDerivation ({ name = "linux-${version}"; From 98341e0bda814d6e92e9fef8522840eec738db4b Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:48:50 -0400 Subject: [PATCH 15/18] linux/kernel/manual-config: Use the kernel's make install --- .../linux/kernel/manual-config.nix | 34 +++++++++---------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 730983d895fe..777b33a84731 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,4 +1,4 @@ -{ stdenv, runCommand, nettools, perl, kmod }: +{ stdenv, runCommand, nettools, perl, kmod, writeTextFile }: with stdenv.lib; @@ -54,7 +54,20 @@ in features ? readFeatures config }: -let commonMakeFlags = [ "O=../build" ]; in +let + commonMakeFlags = [ + "O=../build" + "INSTALL_PATH=$(out)" + "INSTALLKERNEL=${installkernel}" + ]; + + installkernel = writeTextFile { name = "installkernel"; executable=true; text = '' + #!/bin/sh + mkdir $4 + mv -v $2 $4 + mv -v $3 $4 + '';}; +in stdenv.mkDerivation ({ name = "linux-${version}"; @@ -70,9 +83,8 @@ stdenv.mkDerivation ({ prePatch = '' for mf in $(find -name Makefile -o -name Makefile.include); do echo "stripping FHS paths in \`$mf'..." - sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g' + sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' done - sed -i -e 's|/sbin/depmod|${kmod}/sbin/depmod|' Makefile ''; configurePhase = '' @@ -85,19 +97,7 @@ stdenv.mkDerivation ({ runHook postConfigure ''; - INSTALL_PATH = "$(out)"; - - buildNativeInputs = [ perl nettools ]; - - installPhase = '' - runHook preInstall - mkdir $out - mv -v ../build/System.map $out - # !!! Assumes x86 - mv -v ../build/arch/x86/boot/bzImage $out - mv -v ../build/vmlinux $out - runHook postInstall - ''; + buildNativeInputs = [ perl nettools kmod ]; makeFlags = commonMakeFlags; } // optionalAttrs features.modular { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d8223f2e0ffd..88e1626e5801 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5858,7 +5858,7 @@ let # A function to build a manually-configured kernel linuxManualConfig = import ../os-specific/linux/kernel/manual-config.nix { - inherit stdenv runCommand nettools perl kmod; + inherit stdenv runCommand nettools perl kmod writeTextFile; }; keyutils = callPackage ../os-specific/linux/keyutils { }; From f7b6f01da1362931d5c58ec1fd78922966b3e2d4 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:52:34 -0400 Subject: [PATCH 16/18] linux/kernel/manual-config: Cleanup --- pkgs/os-specific/linux/kernel/manual-config.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 777b33a84731..59fb1a6cd4c8 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -51,6 +51,7 @@ in # The kernel .config file config, # Manually specified features the kernel supports + # If unspecified, this will be autodetected from the .config features ? readFeatures config }: @@ -100,7 +101,7 @@ stdenv.mkDerivation ({ buildNativeInputs = [ perl nettools kmod ]; makeFlags = commonMakeFlags; -} // optionalAttrs features.modular { +} // optionalAttrs (features ? modular && features.modular) { makeFlags = commonMakeFlags ++ [ "MODLIB=\"$(out)/lib/modules/${modDirVersion}\"" ]; From 46fa5ab105937b44098bc4c4403a62e9cf4dd950 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:56:56 -0400 Subject: [PATCH 17/18] linux/kernel/manual-config: Relink the symlink from the build directory to the source directory after the source directory is moved --- pkgs/os-specific/linux/kernel/manual-config.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 59fb1a6cd4c8..5aee2c194b63 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -113,6 +113,8 @@ stdenv.mkDerivation ({ cd .. mv $sourceRoot $out/lib/modules/${modDirVersion}/source mv build $out/lib/modules/${modDirVersion}/build + unlink $out/lib/modules/${modDirVersion}/build/source + ln -sv $out/lib/modules/${modDirVersion}/{,build/}source ''; postFixup = '' From 6585646d4195c9cfab1fdae2b473222159aa096b Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 29 Jul 2012 04:59:38 -0400 Subject: [PATCH 18/18] linux/kernel/manual-config: Add meta --- pkgs/os-specific/linux/kernel/manual-config.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 5aee2c194b63..5d2a42646bf6 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -101,6 +101,16 @@ stdenv.mkDerivation ({ buildNativeInputs = [ perl nettools kmod ]; makeFlags = commonMakeFlags; + + meta = { + description = "The Linux kernel"; + license = "GPLv2"; + homepage = http://www.kernel.org/; + maintainers = [ + maintainers.shlevy + ]; + platforms = lib.platforms.linux; + }; } // optionalAttrs (features ? modular && features.modular) { makeFlags = commonMakeFlags ++ [ "MODLIB=\"$(out)/lib/modules/${modDirVersion}\""