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