diff options
Diffstat (limited to 'gnu/services/base.scm')
-rw-r--r-- | gnu/services/base.scm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index f2de85f410..b38d3e3765 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -39,6 +39,7 @@ #:export (root-file-system-service file-system-service device-mapping-service + swap-service user-processes-service host-name-service console-font-service @@ -614,6 +615,27 @@ gexp, to open it, and evaluate @var{close} to close it." (stop #~(lambda _ (not #$close))) (respawn? #f))))) +(define (swap-service device) + "Return a service that uses @var{device} as a swap device." + (define requirement + (if (string-prefix? "/dev/mapper/" device) + (list (symbol-append 'device-mapping- + (string->symbol (basename device)))) + '())) + + (with-monad %store-monad + (return (service + (provision (list (symbol-append 'swap- (string->symbol device)))) + (requirement `(udev ,@requirement)) + (documentation "Enable the given swap device.") + (start #~(lambda () + (swapon #$device) + #t)) + (stop #~(lambda _ + (swapoff #$device) + #f)) + (respawn? #f))))) + (define %base-services ;; Convenience variable holding the basic services. (let ((motd (text-file "motd" " |