Have it refer to specific zfs package.
Users that inherit from the zfs package in order to compile for a specific kernel version should also inherit from this package and pass in their zfs.
* `guix build -f zfs-auto-snapshot.scm` on a scheme file containing only this package.
* Ran the hourly, daily, weekly, and monthly scripts "by hand". Also confirmed `com.sun:auto-snapshot` and `com.sun:auto-snapshot:*` settings work.
* Currently have it running in a homelab server with mcron triggers on the hourly, daily, weekly, and monthly scripts, at least one hourly trigger has passed and snapshots were indeed created without any errors in `/var/log/messages`.
* Checked the installed scripts and verified that the `zfs` and `zpool` commands refer to specific in-store binaries.
From 7425298029dd1c9b4f2b3bba675ddbe7eb730744 Mon Sep 17 00:00:00 2001
* gnu/packages/file-systems.scm (zfs-auto-snapshot): New variable.
gnu/packages/file-systems.scm | 75 +++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
Toggle diff (86 lines)
diff --git a/gnu/packages/file-systems.scm b/gnu/packages/file-systems.scm
index e7d78e41fb..4d01b3da46 100644
--- a/gnu/packages/file-systems.scm
+++ b/gnu/packages/file-systems.scm
@@ -975,6 +975,81 @@ originally developed for Solaris and is now maintained by the OpenZFS
(license license:cddl1.0)))
+(define-public zfs-auto-snapshot
+ (name "zfs-auto-snapshot")
+ "https://github.com/zfsonlinux/zfs-auto-snapshot/archive/upstream/"
+ (base32 "16ry1w43i44xc67gr73x6fa48ninfhqxr498ad4m3kya93vp2zrh"))))
+ (build-system gnu-build-system)
+ ;; Note: if you are inheriting from the above zfs package in order
+ ;; to provide a specific stable kernel version, you should also
+ ;; inherit this package and replace the sole input below.
+ `(#:tests? #f ; No tests
+ (modify-phases %standard-phases
+ ;; Guix System may not have a traditional cron system, but
+ ;; the cron scripts installed by this package are convenient
+ ;; to use as targets for an mcron job specification, so make
+ ;; sure they can be run in-store.
+ (add-before 'install 'fix-scripts
+ (lambda* (#:key outputs inputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (zfs-auto-snapshot (string-append
+ "/sbin/zfs-auto-snapshot"))
+ (zfs-package (assoc-ref inputs "zfs"))
+ (substitute* '("etc/zfs-auto-snapshot.cron.daily"
+ "etc/zfs-auto-snapshot.cron.frequent"
+ "etc/zfs-auto-snapshot.cron.hourly"
+ "etc/zfs-auto-snapshot.cron.monthly"
+ "etc/zfs-auto-snapshot.cron.weekly")
+ (substitute* "src/zfs-auto-snapshot.sh"
+ (string-append "LC_ALL=C " zfs " list"))
+ (("LC_ALL=C zpool status")
+ (string-append "LC_ALL=C " zpool " status"))
+ (string-append zfs " snapshot"))
+ (string-append zfs " destroy"))))))
+ ;; Provide DESTDIR and PREFIX on make command.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (invoke "make" "install"
+ (string-append "DESTDIR=" out)))
+ (home-page "https://github.com/zfsonlinux/zfs-auto-snapshot")
+ (synopsis "Automatically create, rotate, and destroy periodic ZFS snapshots")
+ "An alternative implementation of the zfs-auto-snapshot service for Linux
+that is compatible with zfs-linux and zfs-fuse.
+On Guix System, you will need to invoke the included shell scripts as @code{job}
+definitions in your @code{operating-system} declaration.")
+ (license license:gpl2+)))