kernel 4.14 require libelf to compile modules.

[...]
make modules -C /nix/store/h1vzl6bq4wif3m8dd1bw2p3fv4shjg3n-linux-4.14.9-dev/lib/modules/4.14.9/build EXTRA_CFLAGS=-Werror-implicit-function-declaration M=/tmp/nix-build-spl-kernel-2017-11-16-4.14.9.drv-0/source/build
/nix/store/h1vzl6bq4wif3m8dd1bw2p3fv4shjg3n-linux-4.14.9-dev/lib/modules/4.14.9/source/Makefile:939: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.

This patch introduces kernel.moduleBuildDependencies to avoid the logic "stdenv.lib.optional (stdenv.lib.versionAtLeast kernel.version "4.14") libelf" in multiple places.

[dezgeg did some minor tweaks on top]

authored by David Guibert and committed by Tuomas Tynkkynen 1e77d0b9 77cc6395

+13 -5
+1 -1
pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
··· 36 37 NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration"; 38 39 - buildInputs = [ patchelf cdrkit makeWrapper dbus ]; 40 41 installPhase = '' 42 mkdir -p $out
··· 36 37 NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration"; 38 39 + buildInputs = [ patchelf cdrkit makeWrapper dbus ] ++ kernel.moduleBuildDependencies; 40 41 installPhase = '' 42 mkdir -p $out
+4 -1
pkgs/os-specific/linux/kernel/manual-config.nix
··· 49 inherit (stdenv.lib) 50 hasAttr getAttr optional optionalString optionalAttrs maintainers platforms; 51 52 installkernel = writeTextFile { name = "installkernel"; executable=true; text = '' 53 #!${stdenv.shell} -e 54 mkdir -p $4 ··· 85 (isModular || (config.isDisabled "FIRMWARE_IN_KERNEL")); 86 in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // { 87 passthru = { 88 - inherit version modDirVersion config kernelPatches configfile; 89 }; 90 91 inherit src;
··· 49 inherit (stdenv.lib) 50 hasAttr getAttr optional optionalString optionalAttrs maintainers platforms; 51 52 + # Dependencies that are required to build kernel modules 53 + moduleBuildDependencies = stdenv.lib.optional (stdenv.lib.versionAtLeast version "4.14") libelf; 54 + 55 installkernel = writeTextFile { name = "installkernel"; executable=true; text = '' 56 #!${stdenv.shell} -e 57 mkdir -p $4 ··· 88 (isModular || (config.isDisabled "FIRMWARE_IN_KERNEL")); 89 in (optionalAttrs isModular { outputs = [ "out" "dev" ]; }) // { 90 passthru = { 91 + inherit version modDirVersion config kernelPatches configfile moduleBuildDependencies; 92 }; 93 94 inherit src;
+1 -1
pkgs/os-specific/linux/spl/default.nix
··· 25 26 patches = [ ./const.patch ./install_prefix.patch ]; 27 28 - nativeBuildInputs = [ autoreconfHook ]; 29 30 hardeningDisable = [ "pic" ]; 31
··· 25 26 patches = [ ./const.patch ./install_prefix.patch ]; 27 28 + nativeBuildInputs = [ autoreconfHook ] ++ optional (kernel != null) kernel.moduleBuildDependencies; 29 30 hardeningDisable = [ "pic" ]; 31
+1 -1
pkgs/os-specific/linux/sysdig/default.nix
··· 14 15 buildInputs = [ 16 cmake zlib luajit ncurses perl jsoncpp libb64 openssl curl jq gcc 17 - ]; 18 19 hardeningDisable = [ "pic" ]; 20
··· 14 15 buildInputs = [ 16 cmake zlib luajit ncurses perl jsoncpp libb64 openssl curl jq gcc 17 + ] ++ optional (kernel != null) kernel.moduleBuildDependencies; 18 19 hardeningDisable = [ "pic" ]; 20
+2
pkgs/os-specific/linux/tp_smapi/default.nix
··· 13 name = "tp-smapi-${version}"; 14 }; 15 16 hardeningDisable = [ "pic" ]; 17 18 makeFlags = [
··· 13 name = "tp-smapi-${version}"; 14 }; 15 16 + nativeBuildInputs = kernel.moduleBuildDependencies; 17 + 18 hardeningDisable = [ "pic" ]; 19 20 makeFlags = [
+2
pkgs/os-specific/linux/virtualbox/default.nix
··· 7 "fortify" "pic" "stackprotector" 8 ]; 9 10 patches = [ 11 ./fix_kerndir.patch 12 ./fix_kbuild.patch
··· 7 "fortify" "pic" "stackprotector" 8 ]; 9 10 + nativeBuildInputs = kernel.moduleBuildDependencies; 11 + 12 patches = [ 13 ./fix_kerndir.patch 14 ./fix_kbuild.patch
+2 -1
pkgs/os-specific/linux/zfs/default.nix
··· 38 39 patches = extraPatches; 40 41 - nativeBuildInputs = [ autoreconfHook nukeReferences ]; 42 buildInputs = 43 optionals buildKernel [ spl ] 44 ++ optionals buildUser [ zlib libuuid python attr ]
··· 38 39 patches = extraPatches; 40 41 + nativeBuildInputs = [ autoreconfHook nukeReferences ] 42 + ++ optional (kernel != null) kernel.moduleBuildDependencies; 43 buildInputs = 44 optionals buildKernel [ spl ] 45 ++ optionals buildUser [ zlib libuuid python attr ]