about summary refs log tree commit diff
path: root/pkgs/os-specific
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2017-07-28 16:08:30 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-07-28 16:08:30 +0200
commitb116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed (patch)
treeff5748c1ec96643e47dcdeaa5def1aa950a913ce /pkgs/os-specific
parent9be40841ea4251a09ae7a1023abc1b6d191f61bb (diff)
parent20d2bfa4ff247a49f50fc0cf4d509fbd48723290 (diff)
downloadnixlib-b116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed.tar
nixlib-b116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed.tar.gz
nixlib-b116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed.tar.bz2
nixlib-b116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed.tar.lz
nixlib-b116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed.tar.xz
nixlib-b116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed.tar.zst
nixlib-b116fa5ff2a832b24ffbc3ed3fa703ca6bf904ed.zip
Merge branch 'master' into staging
Diffstat (limited to 'pkgs/os-specific')
-rw-r--r--pkgs/os-specific/linux/bbswitch/default.nix2
-rw-r--r--pkgs/os-specific/linux/exfat/default.nix9
-rw-r--r--pkgs/os-specific/linux/firejail/default.nix15
-rw-r--r--pkgs/os-specific/linux/keyutils/default.nix4
-rw-r--r--pkgs/os-specific/linux/mcelog/default.nix16
-rw-r--r--pkgs/os-specific/linux/spl/default.nix92
-rw-r--r--pkgs/os-specific/linux/sysdig/default.nix12
-rw-r--r--pkgs/os-specific/linux/zfs/default.nix248
8 files changed, 173 insertions, 225 deletions
diff --git a/pkgs/os-specific/linux/bbswitch/default.nix b/pkgs/os-specific/linux/bbswitch/default.nix
index 67b843fac4dc..4489a94f1ed5 100644
--- a/pkgs/os-specific/linux/bbswitch/default.nix
+++ b/pkgs/os-specific/linux/bbswitch/default.nix
@@ -49,7 +49,7 @@ stdenv.mkDerivation {
   meta = with stdenv.lib; {
     description = "A module for powering off hybrid GPUs";
     platforms = platforms.linux;
-    homepage = https://github.com/Bumblebee-Project/bbswitch;
+    homepage = "https://github.com/Bumblebee-Project/bbswitch";
     maintainers = with maintainers; [ abbradar ];
   };
 }
diff --git a/pkgs/os-specific/linux/exfat/default.nix b/pkgs/os-specific/linux/exfat/default.nix
index fa2939e947e5..ee6249ce0408 100644
--- a/pkgs/os-specific/linux/exfat/default.nix
+++ b/pkgs/os-specific/linux/exfat/default.nix
@@ -1,21 +1,18 @@
 { stdenv, lib, fetchFromGitHub, kernel }:
 
-# Upstream build for kernel > 4.10 is currently broken
-# Reference: https://github.com/dorimanx/exfat-nofuse/issues/103
-assert lib.versionOlder kernel.version "4.10";
 
 # Upstream build for kernel 4.1 is broken, 3.12 and below seems to be working
 assert lib.versionAtLeast kernel.version  "4.2" || lib.versionOlder kernel.version "4.0";
 
 stdenv.mkDerivation rec {
   name = "exfat-nofuse-${version}-${kernel.version}";
-  version = "2017-01-03";
+  version = "2017-06-19";
 
   src = fetchFromGitHub {
     owner = "dorimanx";
     repo = "exfat-nofuse";
-    rev = "8d291f5";
-    sha256 = "0lg1mykglayswli2aliw8chsbr4g629v9chki5975avh43jn47w9";
+    rev = "de4c760bc9a05ead83bc3ec6eec6cf1fb106f523";
+    sha256 = "0v979d8sbcb70lakm4jal2ck3gspkdgq9108k127f7ph08vf8djm";
   };
 
   hardeningDisable = [ "pic" ];
diff --git a/pkgs/os-specific/linux/firejail/default.nix b/pkgs/os-specific/linux/firejail/default.nix
index 1bbe8dbb160b..b20dcd34233e 100644
--- a/pkgs/os-specific/linux/firejail/default.nix
+++ b/pkgs/os-specific/linux/firejail/default.nix
@@ -3,11 +3,11 @@ let
   s = # Generated upstream information
   rec {
     baseName="firejail";
-    version="0.9.44.10";
+    version="0.9.48";
     name="${baseName}-${version}";
-    hash="19wln3h54wcscqgcmkm8sprdh7vrn5k91rr0hagv055y1i52c7mj";
-    url="https://netix.dl.sourceforge.net/project/firejail/firejail/firejail-0.9.44.10.tar.xz";
-    sha256="19wln3h54wcscqgcmkm8sprdh7vrn5k91rr0hagv055y1i52c7mj";
+    hash="02a74nx8p2gbpd6ffnr52p02pxxllw3yy5fy4083a77r3wia8zb3";
+    url="https://vorboss.dl.sourceforge.net/project/firejail/firejail/firejail-0.9.48.tar.xz";
+    sha256="02a74nx8p2gbpd6ffnr52p02pxxllw3yy5fy4083a77r3wia8zb3";
   };
   buildInputs = [
     which
@@ -21,6 +21,13 @@ stdenv.mkDerivation {
     name = "${s.name}.tar.bz2";
   };
 
+  prePatch = ''
+    # Allow whitelisting ~/.nix-profile
+    substituteInPlace etc/firejail.config --replace \
+      '# follow-symlink-as-user yes' \
+      'follow-symlink-as-user no'
+  '';
+
   preConfigure = ''
     sed -e 's@/bin/bash@${stdenv.shell}@g' -i $( grep -lr /bin/bash .)
     sed -e "s@/bin/cp@$(which cp)@g" -i $( grep -lr /bin/cp .)
diff --git a/pkgs/os-specific/linux/keyutils/default.nix b/pkgs/os-specific/linux/keyutils/default.nix
index 2aba3ef91128..c7915ace7ca3 100644
--- a/pkgs/os-specific/linux/keyutils/default.nix
+++ b/pkgs/os-specific/linux/keyutils/default.nix
@@ -2,11 +2,11 @@
 
 stdenv.mkDerivation rec {
   name = "keyutils-${version}";
-  version = "1.5.9";
+  version = "1.5.10";
 
   src = fetchurl {
     url = "http://people.redhat.com/dhowells/keyutils/${name}.tar.bz2";
-    sha256 = "1bl3w03ygxhc0hz69klfdlwqn33jvzxl1zfl2jmnb2v85iawb8jd";
+    sha256 = "1dmgjcf7mnwc6h72xkvpaqpzxw8vmlnsmzz0s27pg0giwzm3sp0i";
   };
 
   outputs = [ "out" "lib" "dev" ];
diff --git a/pkgs/os-specific/linux/mcelog/default.nix b/pkgs/os-specific/linux/mcelog/default.nix
index 64b937390f16..a7f5ffaae4a2 100644
--- a/pkgs/os-specific/linux/mcelog/default.nix
+++ b/pkgs/os-specific/linux/mcelog/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "mcelog-${version}";
-  version = "148";
+  version = "153";
 
   src = fetchFromGitHub {
-    sha256 = "04mzscvr38r2q9da9wmv3cxb99vrkxks1mzgvwsxk753xan3p42c";
-    rev = "v${version}";
-    repo = "mcelog";
-    owner = "andikleen";
+    owner  = "andikleen";
+    repo   = "mcelog";
+    rev    = "v${version}";
+    sha256 = "1wz55dzqdiam511d6p1958al6vzlhrhs73s7gly0mzm6kpji0gxa";
   };
 
   postPatch = ''
@@ -28,6 +28,12 @@ stdenv.mkDerivation rec {
 
   installFlags = [ "DESTDIR=$(out)" "prefix=" "DOCDIR=/share/doc" ];
 
+  postInstall = ''
+    mkdir -p $out/lib/systemd/system
+    substitute mcelog.service $out/lib/systemd/system/mcelog.service \
+      --replace /usr/sbin $out/bin
+  '';
+
   meta = with stdenv.lib; {
     description = "Log x86 machine checks: memory, IO, and CPU hardware errors";
     longDescription = ''
diff --git a/pkgs/os-specific/linux/spl/default.nix b/pkgs/os-specific/linux/spl/default.nix
index 941bd8a86710..865be70f34d3 100644
--- a/pkgs/os-specific/linux/spl/default.nix
+++ b/pkgs/os-specific/linux/spl/default.nix
@@ -6,67 +6,57 @@
 }:
 
 with stdenv.lib;
+
 let
   buildKernel = any (n: n == configFile) [ "kernel" "all" ];
   buildUser = any (n: n == configFile) [ "user" "all" ];
+in
+  assert any (n: n == configFile) [ "kernel" "user" "all" ];
+  assert buildKernel -> kernel != null;
+stdenv.mkDerivation rec {
+  name = "spl-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
+  version = "0.7.0";
+
+  src = fetchFromGitHub {
+    owner = "zfsonlinux";
+    repo = "spl";
+    rev = "spl-${version}";
+    sha256 = "05qqwhxc9nj94y28c97iwfz8gkjwicrhnkj425yb47gqa8rafazk";
+  };
 
-  common = { version, sha256 } @ args : stdenv.mkDerivation rec {
-    name = "spl-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
-
-    src = fetchFromGitHub {
-      owner = "zfsonlinux";
-      repo = "spl";
-      rev = "spl-${version}";
-      inherit sha256;
-    };
+  patches = [ ./const.patch ./install_prefix.patch ];
 
-    patches = [ ./const.patch ./install_prefix.patch ];
+  nativeBuildInputs = [ autoreconfHook ];
 
-    nativeBuildInputs = [ autoreconfHook ];
+  hardeningDisable = [ "pic" ];
 
-    hardeningDisable = [ "pic" ];
+  preConfigure = ''
+    substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
+    substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
+    substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
+    substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
+  '';
 
-    preConfigure = ''
-      substituteInPlace ./module/spl/spl-generic.c --replace /usr/bin/hostid hostid
-      substituteInPlace ./module/spl/spl-generic.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:${gawk}:/bin"
-      substituteInPlace ./module/splat/splat-vnode.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
-      substituteInPlace ./module/splat/splat-linux.c --replace "PATH=/sbin:/usr/sbin:/bin:/usr/bin" "PATH=${coreutils}:/bin"
-    '';
+  configureFlags = [
+    "--with-config=${configFile}"
+  ] ++ optionals buildKernel [
+    "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
+    "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
+  ];
 
-    configureFlags = [
-      "--with-config=${configFile}"
-    ] ++ optionals buildKernel [
-      "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
-      "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
-    ];
+  enableParallelBuilding = true;
 
-    enableParallelBuilding = true;
+  meta = {
+    description = "Kernel module driver for solaris porting layer (needed by in-kernel zfs)";
 
-    meta = {
-      description = "Kernel module driver for solaris porting layer (needed by in-kernel zfs)";
-
-      longDescription = ''
-          This kernel module is a porting layer for ZFS to work inside the linux
-          kernel.
-      '';
+    longDescription = ''
+      This kernel module is a porting layer for ZFS to work inside the linux
+      kernel.
+    '';
 
-      homepage = http://zfsonlinux.org/;
-      platforms = platforms.linux;
-      license = licenses.gpl2Plus;
-      maintainers = with maintainers; [ jcumming wizeman wkennington fpletz ];
-    };
+    homepage = http://zfsonlinux.org/;
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ jcumming wizeman wkennington fpletz globin ];
   };
-
-in
-  assert any (n: n == configFile) [ "kernel" "user" "all" ];
-  assert buildKernel -> kernel != null;
-  {
-    splStable = common {
-      version = "0.6.5.11";
-      sha256 = "192val8035pj2rryi3fwb134avzirhv5ifaj5021vh8bbjx75pd5";
-    };
-    splUnstable = common {
-      version = "0.7.0-rc5";
-      sha256 = "17y25g02c9swi3n90lhjvazcnsr69nh50dz3b8g1c08zlz9n2akp";
-    };
-  }
+}
diff --git a/pkgs/os-specific/linux/sysdig/default.nix b/pkgs/os-specific/linux/sysdig/default.nix
index ed0e0849721e..71a7acab0e12 100644
--- a/pkgs/os-specific/linux/sysdig/default.nix
+++ b/pkgs/os-specific/linux/sysdig/default.nix
@@ -3,23 +3,15 @@
 with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "sysdig-${version}";
-  version = "0.16.0";
+  version = "0.17.0";
 
   src = fetchFromGitHub {
     owner = "draios";
     repo = "sysdig";
     rev = version;
-    sha256 = "1h3f9nkc5fkvks6va0maq377m9qxnsf4q3f2dc14rdzfvnzidy06";
+    sha256 = "0xw4in2yb3ynpc8jwl95j92kbyr7fzda3mab8nyxcyld7gshrlvd";
   };
 
-  patches = [
-    (fetchpatch {
-       # Sysdig fails to run on linux kernels with unified cgroups enabled
-       url = https://github.com/draios/sysdig/files/909689/0001-Fix-for-linux-kernels-with-cgroup-v2-API-enabled.patch.txt;
-       sha256 = "10nmisifa500hzpa3899rs837bcal72pnqidxmrnr1js187z8j84";
-    })
-  ];
-
   buildInputs = [
     cmake zlib luajit ncurses perl jsoncpp libb64 openssl curl jq gcc
   ];
diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix
index 8535e3a3bb11..1e28cfe000f7 100644
--- a/pkgs/os-specific/linux/zfs/default.nix
+++ b/pkgs/os-specific/linux/zfs/default.nix
@@ -13,149 +13,105 @@ let
   buildKernel = any (n: n == configFile) [ "kernel" "all" ];
   buildUser = any (n: n == configFile) [ "user" "all" ];
 
-  common = { version, sha256, extraPatches, spl, incompatibleKernelVersion ? null } @ args:
-    if buildKernel &&
-       (incompatibleKernelVersion != null) &&
-       versionAtLeast kernel.version incompatibleKernelVersion then
-      throw "Linux v${kernel.version} is not yet supported by zfsonlinux v${version}. Try zfsUnstable or set the NixOS option boot.zfs.enableUnstable."
-    else stdenv.mkDerivation rec {
-      name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
-
-      src = fetchFromGitHub {
-        owner = "zfsonlinux";
-        repo = "zfs";
-        rev = "zfs-${version}";
-        inherit sha256;
-      };
-
-      patches = extraPatches;
-
-      buildInputs = [ autoreconfHook nukeReferences ]
-      ++ optionals buildKernel [ spl ]
-      ++ optionals buildUser [ zlib libuuid python attr ];
-
-      # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
-      NIX_CFLAGS_LINK = "-lgcc_s";
-
-      hardeningDisable = [ "pic" ];
-
-      preConfigure = ''
-        substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "umount -t zfs"           "${utillinux}/bin/umount -t zfs"
-        substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "mount -t zfs"            "${utillinux}/bin/mount -t zfs"
-        substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount"             "${utillinux}/bin/umount"
-        substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/mount"              "${utillinux}/bin/mount"
-        substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/ztest"         "$out/sbin/ztest"
-        substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/zdb"           "$out/sbin/zdb"
-        substituteInPlace ./config/user-systemd.m4    --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
-        substituteInPlace ./config/zfs-build.m4       --replace "\$sysconfdir/init.d"     "$out/etc/init.d"
-        substituteInPlace ./etc/zfs/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
-        substituteInPlace ./cmd/zed/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
-        substituteInPlace ./module/Makefile.in        --replace "/bin/cp"                 "cp"
-        substituteInPlace ./etc/systemd/system/zfs-share.service.in \
-          --replace "@bindir@/rm " "${coreutils}/bin/rm "
-
-        for f in ./udev/rules.d/*
-        do
-          substituteInPlace "$f" --replace "/lib/udev/vdev_id" "$out/lib/udev/vdev_id"
-        done
-
-        ./autogen.sh
-      '';
-
-      configureFlags = [
-        "--with-config=${configFile}"
-        ] ++ optionals buildUser [
-        "--with-dracutdir=$(out)/lib/dracut"
-        "--with-udevdir=$(out)/lib/udev"
-        "--with-systemdunitdir=$(out)/etc/systemd/system"
-        "--with-systemdpresetdir=$(out)/etc/systemd/system-preset"
-        "--with-mounthelperdir=$(out)/bin"
-        "--sysconfdir=/etc"
-        "--localstatedir=/var"
-        "--enable-systemd"
-        ] ++ optionals buildKernel [
-        "--with-spl=${spl}/libexec/spl"
-        "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
-        "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
-      ];
-
-      enableParallelBuilding = true;
-
-      installFlags = [
-        "sysconfdir=\${out}/etc"
-        "DEFAULT_INITCONF_DIR=\${out}/default"
-      ];
-
-      postInstall = ''
-        # Prevent kernel modules from depending on the Linux -dev output.
-        nuke-refs $(find $out -name "*.ko")
-      '' + optionalString buildUser ''
-        # Remove provided services as they are buggy
-        rm $out/etc/systemd/system/zfs-import-*.service
-
-        sed -i '/zfs-import-scan.service/d' $out/etc/systemd/system/*
-
-        for i in $out/etc/systemd/system/*; do
-        substituteInPlace $i --replace "zfs-import-cache.service" "zfs-import.target"
-        done
-
-        # Fix pkgconfig.
-        ln -s ../share/pkgconfig $out/lib/pkgconfig
-
-        # Remove tests because they add a runtime dependency on gcc
-        rm -rf $out/share/zfs/zfs-tests
-      '';
-
-      meta = {
-        description = "ZFS Filesystem Linux Kernel module";
-        longDescription = ''
-          ZFS is a filesystem that combines a logical volume manager with a
-          Copy-On-Write filesystem with data integrity detection and repair,
-          snapshotting, cloning, block devices, deduplication, and more.
-        '';
-        homepage = http://zfsonlinux.org/;
-        license = licenses.cddl;
-        platforms = platforms.linux;
-        maintainers = with maintainers; [ jcumming wizeman wkennington fpletz ];
-      };
-    };
-in
-  assert any (n: n == configFile) [ "kernel" "user" "all" ];
-  assert buildKernel -> kernel != null && spl != null;
-  {
-    # also check if kernel version constraints in
-    # ./nixos/modules/tasks/filesystems/zfs.nix needs
-    # to be adapted
-    zfsStable = common {
-      # comment/uncomment if breaking kernel versions are known
-      incompatibleKernelVersion = "4.12";
-
-      version = "0.6.5.11";
-
-      # this package should point to the latest release.
-      sha256 = "1wqz43cjr21m3f52ahcikl2798pbzj5sfy16zqxwiqpv7iy09kr3";
-      extraPatches = [
-        (fetchpatch {
-          url = "https://github.com/Mic92/zfs/compare/zfs-0.6.5.8...nixos-zfs-0.6.5.8.patch";
-          sha256 = "14kqqphzg02m9a7qncdhff8958cfzdrvsid3vsrm9k75lqv1w08z";
-        })
-      ];
-      inherit spl;
-    };
-    zfsUnstable = common {
-      # comment/uncomment if breaking kernel versions are known
-      incompatibleKernelVersion = null;
-
-      version = "0.7.0-rc5";
-
-      # this package should point to a version / git revision compatible with the latest kernel release
-      sha256 = "1k0fl6lbi5winri58v26k7gngd560hbj0247rnwcbc6j01ixsr5n";
-      extraPatches = [
-        (fetchpatch {
-          url = "https://github.com/Mic92/zfs/compare/zfs-0.7.0-rc3...nixos-zfs-0.7.0-rc3.patch";
-          sha256 = "1vlw98v8xvi8qapzl1jwm69qmfslwnbg3ry1lmacndaxnyckkvhh";
-        })
-      ];
-      spl = splUnstable;
-    };
-  }
+in stdenv.mkDerivation rec {
+  name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
+  version = "0.7.0";
+
+  src = fetchFromGitHub {
+    owner = "zfsonlinux";
+    repo = "zfs";
+    rev = "zfs-${version}";
+    sha256 = "16z0fl282rsmvgk608ii7n410swivkrisp112n2fhhjc1fs0zall";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/Mic92/zfs/compare/zfs-0.7.0-rc3...nixos-zfs-0.7.0-rc3.patch";
+      sha256 = "1vlw98v8xvi8qapzl1jwm69qmfslwnbg3ry1lmacndaxnyckkvhh";
+    })
+  ];
+
+  buildInputs = [ autoreconfHook nukeReferences ]
+  ++ optionals buildKernel [ spl ]
+  ++ optionals buildUser [ zlib libuuid python attr ];
+
+  # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
+  NIX_CFLAGS_LINK = "-lgcc_s";
+
+  hardeningDisable = [ "pic" ];
+
+  preConfigure = ''
+    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "umount -t zfs"           "${utillinux}/bin/umount -t zfs"
+    substituteInPlace ./module/zfs/zfs_ctldir.c   --replace "mount -t zfs"            "${utillinux}/bin/mount -t zfs"
+    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount"             "${utillinux}/bin/umount"
+    substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/mount"              "${utillinux}/bin/mount"
+    substituteInPlace ./udev/rules.d/*            --replace "/lib/udev/vdev_id"       "$out/lib/udev/vdev_id"
+    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/ztest"         "$out/sbin/ztest"
+    substituteInPlace ./cmd/ztest/ztest.c         --replace "/usr/sbin/zdb"           "$out/sbin/zdb"
+    substituteInPlace ./config/user-systemd.m4    --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
+    substituteInPlace ./config/zfs-build.m4       --replace "\$sysconfdir/init.d"     "$out/etc/init.d"
+    substituteInPlace ./etc/zfs/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
+    substituteInPlace ./cmd/zed/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
+    substituteInPlace ./module/Makefile.in        --replace "/bin/cp"                 "cp"
+    substituteInPlace ./etc/systemd/system/zfs-share.service.in \
+      --replace "@bindir@/rm " "${coreutils}/bin/rm "
+    ./autogen.sh
+  '';
+
+  configureFlags = [
+    "--with-config=${configFile}"
+    ] ++ optionals buildUser [
+    "--with-dracutdir=$(out)/lib/dracut"
+    "--with-udevdir=$(out)/lib/udev"
+    "--with-systemdunitdir=$(out)/etc/systemd/system"
+    "--with-systemdpresetdir=$(out)/etc/systemd/system-preset"
+    "--with-mounthelperdir=$(out)/bin"
+    "--sysconfdir=/etc"
+    "--localstatedir=/var"
+    "--enable-systemd"
+    ] ++ optionals buildKernel [
+    "--with-spl=${spl}/libexec/spl"
+    "--with-linux=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
+    "--with-linux-obj=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
+  ];
+
+  enableParallelBuilding = true;
+
+  installFlags = [
+    "sysconfdir=\${out}/etc"
+    "DEFAULT_INITCONF_DIR=\${out}/default"
+  ];
+
+  postInstall = ''
+    # Prevent kernel modules from depending on the Linux -dev output.
+    nuke-refs $(find $out -name "*.ko")
+  '' + optionalString buildUser ''
+    # Remove provided services as they are buggy
+    rm $out/etc/systemd/system/zfs-import-*.service
+
+    sed -i '/zfs-import-scan.service/d' $out/etc/systemd/system/*
+
+    for i in $out/etc/systemd/system/*; do
+    substituteInPlace $i --replace "zfs-import-cache.service" "zfs-import.target"
+    done
+
+    # Fix pkgconfig.
+    ln -s ../share/pkgconfig $out/lib/pkgconfig
+
+    # Remove tests because they add a runtime dependency on gcc
+    rm -rf $out/share/zfs/zfs-tests
+  '';
+
+  meta = {
+    description = "ZFS Filesystem Linux Kernel module";
+    longDescription = ''
+      ZFS is a filesystem that combines a logical volume manager with a
+      Copy-On-Write filesystem with data integrity detection and repair,
+      snapshotting, cloning, block devices, deduplication, and more.
+    '';
+    homepage = http://zfsonlinux.org/;
+    license = licenses.cddl;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ jcumming wizeman wkennington fpletz globin ];
+  };
+}