mapped-devices: <mapped-device-type> can specify modules to import.

* gnu/system/mapped-devices.scm (<mapped-device-type>)[modules]: New
field.
(device-mapping-service-type): Honor it.
* gnu/system/linux-initrd.scm (raw-initrd): Likewise.

Change-Id: Icc702cb6f281741975e33203f87fbc1ffa9856da
This commit is contained in:
Ludovic Courtès 2024-04-08 00:13:25 +02:00
parent b30b838d50
commit 6062339156
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 12 additions and 3 deletions

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013-2020, 2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
@ -259,6 +259,11 @@ (define kodir
#: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)
mapped-devices))
(with-output-to-port (%make-void-port "w")
(lambda ()
(set-path-environment-variable "PATH" '("bin" "sbin")

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014-2022, 2024 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2017, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2024 Tomas Volf <~@wolfsden.cz>
@ -57,6 +57,7 @@ (define-module (gnu system mapped-devices)
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 @@ (define-record-type* <mapped-device-type> mapped-device-kind
(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 @@ (define device-mapping-service-type
'device-mapping
(match-lambda
(($ <mapped-device> source targets
($ <mapped-device-type> open close))
($ <mapped-device-type> 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.")))