Subject: [PATCH v0] gnu: zfs: Update to 2.2.3

From: antlers <[email-masked]>
Date: Mon, 29 Apr 2024 01:22:36 -0700

* gnu/packages/file-systems.scm (zfs): Update to 2.2.3
---
I did the bare minimum to build v2.2.x after mounting my array elsewhere and
inadvertently catching a dependance on feature 'com.klarasystems:vdev_zaps_v2'.
Specifically, I removed substitutions on files which no longer exist and added
new ones until it built. Hence I can make no claim that this is exaustive, but
I can mount the array and nothing's broken that wasn't already (ie. ZED).

I've made a habit of mentioning how to run this because it's not documented.
You have to:

a.) build it against your current kernel (<=v6.7, lts is currently 6.6) by
setting the package's '#:linux' argument.

b.) ensure that the module is loaded by either creating a
'kernel-module-loader' service or building the module into the kernel.

A few additional notes-to-self:

- Combining 'a' with the latter approach to 'b' means building the kernel
  twice, when (IIRC) 'linux-module-build-system' packages often depend on
  target sources rather than outputs? We should probably be able to set
  `#:linux` to (or infer from it) the headers or whatever's needed without
  depending on a full kernel build.

- ZFS Event Daemon (ZED) fails to start because it thinks it lives in
  '/gnu/store/...-zfs-2.x.x/var/run', and I don't even see an option to
  override it from the command-line. Seems to have been like that for a while.
  Should be a quick fix by setting '@runstatedir@' correctly, but I doubt
  anyone's clamoring for it and am moving on for now -- could toss in a fix for
  that with the next point release?

 gnu/packages/file-systems.scm | 36 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/gnu/packages/file-systems.scm b/gnu/packages/file-systems.scm
index 8afd853350..8e85b295cf 100644
--- a/gnu/packages/file-systems.scm
+++ b/gnu/packages/file-systems.scm
@@ -1442,7 +1442,7 @@ (define args
 (define-public zfs
   (package
     (name "zfs")
-    (version "2.1.14")
+    (version "2.2.3")
     (outputs '("out" "module" "src"))
     (source
       (origin
@@ -1451,7 +1451,7 @@ (define-public zfs
                               "/download/zfs-" version
                               "/zfs-" version ".tar.gz"))
           (sha256
-           (base32 "0gzansmin40llxxh2zkgpdyp41ikd8s5hv5mpwhpcivk1q8fv7sh"))))
+           (base32 "1hqsv2skymrhzg9n94bcna8r7m1zl30wjb5knaw43j659vri599h"))))
     (build-system linux-module-build-system)
     (arguments
      (list
@@ -1500,12 +1500,6 @@ (define-public zfs
                              "man/man7/zpool-features.7")
                 (("/usr/share/zfs/compatibility.d")
                  (string-append #$output "/share/zfs/compatibility.d")))
-              (substitute* "etc/Makefile.in"
-                ;; This just contains an example configuration file for
-                ;; configuring ZFS on traditional init systems, skip it
-                ;; since we cannot use it anyway; the install target becomes
-                ;; misdirected.
-                (("= default ") "= "))
               (substitute* "lib/libzfs/os/linux/libzfs_util_os.c"
                 ;; Use path to /gnu/store/*-kmod in actual path that is
                 ;; exec'ed.
@@ -1516,9 +1510,17 @@ (define-public zfs
                 ;; Just use 'modprobe' in message to user, since Guix
                 ;; does not have a traditional /sbin/
                 (("'/sbin/modprobe ") "'modprobe "))
-              (substitute* "contrib/Makefile.in"
-                ;; This is not configurable nor is its hard-coded /usr prefix.
-                ((" initramfs") ""))
+              (substitute* "configure"
+                (("/etc/default")
+		 (string-append #$output "/etc/default"))
+		(("/etc/bash_completion.d")
+		 (string-append #$output "/etc/bash_completion.d")))
+              (substitute* "Makefile.in"
+                (("/usr/share/initramfs-tools")
+		 (string-append #$output "/usr/share/initramfs-tools")))
+              (substitute* "contrib/initramfs/Makefile.am"
+                (("/usr/share/initramfs-tools")
+		 (string-append #$output "/usr/share/initramfs-tools")))
               (substitute* "module/os/linux/zfs/zfs_ctldir.c"
                 (("/usr/bin/env\", \"umount")
                  (string-append (search-input-file inputs "/bin/umount")
@@ -1535,18 +1537,8 @@ (define-public zfs
               (substitute* "config/zfs-build.m4"
                 (("\\$sysconfdir/init.d")
                  (string-append #$output "/etc/init.d")))
-              (substitute* '("etc/zfs/Makefile.am"
-                             "cmd/zed/Makefile.am")
+              (substitute* '("cmd/zed/Makefile.am")
                 (("\\$\\(sysconfdir)") (string-append #$output "/etc")))
-              (substitute* "cmd/vdev_id/vdev_id"
-                (("PATH=/bin:/sbin:/usr/bin:/usr/sbin")
-                 (string-append "PATH="
-                                (dirname (which "chmod")) ":"
-                                (dirname (which "grep")) ":"
-                                (dirname (which "sed")) ":"
-                                (dirname (which "gawk")))))
-              (substitute* "contrib/pyzfs/Makefile.in"
-                ((".*install-lib.*") ""))
               (substitute* '("Makefile.am" "Makefile.in")
                 (("\\$\\(prefix)/src") (string-append #$output:src "/src")))
               (substitute* (find-files "udev/rules.d/" ".rules.in$")
-- 
2.41.0