mirror of
https://codeberg.org/hako/Rosenthal.git
synced 2025-11-04 03:34:37 +00:00
services: zfs: Add zfs-configuration.
* modules/rosenthal/services/file-systems.scm (<zfs-configuration>): New data type. Enable auto mounting and disable volumes by default. (zfs-shepherd-service): Rename to zfs-shepherd. No longer use one-shot services. (zfs-service-type): Adjust accordingly. Set default value. * modules/rosenthal/utils/transformations.scm (rosenthal-transformation-zfs): Allow configuration.
This commit is contained in:
parent
9e2dc3254d
commit
1c3aed0cdb
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
(define-module (rosenthal services file-systems)
|
(define-module (rosenthal services file-systems)
|
||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
|
#:use-module (guix records)
|
||||||
#:use-module (gnu packages backup)
|
#:use-module (gnu packages backup)
|
||||||
#:use-module (gnu packages file-systems)
|
#:use-module (gnu packages file-systems)
|
||||||
#:use-module (rosenthal packages admin)
|
#:use-module (rosenthal packages admin)
|
||||||
@ -19,7 +20,8 @@
|
|||||||
|
|
||||||
dumb-runtime-dir-service-type
|
dumb-runtime-dir-service-type
|
||||||
|
|
||||||
zfs-service-type))
|
zfs-service-type
|
||||||
|
zfs-configuration))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
@ -101,37 +103,62 @@
|
|||||||
;;; ZFS
|
;;; ZFS
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
(define-configuration/no-serialization zfs-configuration
|
||||||
|
(volumes?
|
||||||
|
(boolean #f)
|
||||||
|
"")
|
||||||
|
(auto-mount?
|
||||||
|
(boolean #t)
|
||||||
|
""))
|
||||||
|
|
||||||
(define zfs-shepherd-service
|
(define zfs-shepherd
|
||||||
(list (shepherd-service
|
(match-record-lambda <zfs-configuration>
|
||||||
(provision '(zfs-import))
|
(volumes? auto-mount?)
|
||||||
(requirement '(kernel-module-loader))
|
(append
|
||||||
(start
|
(list
|
||||||
#~(make-forkexec-constructor
|
(shepherd-service
|
||||||
(list #$(file-append zfs "/sbin/zpool") "import" "-a" "-N")))
|
(provision '(file-system-zfs))
|
||||||
(one-shot? #t))
|
(requirement
|
||||||
(shepherd-service
|
`(zfs-import
|
||||||
(provision '(zfs-volumes))
|
,@(if volumes? '(zfs-volumes) '())
|
||||||
(requirement '(zfs-import))
|
,@(if auto-mount? '(zfs-mount) '())))
|
||||||
(start
|
(start #~(const #t))
|
||||||
#~(make-forkexec-constructor
|
(stop #~(const #f)))
|
||||||
(list #$(file-append zfs "/bin/zvol_wait"))))
|
(shepherd-service
|
||||||
(one-shot? #t))
|
(provision '(zfs-import))
|
||||||
(shepherd-service
|
(requirement '(kernel-module-loader))
|
||||||
(provision '(zfs-mount))
|
(start
|
||||||
(requirement '(zfs-import))
|
#~(make-system-constructor
|
||||||
(start
|
(string-join
|
||||||
#~(make-forkexec-constructor
|
(list #$(file-append zfs "/sbin/zpool") "import" "-a" "-N"))))
|
||||||
(list #$(file-append zfs "/sbin/zfs") "mount" "-a" "-l")))
|
(stop #~(const #f))))
|
||||||
(one-shot? #t))
|
(if volumes?
|
||||||
(shepherd-service
|
(list
|
||||||
(provision '(file-system-zfs))
|
(shepherd-service
|
||||||
(requirement '(zfs-mount))
|
(provision '(zfs-volumes))
|
||||||
(start #~(const #t))
|
(requirement '(zfs-import))
|
||||||
(stop
|
(start
|
||||||
#~(make-system-destructor
|
#~(make-system-constructor
|
||||||
(string-join
|
(string-join
|
||||||
(list #$(file-append zfs "/sbin/zfs") "unmount" "-a")))))))
|
;; TODO: Patch references within zfs package instead.
|
||||||
|
(list "PATH=/run/current-system/profile/bin:/run/current-system/profile/sbin"
|
||||||
|
#$(file-append zfs "/bin/zvol_wait")))))
|
||||||
|
(stop #~(const #f))))
|
||||||
|
'())
|
||||||
|
(if auto-mount?
|
||||||
|
(list
|
||||||
|
(shepherd-service
|
||||||
|
(provision '(zfs-mount))
|
||||||
|
(requirement '(zfs-import))
|
||||||
|
(start
|
||||||
|
#~(make-system-constructor
|
||||||
|
(string-join
|
||||||
|
(list #$(file-append zfs "/sbin/zfs") "mount" "-a" "-l"))))
|
||||||
|
(stop
|
||||||
|
#~(make-system-destructor
|
||||||
|
(string-join
|
||||||
|
(list #$(file-append zfs "/sbin/zfs") "unmount" "-a"))))))
|
||||||
|
'()))))
|
||||||
|
|
||||||
(define zfs-service-type
|
(define zfs-service-type
|
||||||
(service-type
|
(service-type
|
||||||
@ -144,10 +171,10 @@
|
|||||||
(service-extension kernel-module-loader-service-type
|
(service-extension kernel-module-loader-service-type
|
||||||
(const '("zfs")))
|
(const '("zfs")))
|
||||||
(service-extension shepherd-root-service-type
|
(service-extension shepherd-root-service-type
|
||||||
(const zfs-shepherd-service))
|
zfs-shepherd)
|
||||||
(service-extension user-processes-service-type
|
(service-extension user-processes-service-type
|
||||||
(const '(file-system-zfs)))
|
(const '(file-system-zfs)))
|
||||||
(service-extension profile-service-type
|
(service-extension profile-service-type
|
||||||
(const (list zfs)))))
|
(const (list zfs)))))
|
||||||
(default-value #f)
|
(default-value (zfs-configuration))
|
||||||
(description "")))
|
(description "")))
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
(guix-configuration-guix config)))))))))))
|
(guix-configuration-guix config)))))))))))
|
||||||
|
|
||||||
;; NOTE: Booting from ZFS requires patching Guix.
|
;; NOTE: Booting from ZFS requires patching Guix.
|
||||||
(define* (rosenthal-transformation-zfs #:key boot?)
|
(define* (rosenthal-transformation-zfs #:key boot? (config (zfs-configuration)))
|
||||||
(lambda (os)
|
(lambda (os)
|
||||||
(operating-system
|
(operating-system
|
||||||
(inherit os)
|
(inherit os)
|
||||||
@ -81,5 +81,5 @@
|
|||||||
'())
|
'())
|
||||||
,@(operating-system-kernel-loadable-modules os)))
|
,@(operating-system-kernel-loadable-modules os)))
|
||||||
(services
|
(services
|
||||||
(cons* (service zfs-service-type)
|
(cons* (service zfs-service-type config)
|
||||||
(operating-system-user-services os))))))
|
(operating-system-user-services os))))))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user