diff options
Diffstat (limited to 'pkgs/os-specific/linux/zfs/default.nix')
-rw-r--r-- | pkgs/os-specific/linux/zfs/default.nix | 114 |
1 files changed, 63 insertions, 51 deletions
diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix index 56b36d4f368..7784aa8e03f 100644 --- a/pkgs/os-specific/linux/zfs/default.nix +++ b/pkgs/os-specific/linux/zfs/default.nix @@ -1,22 +1,25 @@ -{ stdenv, fetchFromGitHub, fetchpatch -, autoreconfHook, utillinux, nukeReferences, coreutils -, perl, buildPackages +{ lib, stdenv, fetchFromGitHub +, autoreconfHook269, util-linux, nukeReferences, coreutils +, perl, nixosTests , configFile ? "all" # Userspace dependencies , zlib, libuuid, python3, attr, openssl , libtirpc -, nfs-utils +, nfs-utils, samba , gawk, gnugrep, gnused, systemd -, smartmontools, sysstat, sudo +, smartmontools, enableMail ? false +, sysstat, pkg-config # Kernel dependencies , kernel ? null , enablePython ? true }: -with stdenv.lib; +with lib; let + smartmon = smartmontools.override { inherit enableMail; }; + buildKernel = any (n: n == configFile) [ "kernel" "all" ]; buildUser = any (n: n == configFile) [ "user" "all" ]; @@ -25,15 +28,9 @@ let , extraPatches ? [] , 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 { + , kernelCompatible ? null }: + + stdenv.mkDerivation { name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}"; src = fetchFromGitHub { @@ -42,27 +39,27 @@ let inherit rev sha256; }; - patches = [ ./BACKPORT-Linux-5.8-compat-__vmalloc.patch ] ++ extraPatches; + patches = extraPatches; postPatch = optionalString buildKernel '' 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/zfs/zfs_ctldir.c --replace '"/usr/bin/env", "umount"' '"${utillinux}/bin/umount", "-n"' \ - --replace '"/usr/bin/env", "mount"' '"${utillinux}/bin/mount", "-n"' + substituteInPlace ./module/os/linux/zfs/zfs_ctldir.c \ + --replace '"/usr/bin/env", "umount"' '"${util-linux}/bin/umount", "-n"' \ + --replace '"/usr/bin/env", "mount"' '"${util-linux}/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/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 nfs-utils.override (old: { enablePython = old.enablePython or true && enablePython; }) }/bin/exportfs" + substituteInPlace ./lib/libshare/smb.h --replace "/usr/bin/net" "${samba}/bin/net" 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 ./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" @@ -79,23 +76,22 @@ let substituteInPlace ./etc/systemd/system/Makefile.am \ --replace '$(DESTDIR)$(systemdunitdir)' "$out"'$(DESTDIR)$(systemdunitdir)' - substituteInPlace ./etc/systemd/system/zfs-share.service.in \ - --replace "/bin/rm " "${coreutils}/bin/rm " + 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 ./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 ] + nativeBuildInputs = [ autoreconfHook269 nukeReferences ] + ++ 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"; @@ -104,6 +100,7 @@ let configureFlags = [ "--with-config=${configFile}" + "--with-tirpc=1" (withFeatureAs (buildUser && enablePython) "python" python3.interpreter) ] ++ optionals buildUser [ "--with-dracutdir=$(out)/lib/dracut" @@ -134,7 +131,7 @@ let postInstall = optionalString buildKernel '' # Add reference that cannot be detected due to compressed kernel module mkdir -p "$out/nix-support" - echo "${utillinux}" >> "$out/nix-support/extra-refs" + echo "${util-linux}" >> "$out/nix-support/extra-refs" '' + optionalString buildUser '' # Remove provided services as they are buggy rm $out/etc/systemd/system/zfs-import-*.service @@ -145,9 +142,6 @@ let 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 @@ -156,14 +150,27 @@ let (cd $out/share/bash-completion/completions; ln -s zfs zpool) ''; - postFixup = '' - path="PATH=${makeBinPath [ coreutils gawk gnused gnugrep utillinux smartmontools sysstat sudo ]}" + postFixup = let + path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmon sysstat ]}:$PATH"; + in '' for i in $out/libexec/zfs/zpool.d/*; do - sed -i "2i$path" $i + sed -i '2i${path}' $i done ''; - outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ]; + outputs = [ "out" ] ++ optionals buildUser [ "dev" ]; + + passthru = { + inherit enableMail; + + tests = + if isUnstable then [ + nixosTests.zfs.unstable + ] else [ + nixosTests.zfs.installer + nixosTests.zfs.stable + ]; + }; meta = { description = "ZFS Filesystem Linux Kernel module"; @@ -172,10 +179,14 @@ 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"; + changelog = "https://github.com/openzfs/zfs/releases/tag/zfs-${version}"; license = licenses.cddl; platforms = platforms.linux; - maintainers = with maintainers; [ jcumming wizeman fpletz globin ]; + maintainers = with maintainers; [ hmenke jcumming jonringer wizeman fpletz globin mic92 ]; + # If your Linux kernel version is not yet supported by zfs, try zfsUnstable. + # On NixOS set the option boot.zfs.enableUnstable. + broken = buildKernel && (kernelCompatible != null) && !kernelCompatible; }; }; in { @@ -183,23 +194,24 @@ in { # ./nixos/modules/tasks/filesystems/zfs.nix needs # to be adapted zfsStable = common { - # comment/uncomment if breaking kernel versions are known - # incompatibleKernelVersion = "4.20"; + # check the release notes for compatible kernels + kernelCompatible = kernel.kernelAtLeast "3.10" && kernel.kernelOlder "5.14"; # this package should point to the latest release. - version = "0.8.4"; + version = "2.1.0"; - sha256 = "1hl4n900d24gl4vd65qdzq4m62b7bpvckldazcbd1xqcn8xhi6wp"; + sha256 = "sha256-YdY4SStXZGBBdAHdM3R/unco7ztxI3s0/buPSNSeh5o="; }; zfsUnstable = common { - # comment/uncomment if breaking kernel versions are known - # incompatibleKernelVersion = "4.19"; + # check the release notes for compatible kernels + kernelCompatible = kernel.kernelAtLeast "3.10" && kernel.kernelOlder "5.14"; # this package should point to a version / git revision compatible with the latest kernel release - version = "0.8.4"; + version = "2.1.0"; + + sha256 = "sha256-YdY4SStXZGBBdAHdM3R/unco7ztxI3s0/buPSNSeh5o="; - sha256 = "1hl4n900d24gl4vd65qdzq4m62b7bpvckldazcbd1xqcn8xhi6wp"; isUnstable = true; }; } |