summaryrefslogtreecommitdiff
path: root/gnu/system/mapped-devices.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-04-17 18:09:11 +0200
committerLudovic Courtès <ludo@gnu.org>2016-04-18 01:24:06 +0200
commit1ea507bce294d12223c35c3f8c2ae3e54a4127fd (patch)
treeeddb6e8eb5b0b451c39eb87695d6988add87ccda /gnu/system/mapped-devices.scm
parent374f14c265224048b065f2c177f80718b905201b (diff)
services: Move 'device-mapping-service' to (gnu system mapped-devices).
* gnu/services/base.scm (device-mapping-service-type) (device-mapping-service): Move to... * gnu/system/mapped-devices.scm (device-mapping-service-type): (device-mapping-service): ... here. New variables.
Diffstat (limited to 'gnu/system/mapped-devices.scm')
-rw-r--r--gnu/system/mapped-devices.scm31
1 files changed, 31 insertions, 0 deletions
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index dd8e432688..be2d6a4749 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -19,7 +19,10 @@
(define-module (gnu system mapped-devices)
#:use-module (guix gexp)
#:use-module (guix records)
+ #:use-module (gnu services)
+ #:use-module (gnu services shepherd)
#:autoload (gnu packages cryptsetup) (cryptsetup)
+ #:use-module (ice-9 match)
#:export (mapped-device
mapped-device?
mapped-device-source
@@ -31,6 +34,9 @@
mapped-device-kind-open
mapped-device-kind-close
+ device-mapping-service-type
+ device-mapping-service
+
luks-device-mapping))
;;; Commentary:
@@ -56,6 +62,31 @@
;;;
+;;; Device mapping as a Shepherd service.
+;;;
+
+(define device-mapping-service-type
+ (shepherd-service-type
+ 'device-mapping
+ (match-lambda
+ ((target open close)
+ (shepherd-service
+ (provision (list (symbol-append 'device-mapping- (string->symbol target))))
+ (requirement '(udev))
+ (documentation "Map a device node using Linux's device mapper.")
+ (start #~(lambda () #$open))
+ (stop #~(lambda _ (not #$close)))
+ (respawn? #f))))))
+
+(define (device-mapping-service target open close)
+ "Return a service that maps device @var{target}, a string such as
+@code{\"home\"} (meaning @code{/dev/mapper/home}). Evaluate @var{open}, a
+gexp, to open it, and evaluate @var{close} to close it."
+ (service device-mapping-service-type
+ (list target open close)))
+
+
+;;;
;;; Common device mappings.
;;;