From 6062339156ecc42cac59af0d34e22fcc7da3aa4a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 8 Apr 2024 00:13:25 +0200 Subject: mapped-devices: can specify modules to import. * gnu/system/mapped-devices.scm ()[modules]: New field. (device-mapping-service-type): Honor it. * gnu/system/linux-initrd.scm (raw-initrd): Likewise. Change-Id: Icc702cb6f281741975e33203f87fbc1ffa9856da --- gnu/system/mapped-devices.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gnu/system/mapped-devices.scm') diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index c19a818453..4e135772a9 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014-2022 Ludovic Courtès +;;; Copyright © 2014-2022, 2024 Ludovic Courtès ;;; Copyright © 2016 Andreas Enge ;;; Copyright © 2017, 2018 Mark H Weaver ;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz> @@ -57,6 +57,7 @@ mapped-device-kind? mapped-device-kind-open mapped-device-kind-close + mapped-device-kind-modules mapped-device-kind-check device-mapping-service-type @@ -112,6 +113,8 @@ specifications to 'targets'." (open mapped-device-kind-open) ;source target -> gexp (close mapped-device-kind-close ;source target -> gexp (default (const #~(const #f)))) + (modules mapped-device-kind-modules ;list of module names + (default '())) (check mapped-device-kind-check ;source -> Boolean (default (const #t)))) @@ -125,13 +128,14 @@ specifications to 'targets'." 'device-mapping (match-lambda (($ source targets - ($ open close)) + ($ open close modules)) (shepherd-service (provision (list (symbol-append 'device-mapping- (string->symbol (string-join targets "-"))))) (requirement '(udev)) (documentation "Map a device node using Linux's device mapper.") (start #~(lambda () #$(open source targets))) (stop #~(lambda _ (not #$(close source targets)))) + (modules (append %default-modules modules)) (respawn? #f)))) (description "Map a device node using Linux's device mapper."))) -- cgit v1.2.3 From 49f82fca4130ffcfb16aa0cf89750ab56fb99ad7 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 8 Apr 2024 00:15:39 +0200 Subject: mapped-devices: luks: Specify modules needed at the top-level. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . * gnu/system/mapped-devices.scm (luks-device-mapping)[modules]: New field. (open-luks-device): Remove non-top-level ‘use-modules’ form. * gnu/system/linux-initrd.scm (raw-initrd): Remove modules that were added specifically for ‘luks-device-mapping’. Change-Id: I4253c3dd5e3cbcee41ec84fd57227abd428d1bd6 --- gnu/system/linux-initrd.scm | 7 ------- gnu/system/mapped-devices.scm | 11 ++++------- 2 files changed, 4 insertions(+), 14 deletions(-) (limited to 'gnu/system/mapped-devices.scm') diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 7868ff5723..561cfe2fd0 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -252,13 +252,6 @@ upon error." (srfi srfi-1) ;for lvm-device-mapping (srfi srfi-26) - ;; FIXME: The following modules are for - ;; LUKS-DEVICE-MAPPING. We should instead propagate - ;; this info via gexps. - ((gnu build file-systems) - #:select (find-partition-by-luks-uuid)) - (rnrs bytevectors)) - ;; Load extra modules needed by the mapped device code. #$@(append-map (compose mapped-device-kind-modules mapped-device-type) diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 4e135772a9..e56ead9e5e 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -206,12 +206,6 @@ option of @command{guix system}.\n") (uuid-bytevector source) source)) (keyfile #$key-file)) - ;; XXX: 'use-modules' should be at the top level. - (use-modules (rnrs bytevectors) ;bytevector? - ((gnu build file-systems) - #:select (find-partition-by-luks-uuid - system*/tty)) - ((guix build utils) #:select (mkdir-p))) ;; Create '/run/cryptsetup/' if it does not exist, as device locking ;; is mandatory for LUKS2. @@ -287,7 +281,10 @@ option of @command{guix system}.\n") (mapped-device-kind (open open-luks-device) (close close-luks-device) - (check check-luks-device))) + (check check-luks-device) + (modules '((rnrs bytevectors) ;bytevector? + ((gnu build file-systems) + #:select (find-partition-by-luks-uuid system*/tty)))))) (define* (luks-device-mapping-with-options #:key key-file) "Return a luks-device-mapping object with open modified to pass the arguments -- cgit v1.2.3