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 {