From a12606bef42e79184c18e89146df6319e4715884 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 01:20:49 -0700 Subject: [PATCH] linuxPackages.zfs: use the kernel's stdenv when possible --- pkgs/os-specific/linux/zfs/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix index 78cced512a48..a9f1f1c389b3 100644 --- a/pkgs/os-specific/linux/zfs/default.nix +++ b/pkgs/os-specific/linux/zfs/default.nix @@ -26,6 +26,14 @@ let buildKernel = any (n: n == configFile) [ "kernel" "all" ]; buildUser = any (n: n == configFile) [ "user" "all" ]; + # XXX: You always want to build kernel modules with the same stdenv as the + # kernel was built with. However, since zfs can also be built for userspace we + # need to correctly pick between the provided/default stdenv, and the one used + # by the kernel. + # If you don't do this your ZFS builds will fail on any non-standard (e.g. + # clang-built) kernels. + stdenv' = if kernel == null then stdenv else kernel.stdenv; + common = { version , sha256 , extraPatches ? [] @@ -34,7 +42,7 @@ let , latestCompatibleLinuxPackages , kernelCompatible ? null }: - stdenv.mkDerivation { + stdenv'.mkDerivation { name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}"; src = fetchFromGitHub {