Subject: bug#70826: luks-device-mapping-with-options breaks bootloader

From: Quentin Vincent <[email-masked]>
Date: Sun, 15 Jun 2025 06:50:02 +0200

Hi,

I independently ran into and fixed this issue myself, but seeing Ludo's
patch, I'll probably run with that.

@Ludo: I tested your patch on my setup (inside a VM); it needed a few small
fixups (an export was missing and the (apply ...) wasn't working for
some reason), but other than that it worked for me.  I was able to add a
#:key-file parameter to my LUKS device with your patch.  You just need
to apply my fixup on top of your patch.

Cheers,
Quentin

>From 4d507479467c6721f911e5776b4bf6b5709b9846 Mon Sep 17 00:00:00 2001
From: Quentin Vincent <[email-masked]>
Date: Sat, 14 Jun 2025 13:20:22 +0200
Subject: [PATCH] system: Make arguments for <mapped-device-type>s work

Change-Id: Ia5e14d0eb516cb20bee00a270cb3446bfdfabf90
---
 gnu/system/linux-initrd.scm   | 12 ++++++------
 gnu/system/mapped-devices.scm |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 17c2e6f6bf..0484c899fa 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -225,12 +225,12 @@ (define* (raw-initrd file-systems
   (define device-mapping-commands
     ;; List of gexps to open the mapped devices.
     (map (lambda (md)
-           (let* ((source  (mapped-device-source md))
-                  (targets (mapped-device-targets md))
-                  (type    (mapped-device-type md))
-                  (open    (mapped-device-kind-open type)))
-             (apply open source targets
-                    (mapped-device-arguments md))))
+           (let* ((source    (mapped-device-source md))
+                  (targets   (mapped-device-targets md))
+                  (type      (mapped-device-type md))
+                  (open      (mapped-device-kind-open type))
+                  (arguments (mapped-device-arguments md)))
+             (apply open source targets arguments)))
          mapped-devices))
 
   (define file-system-scan-commands
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 29d0dc95cf..f8ec178ba8 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -51,6 +51,7 @@ (define-module (gnu system mapped-devices)
             mapped-device-target
             mapped-device-targets
             mapped-device-type
+            mapped-device-arguments
             mapped-device-location
 
             mapped-device-kind
-- 
2.49.0