From 62bf9a7cc79d24e7edc2b56d6dde6e77eebc537e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 6 Jul 2025 16:31:00 +0200 Subject: [PATCH] =?UTF-8?q?mapped-devices:=20Add=20=E2=80=98arguments?= =?UTF-8?q?=E2=80=99=20field.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . This allows users to specify extra arguments specific to the underlying mapped device type. * gnu/system/mapped-devices.scm ()[arguments]: New field. (device-mapping-service-type): Honor it. * guix/scripts/system.scm (check-mapped-devices): Likewise. * gnu/system/linux-initrd.scm (raw-initrd): Likewise. * doc/guix.texi (Mapped Devices): Document it. Reported-by: 45mg <45mg.writes@gmail.com> Change-Id: Idef5a3e68535c412f13bae9a92c81c49053d4f4a --- doc/guix.texi | 4 ++++ gnu/system/linux-initrd.scm | 3 ++- gnu/system/mapped-devices.scm | 14 ++++++++++---- guix/scripts/system.scm | 5 +++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2e1b9378d1d..b83579ed6d5 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -18637,6 +18637,10 @@ there are several. The format is identical to @var{target}. @item type This must be a @code{mapped-device-kind} object, which specifies how @var{source} is mapped to @var{target}. + +@item arguments +This is a list of arguments specific to @var{type} that are passed to +its @code{open}, @code{close}, and @code{check} procedures. @end table @end deftp diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 72da8e55d30..17c2e6f6bfd 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -229,7 +229,8 @@ upon error." (targets (mapped-device-targets md)) (type (mapped-device-type md)) (open (mapped-device-kind-open type))) - (open source targets))) + (apply open source targets + (mapped-device-arguments md)))) mapped-devices)) (define file-system-scan-commands diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 667a4955703..c09a0f1ef17 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, 2024 Ludovic Courtès +;;; Copyright © 2014-2022, 2024-2025 Ludovic Courtès ;;; Copyright © 2016 Andreas Enge ;;; Copyright © 2017, 2018 Mark H Weaver ;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz> @@ -51,6 +51,7 @@ mapped-device-target mapped-device-targets mapped-device-type + mapped-device-arguments mapped-device-location mapped-device-kind @@ -83,6 +84,8 @@ (source mapped-device-source) ;string | list of strings (targets mapped-device-targets) ;list of strings (type mapped-device-type) ; + (arguments mapped-device-arguments ;list passed to open/close/check + (default '())) (location mapped-device-location (default (current-source-location)) (innate))) @@ -128,13 +131,16 @@ specifications to 'targets'." 'device-mapping (match-lambda (($ source targets - ($ open close modules)) + ($ open close modules) + arguments) (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)))) + (start #~(lambda () + #$(apply open source targets arguments))) + (stop #~(lambda _ + (not #$(apply close source targets arguments)))) (modules (append %default-modules modules)) (respawn? #f)))) (description "Map a device node using Linux's device mapper."))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 23eb2155618..8a56f1cc63d 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -680,9 +680,10 @@ procedure of its type." (mapped-device-type md)))) ;; We expect CHECK to raise an exception with a detailed ;; '&message' if something goes wrong. - (check md + (apply check md #:needed-for-boot? (needed-for-boot? md) - #:initrd-modules initrd-modules))) + #:initrd-modules initrd-modules + (mapped-device-arguments md)))) (operating-system-mapped-devices os))) (define (check-initrd-modules os)