From e7018d383f17ecab977a5e92fd06b70297dcb7bc Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Fri, 10 Nov 2017 03:31:03 +0900 Subject: [PATCH 01/17] kernel: attempt to rerun unpackPhase if sthg fishy When trying to compile/hack the kernel, it would keep asking me to generate the .config file. That was because I had skipped the unpackPhase. Also if one exit the nix-shell (voluntarely or because of an error) and wants to resume the configure phase, it would fail because '$buildRoot' is not set; it is set during the unpackPhase. My tackle on that is that there is a great chance the nix-shell was resumed from the unpacked folder. Then the configurePhase sets the buildRoot accordingly. I could have done it via a preConfigure hook but either way the current situation is not good since one doesn"t know why he is asked to generate the config. Dying with a message "set $buildRoot" could be an option. --- pkgs/os-specific/linux/kernel/manual-config.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index b4ee23079d930..983d553c8485f 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -105,7 +105,16 @@ let configurePhase = '' runHook preConfigure + if [ -z "$buildRoot" ]; then + + # assume we are in the $sourceRoot folder + echo "buildRoot is not set" + mkdir -p ../build + export buildRoot=$(pwd)/../build + fi + ln -sv ${configfile} $buildRoot/.config + # ln -sv ${configfile} ''${buildRoot:=$(pwd)/../build}/.config make $makeFlags "''${makeFlagsArray[@]}" oldconfig runHook postConfigure From 4a55e654a0b258f078fbffdb52d8e34e4cfb30c9 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Wed, 15 Nov 2017 03:48:49 +0900 Subject: [PATCH 02/17] fixes for nix-shell --- 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 983d553c8485f..242f9bc53839a 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -90,7 +90,7 @@ let preUnpack = '' mkdir build - export buildRoot="$(pwd)/build" + export buildRoot="$PWD/build" ''; patches = map (p: p.patch) kernelPatches; @@ -109,8 +109,8 @@ let # assume we are in the $sourceRoot folder echo "buildRoot is not set" - mkdir -p ../build - export buildRoot=$(pwd)/../build + mkdir build + export buildRoot="$PWD/build" fi ln -sv ${configfile} $buildRoot/.config From 26293f37f58757f8c794f41cee554b4bd69f3209 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 18 Nov 2017 03:28:38 +0900 Subject: [PATCH 03/17] TODO check if kernel is build in parallel --- pkgs/os-specific/linux/kernel/manual-config.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 242f9bc53839a..d249a8a93adff 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -56,6 +56,7 @@ let commonMakeFlags = [ "O=$(buildRoot)" + ] ++ stdenv.lib.optionals (stdenv.platform ? kernelMakeFlags) stdenv.platform.kernelMakeFlags; @@ -259,6 +260,8 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe makeFlags = commonMakeFlags ++ [ "ARCH=${stdenv.platform.kernelArch}" ]; + # ++ stdenv.lib.optional enableParallelBuilding "-j{}"; + # cfg.buildCores # TODO set karch = stdenv.platform.kernelArch; From 344475c4c03d984155e2b9ff737174517c3b2a50 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 21 Nov 2017 03:27:59 +0900 Subject: [PATCH 04/17] trying to be more flexible about config generation suing functions/shell etc wip in pkgs/os-specific/linux/kernel/config.nix --- pkgs/os-specific/linux/kernel/config.nix | 87 +++++++++++++++++++ pkgs/os-specific/linux/kernel/generic.nix | 63 +------------- .../linux/kernel/manual-config.nix | 64 +++++++++++--- 3 files changed, 142 insertions(+), 72 deletions(-) create mode 100644 pkgs/os-specific/linux/kernel/config.nix diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix new file mode 100644 index 0000000000000..1358c6da2e0ac --- /dev/null +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -0,0 +1,87 @@ +# {stdenv +# , buildRoot +# , srcRoot +# }: +{ + patchKconfig = '' + # Patch kconfig to print "###" after every question so that + # generate-config.pl from the generic builder can answer them. + sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c + ''; + + + # + buildKernelConfig = arch: autoModules: '' + cd $buildRoot + + # Get a basic config file for later refinement with $generateConfig. + make -C ../$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 \ + PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig + ''; + +} +# TODO we should be able to generate standalone config and config on the go +# => we need functions with module etc +# espcially we need a bash builder +# TODO have a standalone + stdenv.mkDerivation { + inherit ignoreConfigErrors; + name = "linux-config-${version}"; + + generateConfig = ./generate-config.pl; + + kernelConfig = kernelConfigFun config; + + nativeBuildInputs = [ perl ]; + + platformName = stdenv.platform.name; + kernelBaseConfig = stdenv.platform.kernelBaseConfig; + kernelTarget = stdenv.platform.kernelTarget; + autoModules = stdenv.platform.kernelAutoModules; + preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; + arch = stdenv.platform.kernelArch; + + crossAttrs = let + cp = hostPlatform.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; + + inherit (kernel.crossDrv) src patches preUnpack; + }; + + prePatch = kernel.prePatch + patchKconfig; + inherit (kernel) src patches preUnpack; + + buildPhase = '' + cd $buildRoot + + # Get a basic config file for later refinement with $generateConfig. + make -C ../$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 \ + PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig + ''; + + installPhase = "mv .config $out"; + + enableParallelBuilding = true; + } + + diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index c2f4e6843f591..324410d4e743d 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -57,70 +57,15 @@ let map ({extraConfig ? "", ...}: extraConfig) kernelPatches; in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); - configfile = stdenv.mkDerivation { - inherit ignoreConfigErrors; - name = "linux-config-${version}"; - - generateConfig = ./generate-config.pl; - - kernelConfig = kernelConfigFun config; - - nativeBuildInputs = [ perl ]; - - platformName = stdenv.platform.name; - kernelBaseConfig = stdenv.platform.kernelBaseConfig; - kernelTarget = stdenv.platform.kernelTarget; - autoModules = stdenv.platform.kernelAutoModules; - preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; - arch = stdenv.platform.kernelArch; - - crossAttrs = let - cp = hostPlatform.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; - - inherit (kernel.crossDrv) src patches preUnpack; - }; - - prePatch = kernel.prePatch + '' - # Patch kconfig to print "###" after every question so that - # generate-config.pl from the generic builder can answer them. - sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c - ''; - - inherit (kernel) src patches preUnpack; - - buildPhase = '' - cd $buildRoot - - # Get a basic config file for later refinement with $generateConfig. - make -C ../$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 \ - PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig - ''; - - installPhase = "mv .config $out"; - - enableParallelBuilding = true; - }; + # TODO moved it + # configfile = callPackage + # TODO le transformer plutot en kernel = buildLinux { inherit version modDirVersion src kernelPatches stdenv; configfile = configfile.nativeDrv or configfile; + # configfile = null; crossConfigfile = configfile.crossDrv or configfile; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index d249a8a93adff..14a887099fd65 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -31,12 +31,13 @@ in { # Patches for cross compiling only crossKernelPatches ? [], # The native kernel .config file - configfile, + configfile ? null, # The cross kernel .config file crossConfigfile ? configfile, # Manually specified nixexpr representing the config # If unspecified, this will be autodetected from the .config - config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), + # config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), + config ? null, # Cross-compiling config crossConfig ? if allowImportFromDerivation then (readConfig crossConfigfile) else config, # Whether to utilize the controversial import-from-derivation feature to parse the config @@ -54,6 +55,7 @@ let cp -av $3 $4 ''; }; + # flags common to the cross-compiled and native builds commonMakeFlags = [ "O=$(buildRoot)" @@ -82,17 +84,23 @@ let installsFirmware = (config.isEnabled "FW_LOADER") && (isModular || (config.isDisabled "FIRMWARE_IN_KERNEL")); - in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // { + in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // rec { passthru = { - inherit version modDirVersion config kernelPatches configfile; + inherit version modDirVersion kernelPatches configfile; + # inherit config; }; inherit src; - preUnpack = '' - mkdir build - export buildRoot="$PWD/build" - ''; + # why this + # preUnpack = '' + # mkdir build + # export buildRoot="$PWD/build" + # ''; + autoModules = stdenv.platform.kernelAutoModules; + preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; + arch = stdenv.platform.kernelArch; + kernelBaseConfig = stdenv.platform.kernelBaseConfig; patches = map (p: p.patch) kernelPatches; @@ -102,10 +110,32 @@ let sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' done sed -i Makefile -e 's|= depmod|= ${kmod}/bin/depmod|' + '' + + # Patch kconfig to print "###" after every question so that + # generate-config.pl from the generic builder can answer them. + '' + sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c ''; + # imported from generic.nix + buildConfigPhase = '' + + echo "buildRoot set to $buildRoot" + cd $buildRoot + + # Get a basic config file for later refinement with $generateConfig. + make -C ../$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 \ + PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig + ''; + + preConfigure = buildConfigPhase; + configurePhase = '' - runHook preConfigure if [ -z "$buildRoot" ]; then # assume we are in the $sourceRoot folder @@ -113,9 +143,8 @@ let mkdir build export buildRoot="$PWD/build" fi + runHook preConfigure - ln -sv ${configfile} $buildRoot/.config - # ln -sv ${configfile} ''${buildRoot:=$(pwd)/../build}/.config make $makeFlags "''${makeFlagsArray[@]}" oldconfig runHook postConfigure @@ -221,6 +250,8 @@ let make firmware_install $makeFlags "''${makeFlagsArray[@]}" \ $installFlags "''${installFlagsArray[@]}" ''); + # TODO add it as an output + # installPhase = "mv .config $out"; requiredSystemFeatures = [ "big-parallel" ]; @@ -245,6 +276,8 @@ in assert stdenv.lib.versionAtLeast version "4.15" -> libelf != null; assert stdenv.lib.versionAtLeast version "4.15" -> utillinux != null; stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKernelPatches) configfile) // { +# config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), +# stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKernelPatches) configfile) // rec { name = "linux-${version}"; enableParallelBuilding = true; @@ -257,11 +290,16 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe hardeningDisable = [ "bindnow" "format" "fortify" "stackprotector" "pic" ]; + # concatenated from drvAttrs + # configurePhase = '' + # ''; + makeFlags = commonMakeFlags ++ [ "ARCH=${stdenv.platform.kernelArch}" - ]; - # ++ stdenv.lib.optional enableParallelBuilding "-j{}"; + ] + # ++ stdenv.lib.optional enableParallelBuilding "-j${cfg.buildCores}"; # cfg.buildCores # TODO set + ; karch = stdenv.platform.kernelArch; From a0d126182c0945cefcf9c595acadb9cde36b11c1 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 21 Nov 2017 02:59:04 +0900 Subject: [PATCH 05/17] wip --- pkgs/os-specific/linux/kernel/config.nix | 11 +++++++++++ pkgs/os-specific/linux/kernel/manual-config.nix | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index 1358c6da2e0ac..eaea2ffe914c6 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -3,6 +3,17 @@ # , srcRoot # }: { + # runCommand = name: env: buildCommand: + readConfig = configfile: import (runCommand "config.nix" {} '' + echo "{" > "$out" + while IFS='=' read key val; do + [ "x''${key#CONFIG_}" != "x$key" ] || continue + no_firstquote="''${val#\"}"; + echo ' "'"$key"'" = "'"''${no_firstquote%\"}"'";' >> "$out" + done < "${configfile}" + echo "}" >> $out + '').outPath; + patchKconfig = '' # Patch kconfig to print "###" after every question so that # generate-config.pl from the generic builder can answer them. diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 14a887099fd65..9a894c90e245f 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -6,6 +6,7 @@ }: let + # TODO import from config readConfig = configfile: import (runCommand "config.nix" {} '' echo "{" > "$out" while IFS='=' read key val; do @@ -31,7 +32,7 @@ in { # Patches for cross compiling only crossKernelPatches ? [], # The native kernel .config file - configfile ? null, + configfile, # The cross kernel .config file crossConfigfile ? configfile, # Manually specified nixexpr representing the config From c2818dfc07830c1d04238195500db231d7d01953 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 21 Nov 2017 21:43:36 +0900 Subject: [PATCH 06/17] wip --- pkgs/os-specific/linux/kernel/config.nix | 11 ++++++++--- pkgs/os-specific/linux/kernel/generic.nix | 8 ++------ pkgs/os-specific/linux/kernel/manual-config.nix | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index eaea2ffe914c6..d5b30ac43699d 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -20,6 +20,11 @@ sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c ''; + kernelConfigFun = baseConfig: kernelPatches: + let + configFromPatches = + map ({extraConfig ? "", ...}: extraConfig) kernelPatches; + in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); # buildKernelConfig = arch: autoModules: '' @@ -35,12 +40,11 @@ PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig ''; -} # TODO we should be able to generate standalone config and config on the go # => we need functions with module etc # espcially we need a bash builder # TODO have a standalone - stdenv.mkDerivation { + kernelConfig = stdenv.mkDerivation { inherit ignoreConfigErrors; name = "linux-config-${version}"; @@ -93,6 +97,7 @@ installPhase = "mv .config $out"; enableParallelBuilding = true; - } + }; +} diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 324410d4e743d..cefc7b73ccd9f 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -51,14 +51,10 @@ let config = configWithPlatform stdenv.platform; configCross = configWithPlatform hostPlatform.platform; - kernelConfigFun = baseConfig: - let - configFromPatches = - map ({extraConfig ? "", ...}: extraConfig) kernelPatches; - in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); # TODO moved it - # configfile = callPackage + # callPackage ./config.nix {}; + configfile = (import ./config.nix); # TODO le transformer plutot en kernel = buildLinux { diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 9a894c90e245f..1c4dc745ff54a 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -298,7 +298,8 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe makeFlags = commonMakeFlags ++ [ "ARCH=${stdenv.platform.kernelArch}" ] - # ++ stdenv.lib.optional enableParallelBuilding "-j${cfg.buildCores}"; + # {cfg.buildCores} + ++ stdenv.lib.optional enableParallelBuilding "-j4" # cfg.buildCores # TODO set ; From 8e7296d9763bf3a4917976c22eadfa0237bdb71a Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 23 Nov 2017 02:50:37 +0900 Subject: [PATCH 07/17] it still does an unpack for the config =========== En gros on a linux_mptcp = callPackage generic.nix (linux_mptcp.nix) generic.nix fait appel a buildLinux qui est defini dans manual-config.nix generic.nix importe aussi kernelPlatform: import ./common-config.nix extraConfig (optional) is a string specifying extra options to be concatenated to the kernel configuration file (.config) =========== kernelPatches is a set of bridge_stp_helper = { name = "bridge-stp-helper"; patch = ./bridge-stp-helper.patch; }; 'make oldconfig' It reads the existing .config file and prompts the user for options in the current kernel source that are not found in the file. This is useful when taking an existing configuration and moving it to a new kernel configfile est un chemin vers le fichier au format '.config' tandis que 'config' pcBase = { name = "pc"; kernelHeadersBaseConfig = "defconfig"; kernelBaseConfig = "defconfig"; # Build whatever possible as a module, if not stated in the extra config. kernelAutoModules = true; kernelTarget = "bzImage"; }; pc64 = pcBase // { kernelArch = "x86_64"; }; kernelTargets kernelExtraConfig = '' # Ubi for the mtd MTD_UBI y UBIFS_FS y UBIFS_FS_XATTR y UBIFS_FS_ADVANCED_COMPR y UBIFS_FS_LZO y UBIFS_FS_ZLIB y UBIFS_FS_DEBUG n ''; dans la phase de build du noyau make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch warning: dumping very large path (> 256 MiB); this may run out of memory Using .. as source for kernel --- pkgs/os-specific/linux/kernel/config.nix | 4 +- pkgs/os-specific/linux/kernel/generic.nix | 3 +- pkgs/os-specific/linux/kernel/linux-mptcp.nix | 1 + .../linux/kernel/manual-config.nix | 42 +++++++------------ 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index d5b30ac43699d..4887c022883fd 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -20,6 +20,8 @@ sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c ''; + + # generates kernelConfigFun = baseConfig: kernelPatches: let configFromPatches = @@ -44,7 +46,7 @@ # => we need functions with module etc # espcially we need a bash builder # TODO have a standalone - kernelConfig = stdenv.mkDerivation { + kernelConfigDrv = stdenv.mkDerivation { inherit ignoreConfigErrors; name = "linux-config-${version}"; diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index cefc7b73ccd9f..858c77557207a 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -6,7 +6,7 @@ , # The kernel version. version -, # Overrides to the kernel config. +, # Appended verbatim to kernel .config extraConfig ? "" , # The version number used for the module directory @@ -54,6 +54,7 @@ let # TODO moved it # callPackage ./config.nix {}; + # configfile = stdenv.mkDerivation { configfile = (import ./config.nix); # TODO le transformer plutot en diff --git a/pkgs/os-specific/linux/kernel/linux-mptcp.nix b/pkgs/os-specific/linux/kernel/linux-mptcp.nix index 92b202100a63d..5c4266b6a72ca 100644 --- a/pkgs/os-specific/linux/kernel/linux-mptcp.nix +++ b/pkgs/os-specific/linux/kernel/linux-mptcp.nix @@ -1,5 +1,6 @@ { stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: +# ~ linux_mptcp = callPackage generic.nix (linux_mptcp.nix) import ./generic.nix (rec { mptcpVersion = "0.93"; modDirVersion = "4.9.60"; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 1c4dc745ff54a..1cf14b50b8e55 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,3 +1,4 @@ +# defines buildLinux { runCommand, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl , libelf ? null , utillinux ? null @@ -16,6 +17,7 @@ let done < "${configfile}" echo "}" >> $out '').outPath; + confHelpers = import ./config.nix; in { # Allow overriding stdenv on each buildLinux call stdenv, @@ -37,8 +39,8 @@ in { crossConfigfile ? configfile, # Manually specified nixexpr representing the config # If unspecified, this will be autodetected from the .config - # config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), - config ? null, + config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), + # config ? null, # Cross-compiling config crossConfig ? if allowImportFromDerivation then (readConfig crossConfigfile) else config, # Whether to utilize the controversial import-from-derivation feature to parse the config @@ -94,10 +96,10 @@ let inherit src; # why this - # preUnpack = '' + preUnpack = '' # mkdir build # export buildRoot="$PWD/build" - # ''; + ''; autoModules = stdenv.platform.kernelAutoModules; preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; arch = stdenv.platform.kernelArch; @@ -111,41 +113,28 @@ let sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' done sed -i Makefile -e 's|= depmod|= ${kmod}/bin/depmod|' - '' + - # Patch kconfig to print "###" after every question so that - # generate-config.pl from the generic builder can answer them. '' - sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c - ''; + # if no configfile set then it means we have to generate it on the go + + stdenv.lib.optionalString (configfile == null) confHelpers.patchKconfig; # imported from generic.nix - buildConfigPhase = '' - - echo "buildRoot set to $buildRoot" - cd $buildRoot - # Get a basic config file for later refinement with $generateConfig. - make -C ../$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 \ - PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig - ''; - - preConfigure = buildConfigPhase; + # preConfigure = buildConfigPhase; configurePhase = '' - if [ -z "$buildRoot" ]; then + # if [ -z "$buildRoot" ]; then + # we should be in $sourceRoot # assume we are in the $sourceRoot folder + # echo "buildRoot is not set" echo "buildRoot is not set" mkdir build export buildRoot="$PWD/build" - fi + # fi runHook preConfigure + # reads the existing .config file and prompts the user for options in + # the current kernel source that are not found in the file. make $makeFlags "''${makeFlagsArray[@]}" oldconfig runHook postConfigure @@ -294,6 +283,7 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe # concatenated from drvAttrs # configurePhase = '' # ''; + # TODO add an output for the config ? makeFlags = commonMakeFlags ++ [ "ARCH=${stdenv.platform.kernelArch}" From ab67f6b6e85c4cb9c026a7bde77ff3a8507ddb56 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 25 Nov 2017 04:13:22 +0900 Subject: [PATCH 08/17] TODO generate config if configfile set to null --- pkgs/os-specific/linux/kernel/config.nix | 85 ++++++++++++------- .../linux/kernel/generate-config.pl | 6 +- pkgs/os-specific/linux/kernel/generic.nix | 30 +++++-- pkgs/os-specific/linux/kernel/lib.nix | 63 ++++++++++++++ pkgs/os-specific/linux/kernel/linux-mptcp.nix | 4 +- .../linux/kernel/manual-config.nix | 56 ++++++++---- 6 files changed, 190 insertions(+), 54 deletions(-) create mode 100644 pkgs/os-specific/linux/kernel/lib.nix diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index 4887c022883fd..28f7a91f82428 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -1,9 +1,37 @@ -# {stdenv +{ + stdenv +, lib # , buildRoot # , srcRoot -# }: -{ - # runCommand = name: env: buildCommand: +, ignoreConfigErrors, version +# , kernelConfig +, runCommand +, perl, hostPlatform +, ... +}: + +with import lib.nix; +/* + +# TODO we should be able to generate standalone config and config on the go +# => we need functions with module etc +# espcially we need a bash builder +# TODO have a standalone +# etait defini dans generic.nix + +There variables are exported to be used by the generate-config.pl script, see the buildPhase +debug +autoModules +preferBuiltin +ignoreConfigErrors +kernel_config + +kernel-config is a file + +TODO doesn t need to be a derviation ? +*/ +let + readConfig = configfile: import (runCommand "config.nix" {} '' echo "{" > "$out" while IFS='=' read key val; do @@ -14,53 +42,46 @@ echo "}" >> $out '').outPath; + # RENAME to 'load' + convertKernelConfigToJson = readConfig; + patchKconfig = '' # Patch kconfig to print "###" after every question so that # generate-config.pl from the generic builder can answer them. sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c ''; - - # generates + # generates functor + # kernelConfigFun = baseConfig: kernelPatches: let configFromPatches = map ({extraConfig ? "", ...}: extraConfig) kernelPatches; in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); - - # - buildKernelConfig = arch: autoModules: '' - cd $buildRoot - - # Get a basic config file for later refinement with $generateConfig. - make -C ../$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 \ - PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig - ''; - -# TODO we should be able to generate standalone config and config on the go -# => we need functions with module etc -# espcially we need a bash builder -# TODO have a standalone - kernelConfigDrv = stdenv.mkDerivation { +in +stdenv.mkDerivation { inherit ignoreConfigErrors; name = "linux-config-${version}"; generateConfig = ./generate-config.pl; - kernelConfig = kernelConfigFun config; + # string that will be echoed to kernel-config file + # writeFile + # echo "$kernelConfig" > kernel-config + kernelConfig = kernelConfigFun config kernel-patches; nativeBuildInputs = [ perl ]; platformName = stdenv.platform.name; + + # sthg like "defconfig" kernelBaseConfig = stdenv.platform.kernelBaseConfig; + + # e.g. "bzImage" kernelTarget = stdenv.platform.kernelTarget; autoModules = stdenv.platform.kernelAutoModules; preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; + # kernel ARCH arch = stdenv.platform.kernelArch; crossAttrs = let @@ -80,9 +101,16 @@ inherit (kernel.crossDrv) src patches preUnpack; }; + patchKconfig = '' + # Patch kconfig to print "###" after every question so that + # generate-config.pl from the generic builder can answer them. + sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c + ''; + prePatch = kernel.prePatch + patchKconfig; inherit (kernel) src patches preUnpack; + # TODO replace with config.nix buildPhase buildPhase = '' cd $buildRoot @@ -99,7 +127,4 @@ installPhase = "mv .config $out"; enableParallelBuilding = true; - }; - } - diff --git a/pkgs/os-specific/linux/kernel/generate-config.pl b/pkgs/os-specific/linux/kernel/generate-config.pl index 5bce3af94293a..da62520cbcd8f 100644 --- a/pkgs/os-specific/linux/kernel/generate-config.pl +++ b/pkgs/os-specific/linux/kernel/generate-config.pl @@ -15,10 +15,12 @@ my $wd = getcwd; +# exported via nix my $debug = $ENV{'DEBUG'}; my $autoModules = $ENV{'AUTO_MODULES'}; my $preferBuiltin = $ENV{'PREFER_BUILTIN'}; - +my $ignoreConfigErrors = $ENV{'ignoreConfigErrors'}; + $SIG{PIPE} = 'IGNORE'; # Read the answers. @@ -137,7 +139,7 @@ sub runConfig { close CONFIG; foreach my $name (sort (keys %answers)) { - my $f = $requiredAnswers{$name} && $ENV{'ignoreConfigErrors'} ne "1" + my $f = $requiredAnswers{$name} && $ignoreConfigErrors ne "1" ? sub { die "error: " . $_[0]; } : sub { warn "warning: " . $_[0]; }; &$f("unused option: $name\n") unless defined $config{$name}; &$f("option not set correctly: $name (wanted '$answers{$name}', got '$config{$name}')\n") diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 858c77557207a..5a3b782267517 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -6,6 +6,10 @@ , # The kernel version. version +, # path to a .config file (or its content ?) + # if it s null we generate it + configfilename ? null + , # Appended verbatim to kernel .config extraConfig ? "" @@ -26,8 +30,9 @@ , ignoreConfigErrors ? stdenv.platform.name != "pc" , extraMeta ? {} , hostPlatform +, callPackage , ... -}: +} @ args: assert stdenv.isLinux; @@ -51,20 +56,35 @@ let config = configWithPlatform stdenv.platform; configCross = configWithPlatform hostPlatform.platform; + configDrv = callPackage ./config.nix { + inherit ignoreConfigErrors; + + inherit version src kernelPatches stdenv; + # modDirVersion + }; # TODO moved it # callPackage ./config.nix {}; # configfile = stdenv.mkDerivation { - configfile = (import ./config.nix); + # configfile = (import ./config.nix); # TODO le transformer plutot en kernel = buildLinux { + # TODO args inherit version modDirVersion src kernelPatches stdenv; + # inherit ignoreConfigErrors; + inherit configDrv; + + # configfile = configfile.nativeDrv or configfile; + # configfile = configfile.nativeDrv or configfile; + + # this is really configfilename + # configfile = if configfilename then configfilename else (callPackage ./config.nix {}); + configfile = null; - configfile = configfile.nativeDrv or configfile; - # configfile = null; - crossConfigfile = configfile.crossDrv or configfile; + # TODO fix later + # crossConfigfile = configfile.crossDrv or configfile; config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; diff --git a/pkgs/os-specific/linux/kernel/lib.nix b/pkgs/os-specific/linux/kernel/lib.nix new file mode 100644 index 0000000000000..23918a47f47ce --- /dev/null +++ b/pkgs/os-specific/linux/kernel/lib.nix @@ -0,0 +1,63 @@ +# this should be +# +{ + stdenv +, lib +# , buildRoot +# , srcRoot +# , ignoreConfigErrors: version, kernelConfig, runCommand +, version +, runCommand +}: +rec { + # runCommand = name: env: buildCommand: + /* generate a file config.nix with { + key=val; + } + from a kernel .config file passed as "configfile" + key#CONFIG_ removes "CONFIG_" prefix + */ + readConfig = configfile: import (runCommand "config.nix" {} '' + echo "{" > "$out" + while IFS='=' read key val; do + [ "x''${key#CONFIG_}" != "x$key" ] || continue + no_firstquote="''${val#\"}"; + echo ' "'"$key"'" = "'"''${no_firstquote%\"}"'";' >> "$out" + done < "${configfile}" + echo "}" >> $out + '').outPath; + + # RENAME to 'load' + convertKernelConfigToJson = readConfig; + + patchKconfig = '' + # Patch kconfig to print "###" after every question so that + # generate-config.pl from the generic builder can answer them. + sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c + ''; + + # generates functor + # + kernelConfigFun = baseConfig: kernelPatches: + let + configFromPatches = + map ({extraConfig ? "", ...}: extraConfig) kernelPatches; + in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); + + # TODO check bash variables exist -u + buildKernelConfig = arch: autoModules: '' + # cd $buildRoot + + # Get a basic config file for later refinement with $generateConfig. + # make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch + make -C .. 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 \ + PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig + ''; +} + + diff --git a/pkgs/os-specific/linux/kernel/linux-mptcp.nix b/pkgs/os-specific/linux/kernel/linux-mptcp.nix index 5c4266b6a72ca..d5d7d59748dc3 100644 --- a/pkgs/os-specific/linux/kernel/linux-mptcp.nix +++ b/pkgs/os-specific/linux/kernel/linux-mptcp.nix @@ -1,4 +1,4 @@ -{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: +{ stdenv, callPackage, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args: # ~ linux_mptcp = callPackage generic.nix (linux_mptcp.nix) import ./generic.nix (rec { @@ -44,4 +44,4 @@ import ./generic.nix (rec { TCP_CONG_BALIA m '' + (args.extraConfig or ""); -} // args // (args.argsOverride or {})) +} // removeAttrs args ["extraConfig"]) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 1cf14b50b8e55..7f80664bcfc7e 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,23 +1,24 @@ -# defines buildLinux +# defines buildLinux, aka returns a function { runCommand, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl , libelf ? null , utillinux ? null , writeTextFile, ubootTools +callPackage , hostPlatform }: let # TODO import from config - readConfig = configfile: import (runCommand "config.nix" {} '' - echo "{" > "$out" - while IFS='=' read key val; do - [ "x''${key#CONFIG_}" != "x$key" ] || continue - no_firstquote="''${val#\"}"; - echo ' "'"$key"'" = "'"''${no_firstquote%\"}"'";' >> "$out" - done < "${configfile}" - echo "}" >> $out - '').outPath; - confHelpers = import ./config.nix; + # readConfig = configfile: import (runCommand "config.nix" {} '' + # echo "{" > "$out" + # while IFS='=' read key val; do + # [ "x''${key#CONFIG_}" != "x$key" ] || continue + # no_firstquote="''${val#\"}"; + # echo ' "'"$key"'" = "'"''${no_firstquote%\"}"'";' >> "$out" + # done < "${configfile}" + # echo "}" >> $out + # '').outPath; + confHelpers = callPackage ./config.nix {}; in { # Allow overriding stdenv on each buildLinux call stdenv, @@ -33,16 +34,20 @@ in { nativeKernelPatches ? [], # Patches for cross compiling only crossKernelPatches ? [], + # ignoreConfigErrors, + # NEW pass a set with config inside + configDrv, # The native kernel .config file + # TODO if null, generate it from readFile configDrv configfile, # The cross kernel .config file crossConfigfile ? configfile, # Manually specified nixexpr representing the config # If unspecified, this will be autodetected from the .config - config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), + config ? stdenv.lib.optionalAttrs allowImportFromDerivation (confHelpers.readConfig configfile), # config ? null, # Cross-compiling config - crossConfig ? if allowImportFromDerivation then (readConfig crossConfigfile) else config, + crossConfig ? if allowImportFromDerivation then (confHelpers.readConfig crossConfigfile) else config, # Whether to utilize the controversial import-from-derivation feature to parse the config allowImportFromDerivation ? false }: @@ -95,6 +100,9 @@ let inherit src; + # to help debug + # inherit config crossConfig; + # why this preUnpack = '' # mkdir build @@ -115,13 +123,24 @@ let sed -i Makefile -e 's|= depmod|= ${kmod}/bin/depmod|' '' # if no configfile set then it means we have to generate it on the go - + stdenv.lib.optionalString (configfile == null) confHelpers.patchKconfig; + # configfile == null + # configfile.patchKconfig + # + stdenv.lib.optionalString (true) confHelpers.patchKconfig; + + stdenv.lib.optionalString (true) configDrv.patchKconfig; # imported from generic.nix # preConfigure = buildConfigPhase; - configurePhase = '' + configurePhase = let + + # if configfile is valid file + linkConfig = if (true) then ''ln -sv ${configfile} $buildRoot/.config + '' else '' + # TODO generate CONFIG !!! + ''; + + in '' # if [ -z "$buildRoot" ]; then # we should be in $sourceRoot @@ -132,6 +151,13 @@ let export buildRoot="$PWD/build" # fi runHook preConfigure + '' + + + linkConfig + + + '' + + # ln -sv ${configfile} $buildRoot/.config # reads the existing .config file and prompts the user for options in # the current kernel source that are not found in the file. From 452d9ecd97d29d071e1e27b0b5ebd650413d9f2e Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 27 Nov 2017 21:22:37 +0900 Subject: [PATCH 09/17] Wouldn't it be simpler to: - merge config/kernel and have a stopAtConfig boolean ? - override src of config ? - have 2 different configs ? embedded/inplace --- pkgs/os-specific/linux/kernel/config.nix | 17 ++++++++++++----- pkgs/os-specific/linux/kernel/manual-config.nix | 14 ++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index 28f7a91f82428..63a827fcd67d7 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -29,6 +29,9 @@ kernel_config kernel-config is a file TODO doesn t need to be a derviation ? +can 't we justr override the source or split into two derivations: +- standalone +- embedded */ let @@ -111,20 +114,24 @@ stdenv.mkDerivation { inherit (kernel) src patches preUnpack; # TODO replace with config.nix buildPhase - buildPhase = '' - cd $buildRoot + buildPhase = buildConfigCommands; + buildConfigCommands = '' + # cd $buildRoot + set -x # Get a basic config file for later refinement with $generateConfig. - make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch + make O=$buildRoot $kernelBaseConfig ARCH=$arch + # make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch # Create the config file. echo "generating kernel configuration..." echo "$kernelConfig" > kernel-config + # TODO SRC ? DEBUG=1 ARCH=$arch KERNEL_CONFIG=kernel-config AUTO_MODULES=$autoModules \ - PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig + PREFER_BUILTIN=$preferBuiltin SRC=. perl -w $generateConfig ''; - installPhase = "mv .config $out"; + installPhase = "mv $buildRoot/.config $out"; enableParallelBuilding = true; } diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 7f80664bcfc7e..176de797ddf7a 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -132,13 +132,19 @@ let # preConfigure = buildConfigPhase; + + # we are in $sourceRoot configurePhase = let # if configfile is valid file - linkConfig = if (true) then ''ln -sv ${configfile} $buildRoot/.config - '' else '' - # TODO generate CONFIG !!! - ''; + linkConfig = if (configfile) then '' + ln -sv ${configfile} $buildRoot/.config + '' else + configDrv.buildConfigCommands + # '' + # # TODO generate CONFIG !!! + # '' + ; in '' # if [ -z "$buildRoot" ]; then From 338fc229903b567b92b86ba79af1ac1fb27c4fe3 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 28 Nov 2017 01:18:06 +0900 Subject: [PATCH 10/17] wip' --- pkgs/os-specific/linux/kernel/config.nix | 25 +++++++++++++------ pkgs/os-specific/linux/kernel/generic.nix | 4 ++- .../linux/kernel/manual-config.nix | 4 +-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index 63a827fcd67d7..13c2f80871962 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -1,16 +1,20 @@ { stdenv , lib +# , config # , buildRoot # , srcRoot , ignoreConfigErrors, version # , kernelConfig +, config, configCross ?null +, kernelPatches , runCommand +, kernel , perl, hostPlatform , ... }: -with import lib.nix; +# with import lib.nix; /* # TODO we should be able to generate standalone config and config on the go @@ -62,16 +66,19 @@ let map ({extraConfig ? "", ...}: extraConfig) kernelPatches; in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); in -stdenv.mkDerivation { +stdenv.mkDerivation rec { inherit ignoreConfigErrors; name = "linux-config-${version}"; + + # Runs generate-config + # my $pid = open2(\*IN, \*OUT, "make -C $ENV{SRC} O=$wd config SHELL=bash ARCH=$ENV{ARCH}"); generateConfig = ./generate-config.pl; # string that will be echoed to kernel-config file # writeFile # echo "$kernelConfig" > kernel-config - kernelConfig = kernelConfigFun config kernel-patches; + kernelConfig = kernelConfigFun config kernelPatches; nativeBuildInputs = [ perl ]; @@ -111,24 +118,28 @@ stdenv.mkDerivation { ''; prePatch = kernel.prePatch + patchKconfig; + # inherit (kernel) src patches preUnpack; inherit (kernel) src patches preUnpack; # TODO replace with config.nix buildPhase + # add a cd ? buildPhase = buildConfigCommands; + + # need to be in srcRoot before launching this ! buildConfigCommands = '' - # cd $buildRoot + cd $buildRoot set -x # Get a basic config file for later refinement with $generateConfig. - make O=$buildRoot $kernelBaseConfig ARCH=$arch - # make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch + # make O=$buildRoot $kernelBaseConfig ARCH=$arch + make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch # Create the config file. echo "generating kernel configuration..." echo "$kernelConfig" > kernel-config # TODO SRC ? DEBUG=1 ARCH=$arch KERNEL_CONFIG=kernel-config AUTO_MODULES=$autoModules \ - PREFER_BUILTIN=$preferBuiltin SRC=. perl -w $generateConfig + PREFER_BUILTIN=$preferBuiltin SRC=. perl -w ${generateConfig} ''; installPhase = "mv $buildRoot/.config $out"; diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 5a3b782267517..40db581676f97 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -59,8 +59,9 @@ let configDrv = callPackage ./config.nix { inherit ignoreConfigErrors; - inherit version src kernelPatches stdenv; + inherit version src kernelPatches stdenv config; # modDirVersion + inherit kernel; }; # TODO moved it @@ -86,6 +87,7 @@ let # TODO fix later # crossConfigfile = configfile.crossDrv or configfile; + # erase parent config ???! config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; crossConfig = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 176de797ddf7a..63e40db3d1de3 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -137,9 +137,10 @@ let configurePhase = let # if configfile is valid file - linkConfig = if (configfile) then '' + linkConfig = if (configfile != null) then '' ln -sv ${configfile} $buildRoot/.config '' else + # TODO la le kernel config n est pas genere configDrv.buildConfigCommands # '' # # TODO generate CONFIG !!! @@ -163,7 +164,6 @@ let + '' - # ln -sv ${configfile} $buildRoot/.config # reads the existing .config file and prompts the user for options in # the current kernel source that are not found in the file. From 56886ab2991a5d44138e055aa63aa24a1f66cd4d Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 30 Nov 2017 05:10:41 +0900 Subject: [PATCH 11/17] use absolute paths in builder fixed perl script. this works in nix-shell but now fails with nix-build, aka nixops fails . --- pkgs/os-specific/linux/kernel/config.nix | 10 ++++++---- pkgs/os-specific/linux/kernel/generate-config.pl | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index 13c2f80871962..43358bb845737 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -114,6 +114,7 @@ stdenv.mkDerivation rec { patchKconfig = '' # Patch kconfig to print "###" after every question so that # generate-config.pl from the generic builder can answer them. + echo "Patching Kconfig" sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c ''; @@ -132,14 +133,15 @@ stdenv.mkDerivation rec { # Get a basic config file for later refinement with $generateConfig. # make O=$buildRoot $kernelBaseConfig ARCH=$arch - make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch + make -C ../$sourceRoot O=$buildRoot $kernelBaseConfig ARCH=$arch # Create the config file. echo "generating kernel configuration..." - echo "$kernelConfig" > kernel-config + echo "${kernelConfig}" > $buildRoot/kernel-config + echo "Printing kernel config" # TODO SRC ? - DEBUG=1 ARCH=$arch KERNEL_CONFIG=kernel-config AUTO_MODULES=$autoModules \ - PREFER_BUILTIN=$preferBuiltin SRC=. perl -w ${generateConfig} + DEBUG=1 ARCH=$arch KERNEL_CONFIG=$buildRoot/kernel-config AUTO_MODULES=$autoModules \ + PREFER_BUILTIN=$preferBuiltin SRC=. BUILD_FOLDER=$buildRoot perl -w ${generateConfig} ''; installPhase = "mv $buildRoot/.config $out"; diff --git a/pkgs/os-specific/linux/kernel/generate-config.pl b/pkgs/os-specific/linux/kernel/generate-config.pl index da62520cbcd8f..ba272eefeac1e 100644 --- a/pkgs/os-specific/linux/kernel/generate-config.pl +++ b/pkgs/os-specific/linux/kernel/generate-config.pl @@ -13,20 +13,22 @@ use IPC::Open2; use Cwd; -my $wd = getcwd; +# my $wd = getcwd; # exported via nix my $debug = $ENV{'DEBUG'}; my $autoModules = $ENV{'AUTO_MODULES'}; my $preferBuiltin = $ENV{'PREFER_BUILTIN'}; my $ignoreConfigErrors = $ENV{'ignoreConfigErrors'}; +my $buildFolder=$ENV{'BUILD_FOLDER'}; +my $finalConfig="$buildFolder/.config"; $SIG{PIPE} = 'IGNORE'; # Read the answers. my %answers; my %requiredAnswers; -open ANSWERS, "<$ENV{KERNEL_CONFIG}" or die; +open ANSWERS, "<$ENV{KERNEL_CONFIG}" or die "Could not open answer file"; while () { chomp; s/#.*//; @@ -42,7 +44,7 @@ sub runConfig { # Run `make config'. - my $pid = open2(\*IN, \*OUT, "make -C $ENV{SRC} O=$wd config SHELL=bash ARCH=$ENV{ARCH}"); + my $pid = open2(\*IN, \*OUT, "make -C $ENV{SRC} O=$buildFolder config SHELL=bash ARCH=$ENV{ARCH}"); # Parse the output, look for questions and then send an # appropriate answer. @@ -124,7 +126,7 @@ sub runConfig { # there. `make config' often overrides answers if later questions # cause options to be selected. my %config; -open CONFIG, "<.config" or die; +open CONFIG, "<$finalConfig" or die "Could not read .config"; while () { chomp; if (/^CONFIG_([A-Za-z0-9_]+)="(.*)"$/) { From 70f08d0bdc72ae61be75237ce45381ce13993de8 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 30 Nov 2017 20:44:24 +0900 Subject: [PATCH 12/17] fixed callPacakge ? --- pkgs/os-specific/linux/kernel/builder.sh | 8 ++++++++ pkgs/os-specific/linux/kernel/config.nix | 6 ++++-- pkgs/os-specific/linux/kernel/generic.nix | 4 ++-- pkgs/os-specific/linux/kernel/manual-config.nix | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 pkgs/os-specific/linux/kernel/builder.sh diff --git a/pkgs/os-specific/linux/kernel/builder.sh b/pkgs/os-specific/linux/kernel/builder.sh new file mode 100644 index 0000000000000..44baff1f7dfd3 --- /dev/null +++ b/pkgs/os-specific/linux/kernel/builder.sh @@ -0,0 +1,8 @@ +# TODO testing if that's better +source $stdenv/setup + +# that s how cmake replaces +# if [ -z "$dontUseCmakeConfigure" -a -z "$configurePhase" ]; then +# setOutputFlags= +# configurePhase=cmakeConfigurePhase +# fi diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index 43358bb845737..cf579f7802f2f 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -128,12 +128,14 @@ stdenv.mkDerivation rec { # need to be in srcRoot before launching this ! buildConfigCommands = '' - cd $buildRoot set -x + echo $PWD + cd $buildRoot # Get a basic config file for later refinement with $generateConfig. # make O=$buildRoot $kernelBaseConfig ARCH=$arch - make -C ../$sourceRoot O=$buildRoot $kernelBaseConfig ARCH=$arch + # /$sourceRoot + make -C .. O=$buildRoot $kernelBaseConfig ARCH=$arch # Create the config file. echo "generating kernel configuration..." diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 40db581676f97..cf9d6571564dd 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -30,7 +30,7 @@ , ignoreConfigErrors ? stdenv.platform.name != "pc" , extraMeta ? {} , hostPlatform -, callPackage +# , callPackage , ... } @ args: @@ -56,7 +56,7 @@ let config = configWithPlatform stdenv.platform; configCross = configWithPlatform hostPlatform.platform; - configDrv = callPackage ./config.nix { + configDrv = stdenv.lib.callPackage ./config.nix { inherit ignoreConfigErrors; inherit version src kernelPatches stdenv config; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 63e40db3d1de3..3433dc6c0a1d9 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -153,9 +153,9 @@ let # we should be in $sourceRoot # assume we are in the $sourceRoot folder # echo "buildRoot is not set" - echo "buildRoot is not set" mkdir build export buildRoot="$PWD/build" + echo "buildRoot was not set, now is $buildRoot" # fi runHook preConfigure '' From dda2528f76d9d9df0d1d9a3e8a5ca34e2d47023d Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Fri, 1 Dec 2017 00:36:54 +0900 Subject: [PATCH 13/17] Kinda works but ignores the custom platform because it is to be used for crossplatform comiplation only --- pkgs/os-specific/linux/kernel/config.nix | 6 ++++-- pkgs/os-specific/linux/kernel/generic.nix | 5 +++-- pkgs/os-specific/linux/kernel/manual-config.nix | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index cf579f7802f2f..e5dc9460aa3f9 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -132,7 +132,7 @@ stdenv.mkDerivation rec { echo $PWD cd $buildRoot - # Get a basic config file for later refinement with $generateConfig. + # Get a basic config file for later refinement with $ generateConfig. # make O=$buildRoot $kernelBaseConfig ARCH=$arch # /$sourceRoot make -C .. O=$buildRoot $kernelBaseConfig ARCH=$arch @@ -142,7 +142,9 @@ stdenv.mkDerivation rec { echo "${kernelConfig}" > $buildRoot/kernel-config echo "Printing kernel config" # TODO SRC ? - DEBUG=1 ARCH=$arch KERNEL_CONFIG=$buildRoot/kernel-config AUTO_MODULES=$autoModules \ + DEBUG=1 ARCH=$arch KERNEL_CONFIG=$buildRoot/kernel-config \ + AUTO_MODULES=${builtins.toString autoModules} \ + ignoreConfigErrors=${builtins.toString ignoreConfigErrors} \ PREFER_BUILTIN=$preferBuiltin SRC=. BUILD_FOLDER=$buildRoot perl -w ${generateConfig} ''; diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index cf9d6571564dd..05672caf96d18 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -30,7 +30,8 @@ , ignoreConfigErrors ? stdenv.platform.name != "pc" , extraMeta ? {} , hostPlatform -# , callPackage +, callPackage +# , pkgs , ... } @ args: @@ -56,7 +57,7 @@ let config = configWithPlatform stdenv.platform; configCross = configWithPlatform hostPlatform.platform; - configDrv = stdenv.lib.callPackage ./config.nix { + configDrv = callPackage ./config.nix { inherit ignoreConfigErrors; inherit version src kernelPatches stdenv config; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 3433dc6c0a1d9..269e9117f654b 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -1,9 +1,9 @@ # defines buildLinux, aka returns a function -{ runCommand, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl +{ runCommand, stdenv, nettools, bc, perl, gmp, libmpc, mpfr, kmod, openssl , libelf ? null , utillinux ? null , writeTextFile, ubootTools -callPackage +# , callPackage , hostPlatform }: @@ -18,7 +18,7 @@ let # done < "${configfile}" # echo "}" >> $out # '').outPath; - confHelpers = callPackage ./config.nix {}; + confHelpers = stdenv.lib.callPackage ./config.nix {}; in { # Allow overriding stdenv on each buildLinux call stdenv, @@ -215,7 +215,7 @@ let unlink $out/lib/modules/${modDirVersion}/source mkdir -p $dev/lib/modules/${modDirVersion}/build - cp -dpR ../$sourceRoot $dev/lib/modules/${modDirVersion}/source + cp -dpR .. $dev/lib/modules/${modDirVersion}/source cd $dev/lib/modules/${modDirVersion}/source cp $buildRoot/{.config,Module.symvers} $dev/lib/modules/${modDirVersion}/build @@ -321,7 +321,7 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe "ARCH=${stdenv.platform.kernelArch}" ] # {cfg.buildCores} - ++ stdenv.lib.optional enableParallelBuilding "-j4" + # ++ stdenv.lib.optional enableParallelBuilding "-j4" # cfg.buildCores # TODO set ; From 7e5673d04d2519bd1cbcd279971a0ba0c8520358 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Fri, 1 Dec 2017 03:25:37 +0900 Subject: [PATCH 14/17] adding VIRTIO_PCI for nixops --- pkgs/os-specific/linux/kernel/config.nix | 3 ++- pkgs/os-specific/linux/kernel/linux-4.9.nix | 12 +++++++++++- pkgs/os-specific/linux/kernel/manual-config.nix | 5 ++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/config.nix b/pkgs/os-specific/linux/kernel/config.nix index e5dc9460aa3f9..dd7ec4d162323 100644 --- a/pkgs/os-specific/linux/kernel/config.nix +++ b/pkgs/os-specific/linux/kernel/config.nix @@ -89,7 +89,8 @@ stdenv.mkDerivation rec { # e.g. "bzImage" kernelTarget = stdenv.platform.kernelTarget; - autoModules = stdenv.platform.kernelAutoModules; + # HHHAAAACCKKK + autoModules = false; # stdenv.platform.kernelAutoModules; preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; # kernel ARCH arch = stdenv.platform.kernelArch; diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix index 3e3626cb39d4b..7b57056383bb8 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.9.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix @@ -1,9 +1,19 @@ -{ stdenv, hostPlatform, fetchurl, perl, buildLinux, ... } @ args: +{ stdenv, hostPlatform, fetchurl, perl, buildLinux, callPackage, ... } @ args: import ./generic.nix (args // rec { version = "4.9.65"; extraMeta.branch = "4.9"; + ignoreConfigErrors = true; + + extraConfig='' + VIRTIO_PCI y + VIRTIO_PCI_LEGACY y + VIRTIO_BALLOON m + VIRTIO_INPUT m + VIRTIO_MMIO m + ''; + src = fetchurl { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; sha256 = "15a8a7p6i2dgiglps22cwsy5gsfkc39fy4jzvhjwz8s9fn3p1fi4"; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 269e9117f654b..a0d21ab5cdb91 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -105,10 +105,9 @@ let # why this preUnpack = '' - # mkdir build - # export buildRoot="$PWD/build" ''; - autoModules = stdenv.platform.kernelAutoModules; + # HAAAACCKKKKK + autoModules = false; # stdenv.platform.kernelAutoModules; preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; arch = stdenv.platform.kernelArch; kernelBaseConfig = stdenv.platform.kernelBaseConfig; From 17f41a1ab128daef96896058dfa65b842cac0914 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 2 Dec 2017 04:21:25 +0900 Subject: [PATCH 15/17] hostPlatform is not what I expected it is a set that contains a platform entity --- pkgs/os-specific/linux/kernel/generic.nix | 5 +++-- pkgs/os-specific/linux/kernel/linux-4.9.nix | 4 +--- .../linux/kernel/manual-config.nix | 22 +++++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 05672caf96d18..f0e7db77ae055 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -54,8 +54,9 @@ let features = kernelFeatures; # Ensure we know of all extra patches, etc. }; - config = configWithPlatform stdenv.platform; - configCross = configWithPlatform hostPlatform.platform; + # CARE I modified the line below + config = configWithPlatform hostPlatform; + configCross = configWithPlatform hostPlatform; configDrv = callPackage ./config.nix { inherit ignoreConfigErrors; diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix index 7b57056383bb8..15d64ad0db1b1 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.9.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix @@ -1,11 +1,9 @@ -{ stdenv, hostPlatform, fetchurl, perl, buildLinux, callPackage, ... } @ args: +{ stdenv, hostPlatform, ignoreConfigErrors ? true, fetchurl, perl, buildLinux, callPackage, ... } @ args: import ./generic.nix (args // rec { version = "4.9.65"; extraMeta.branch = "4.9"; - ignoreConfigErrors = true; - extraConfig='' VIRTIO_PCI y VIRTIO_PCI_LEGACY y diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index a0d21ab5cdb91..5c5592e0e46c7 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -4,6 +4,8 @@ , utillinux ? null , writeTextFile, ubootTools # , callPackage + +# in fact this should be a set like https://github.com/NixOS/nixpkgs/issues/24388 , hostPlatform }: @@ -56,6 +58,8 @@ let inherit (stdenv.lib) hasAttr getAttr optional optionalString optionalAttrs maintainers platforms; + platform = hostPlatform; + installkernel = writeTextFile { name = "installkernel"; executable=true; text = '' #!${stdenv.shell} -e mkdir -p $4 @@ -68,7 +72,7 @@ let "O=$(buildRoot)" ] ++ stdenv.lib.optionals (stdenv.platform ? kernelMakeFlags) - stdenv.platform.kernelMakeFlags; + platform.kernelMakeFlags; drvAttrs = config_: platform: kernelPatches: configfile: let @@ -107,10 +111,10 @@ let preUnpack = '' ''; # HAAAACCKKKKK - autoModules = false; # stdenv.platform.kernelAutoModules; - preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; - arch = stdenv.platform.kernelArch; - kernelBaseConfig = stdenv.platform.kernelBaseConfig; + autoModules = platform.kernelAutoModules; + preferBuiltin = platform.kernelPreferBuiltin or false; + arch = platform.kernelArch; + kernelBaseConfig = platform.kernelBaseConfig; patches = map (p: p.patch) kernelPatches; @@ -296,7 +300,7 @@ in assert stdenv.lib.versionAtLeast version "4.15" -> libelf != null; assert stdenv.lib.versionAtLeast version "4.15" -> utillinux != null; -stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKernelPatches) configfile) // { +stdenv.mkDerivation ((drvAttrs config platform (kernelPatches ++ nativeKernelPatches) configfile) // { # config ? stdenv.lib.optionalAttrs allowImportFromDerivation (readConfig configfile), # stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKernelPatches) configfile) // rec { name = "linux-${version}"; @@ -304,7 +308,7 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe enableParallelBuilding = true; nativeBuildInputs = [ perl bc nettools openssl gmp libmpc mpfr ] - ++ optional (stdenv.platform.kernelTarget == "uImage") ubootTools + ++ optional (platform.kernelTarget == "uImage") ubootTools ++ optional (stdenv.lib.versionAtLeast version "4.15") libelf ++ optional (stdenv.lib.versionAtLeast version "4.15") utillinux ; @@ -317,14 +321,14 @@ stdenv.mkDerivation ((drvAttrs config stdenv.platform (kernelPatches ++ nativeKe # TODO add an output for the config ? makeFlags = commonMakeFlags ++ [ - "ARCH=${stdenv.platform.kernelArch}" + "ARCH=${platform.kernelArch}" ] # {cfg.buildCores} # ++ stdenv.lib.optional enableParallelBuilding "-j4" # cfg.buildCores # TODO set ; - karch = stdenv.platform.kernelArch; + karch = platform.kernelArch; crossAttrs = let cp = hostPlatform.platform; in (drvAttrs crossConfig cp (kernelPatches ++ crossKernelPatches) crossConfigfile) // { From ad522f169f4c392b8f2d356b96012b5b155afff2 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 3 Dec 2017 11:34:38 +0900 Subject: [PATCH 16/17] wip --- pkgs/os-specific/linux/kernel/manual-config.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index 5c5592e0e46c7..ee037cfeeb04b 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -5,7 +5,9 @@ , writeTextFile, ubootTools # , callPackage -# in fact this should be a set like https://github.com/NixOS/nixpkgs/issues/24388 +# in fact this refers to a system (see lib/systems/examples.nix) and not a "platform" +# since this sometimes call +# should be a set like https://github.com/NixOS/nixpkgs/issues/24388 , hostPlatform }: From 8a2a39f0ca2a29459926cd24766b352d113d566d Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 4 Dec 2017 20:29:49 +0900 Subject: [PATCH 17/17] reverted some platform changes --- pkgs/os-specific/linux/kernel/generic.nix | 5 ++--- pkgs/os-specific/linux/kernel/manual-config.nix | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index f0e7db77ae055..05672caf96d18 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -54,9 +54,8 @@ let features = kernelFeatures; # Ensure we know of all extra patches, etc. }; - # CARE I modified the line below - config = configWithPlatform hostPlatform; - configCross = configWithPlatform hostPlatform; + config = configWithPlatform stdenv.platform; + configCross = configWithPlatform hostPlatform.platform; configDrv = callPackage ./config.nix { inherit ignoreConfigErrors; diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix index ee037cfeeb04b..3cbc554b52299 100644 --- a/pkgs/os-specific/linux/kernel/manual-config.nix +++ b/pkgs/os-specific/linux/kernel/manual-config.nix @@ -60,7 +60,7 @@ let inherit (stdenv.lib) hasAttr getAttr optional optionalString optionalAttrs maintainers platforms; - platform = hostPlatform; + platform = stdenv.platform; installkernel = writeTextFile { name = "installkernel"; executable=true; text = '' #!${stdenv.shell} -e