diff options
| author | vin <git@vineetk.net> | 2025-07-23 03:00:18 -0400 |
|---|---|---|
| committer | vin <git@vineetk.net> | 2025-07-23 03:00:18 -0400 |
| commit | 48f7d54ab6df2acc51b679e44695bc76ee581696 (patch) | |
| tree | 9ff81a181918fb7c650f92f39cb059db9a60b61e /epistemia/services | |
| parent | 1e0d8f224707b309fbbb275ba8afadae993f7852 (diff) | |
start reorganizing
Diffstat (limited to 'epistemia/services')
| -rw-r--r-- | epistemia/services/zfs.scm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/epistemia/services/zfs.scm b/epistemia/services/zfs.scm new file mode 100644 index 0000000..bb5e13f --- /dev/null +++ b/epistemia/services/zfs.scm | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | (define-module (epistemia services zfs) | ||
| 2 | #:use-module (gnu services shepherd) | ||
| 3 | #:use-module (guix gexp) | ||
| 4 | #:use-module (epistemia packages zfs) | ||
| 5 | #:export (zfs-shepherd-services)) | ||
| 6 | |||
| 7 | ;; from raid5atemyhomework's valiant efforts | ||
| 8 | (define zfs-shepherd-services | ||
| 9 | (let ((zpool (file-append zfs-linux "/sbin/zpool")) | ||
| 10 | (zfs (file-append zfs-linux "/sbin/zfs")) | ||
| 11 | (scheme-modules `((srfi srfi-1) | ||
| 12 | (srfi srfi-34) | ||
| 13 | (srfi srfi-35) | ||
| 14 | (rnrs io ports) | ||
| 15 | ,@%default-modules))) | ||
| 16 | (define zfs-scan | ||
| 17 | (shepherd-service | ||
| 18 | (provision '(zfs-scan)) | ||
| 19 | (documentation "Scans for ZFS pools.") | ||
| 20 | (requirement '(kernel-module-loader udev)) | ||
| 21 | (modules scheme-modules) | ||
| 22 | (start #~(lambda _ | ||
| 23 | (invoke/quiet #$zpool "import" "-a" "-N" "-d" "/dev/disk/by-id"))) | ||
| 24 | (stop #~(const #f)))) | ||
| 25 | (define zfs-automount | ||
| 26 | (shepherd-service | ||
| 27 | (provision '(zfs-automount)) | ||
| 28 | (documentation "Automounts ZFS data sets.") | ||
| 29 | (requirement '(zfs-scan)) | ||
| 30 | (modules scheme-modules) | ||
| 31 | (start #~(lambda _ | ||
| 32 | (with-output-to-port | ||
| 33 | (current-error-port) | ||
| 34 | (lambda () | ||
| 35 | (invoke #$zfs "mount" "-a" "-l"))))) | ||
| 36 | (stop #~(lambda _ | ||
| 37 | (chdir "/") | ||
| 38 | (invoke/quiet #$zfs "unmount" "-a" "-f") | ||
| 39 | #f)))) | ||
| 40 | (list zfs-scan zfs-automount))) | ||
