Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 38f89284fc22
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8588cc051495
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jan 29, 2021

  1. Copy the full SHA
    8588cc0 View commit details
Showing with 27 additions and 31 deletions.
  1. +27 −31 pkgs/os-specific/linux/zfs/default.nix
58 changes: 27 additions & 31 deletions pkgs/os-specific/linux/zfs/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, fetchpatch
{ lib, stdenv, fetchFromGitHub, fetchpatch
, autoreconfHook, utillinux, nukeReferences, coreutils
, perl, buildPackages
, configFile ? "all"
@@ -9,13 +9,14 @@
, nfs-utils
, gawk, gnugrep, gnused, systemd
, smartmontools, sysstat, sudo
, pkg-config

# Kernel dependencies
, kernel ? null
, enablePython ? true
}:

with stdenv.lib;
with lib;
let
buildKernel = any (n: n == configFile) [ "kernel" "all" ];
buildUser = any (n: n == configFile) [ "user" "all" ];
@@ -26,14 +27,8 @@ let
, rev ? "zfs-${version}"
, isUnstable ? false
, incompatibleKernelVersion ? null }:
if buildKernel &&
(incompatibleKernelVersion != null) &&
versionAtLeast kernel.version incompatibleKernelVersion then
throw ''
Linux v${kernel.version} is not yet supported by zfsonlinux v${version}.
${stdenv.lib.optionalString (!isUnstable) "Try zfsUnstable or set the NixOS option boot.zfs.enableUnstable."}
''
else stdenv.mkDerivation {

stdenv.mkDerivation {
name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";

src = fetchFromGitHub {
@@ -48,13 +43,11 @@ let
patchShebangs scripts
# The arrays must remain the same length, so we repeat a flag that is
# already part of the command and therefore has no effect.
substituteInPlace ./module/${optionalString isUnstable "os/linux/"}zfs/zfs_ctldir.c \
substituteInPlace ./module/os/linux/zfs/zfs_ctldir.c \
--replace '"/usr/bin/env", "umount"' '"${utillinux}/bin/umount", "-n"' \
--replace '"/usr/bin/env", "mount"' '"${utillinux}/bin/mount", "-n"'
'' + optionalString buildUser ''
substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount" "${utillinux}/bin/umount" \
--replace "/bin/mount" "${utillinux}/bin/mount"
substituteInPlace ./lib/libshare/${optionalString isUnstable "os/linux/"}nfs.c --replace "/usr/sbin/exportfs" "${
substituteInPlace ./lib/libshare/os/linux/nfs.c --replace "/usr/sbin/exportfs" "${
# We don't *need* python support, but we set it like this to minimize closure size:
# If it's disabled by default, no need to enable it, even if we have python enabled
# And if it's enabled by default, only change that if we explicitly disable python to remove python from the closure
@@ -64,7 +57,6 @@ let
substituteInPlace ./config/zfs-build.m4 --replace "\$sysconfdir/init.d" "$out/etc/init.d" \
--replace "/etc/default" "$out/etc/default"
substituteInPlace ./etc/zfs/Makefile.am --replace "\$(sysconfdir)" "$out/etc"
substituteInPlace ./cmd/zed/Makefile.am --replace "\$(sysconfdir)" "$out/etc"
substituteInPlace ./contrib/initramfs/hooks/Makefile.am \
--replace "/usr/share/initramfs-tools/hooks" "$out/usr/share/initramfs-tools/hooks"
@@ -81,30 +73,22 @@ let
substituteInPlace ./etc/systemd/system/Makefile.am \
--replace '$(DESTDIR)$(systemdunitdir)' "$out"'$(DESTDIR)$(systemdunitdir)'
${optionalString isUnstable ''
substituteInPlace ./contrib/initramfs/conf.d/Makefile.am \
--replace "/usr/share/initramfs-tools/conf.d" "$out/usr/share/initramfs-tools/conf.d"
substituteInPlace ./contrib/initramfs/conf-hooks.d/Makefile.am \
--replace "/usr/share/initramfs-tools/conf-hooks.d" "$out/usr/share/initramfs-tools/conf-hooks.d"
''}
substituteInPlace ./etc/systemd/system/zfs-share.service.in \
--replace "/bin/rm " "${coreutils}/bin/rm "
substituteInPlace ./cmd/vdev_id/vdev_id \
--replace "PATH=/bin:/sbin:/usr/bin:/usr/sbin" \
"PATH=${makeBinPath [ coreutils gawk gnused gnugrep systemd ]}"
'' + optionalString stdenv.hostPlatform.isMusl ''
substituteInPlace config/user-libtirpc.m4 \
--replace /usr/include/tirpc ${libtirpc}/include/tirpc
'';

nativeBuildInputs = [ autoreconfHook nukeReferences ]
++ optionals buildKernel (kernel.moduleBuildDependencies ++ [ perl ]);
buildInputs = optionals buildUser [ zlib libuuid attr ]
++ optionals buildKernel (kernel.moduleBuildDependencies ++ [ perl ])
++ optional buildUser pkg-config;
buildInputs = optionals buildUser [ zlib libuuid attr libtirpc ]
++ optional buildUser openssl
++ optional (buildUser && enablePython) python3
++ optional stdenv.hostPlatform.isMusl libtirpc;
++ optional (buildUser && enablePython) python3;

# for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
NIX_CFLAGS_LINK = "-lgcc_s";
@@ -113,6 +97,7 @@ let

configureFlags = [
"--with-config=${configFile}"
"--with-tirpc=1"
(withFeatureAs (buildUser && enablePython) "python" python3.interpreter)
] ++ optionals buildUser [
"--with-dracutdir=$(out)/lib/dracut"
@@ -179,10 +164,17 @@ let
Copy-On-Write filesystem with data integrity detection and repair,
snapshotting, cloning, block devices, deduplication, and more.
'';
homepage = "https://zfsonlinux.org/";
homepage = "https://github.com/openzfs/zfs";
license = licenses.cddl;
platforms = platforms.linux;
maintainers = with maintainers; [ jcumming wizeman fpletz globin ];
maintainers = with maintainers; [ hmenke jcumming jonringer wizeman fpletz globin mic92 ];
broken = if
buildKernel && (incompatibleKernelVersion != null) && versionAtLeast kernel.version incompatibleKernelVersion
then builtins.trace ''
Linux v${kernel.version} is not yet supported by zfsonlinux v${version}.
${lib.optionalString (!isUnstable) "Try zfsUnstable or set the NixOS option boot.zfs.enableUnstable."}
'' true
else false;
};
};
in {
@@ -191,12 +183,14 @@ in {
# to be adapted
zfsStable = common {
# comment/uncomment if breaking kernel versions are known
incompatibleKernelVersion = "5.11";
# incompatibleKernelVersion = "4.20";

# this package should point to the latest release.
version = "2.0.1";

sha256 = "0wmw823ildwm9rcfyk22pvzg100yhps3y9hfjlrpspfd1hhkbp0d";

extraPatches = [ ];
};

zfsUnstable = common {
@@ -207,6 +201,8 @@ in {
version = "2.0.1";

sha256 = "0wmw823ildwm9rcfyk22pvzg100yhps3y9hfjlrpspfd1hhkbp0d";
isUnstable = true;

extraPatches = [ ];
};
}