Subject: Re: [bug#55231] [PATCH v1] initrd: Allow extra search paths with‘initrd-extra-module-paths’

From: Brian Cully <[email-masked]>
Date: Mon, 02 May 2022 18:53:31 -0400

Maxime Devos <[email-masked]> writes:

> This needs some information in the manual -- when does the field 
> need
> to be set?  For what kernel modules?  Is this required by 
> v4l2loopback-
> linux-module and librem-ec-acpi-linux-module?  Things like that.
> As-is, this functionality is hard to discover.

I knew I missed something. How’s this look?

---
 doc/guix.texi | 42 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5399584cb0..1ee2c1b4a3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15173,6 +15173,16 @@ Window System.
 The list of Linux kernel modules that need to be available in the
 initial RAM disk.  @xref{Initial RAM Disk}.
 
+@item @code{initrd-extra-module-paths} (default: @code{'()})
+@cindex initrd
+@cindex initial RAM disk
+A list of paths outside of the Linux kernel tree to search for 
Linux
+kernel modules.
+
+The items in this may be either file-like objects (usually 
packages), or
+a list where the first element is a package and the second is an
+output--e.g. @code{(list (list zfs "module"))}.
+
 @item @code{initrd} (default: @code{base-initrd})
 A procedure that returns an initial RAM disk for the Linux
 kernel.  This field is provided to support low-level 
 customization and
@@ -35516,6 +35526,19 @@ file system, you would write:
   (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
 @end lisp
 
+If a module listed in @code{initrd-modules} is not included in 
the
+Linux-libre kernel, then the location to it must be added to the
+@code{initrd-extra-module-paths} list.  For example, if your root 
file
+system exists on a ZFS pool, then your configuration might look 
like the
+following:
+
+@lisp
+(operating-system
+  ;; @dots{}
+  (initrd-modules (cons "zfs" %base-initrd-modules))
+  (initrd-extra-module-paths (list (list zfs "module"))))
+@end lisp
+
 @defvr {Scheme Variable} %base-initrd-modules
 This is the list of kernel modules included in the initrd by 
 default.
 @end defvr
@@ -35629,13 +35652,15 @@ here is how to use it and customize it 
further.
 @cindex initrd
 @cindex initial RAM disk
 @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
-       [#:linux-modules '()] [#:mapped-devices '()] @
-       [#:keyboard-layout #f] @
+       [#:linux-modules '()] [#:linux-extra-module-paths '()] @
+       [#:mapped-devices '()] [#:keyboard-layout #f] @
        [#:helper-packages '()] [#:qemu-networking? #f] 
        [#:volatile-root? #f]
 Return a derivation that builds a raw initrd.  @var{file-systems} 
 is
 a list of file systems to be mounted by the initrd, possibly in 
 addition to
 the root file system specified on the kernel command line via 
 @option{root}.
 @var{linux-modules} is a list of kernel modules to be loaded at 
 boot time.
+@var{linux-extra-module-paths} is a list of file-like objects to 
be searched
+for kernel modules.
 @var{mapped-devices} is a list of device mappings to realize 
 before
 @var{file-systems} are mounted (@pxref{Mapped Devices}).
 @var{helper-packages} is a list of packages to be copied in the 
 initrd.
@@ -35660,12 +35685,13 @@ to it are lost.
 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
        [#:mapped-devices '()] [#:keyboard-layout #f] @
        [#:qemu-networking? #f] [#:volatile-root? #f] @
-       [#:linux-modules '()]
-Return as a file-like object a generic initrd, with kernel
-modules taken from @var{linux}.  @var{file-systems} is a list of 
 file-systems to be
-mounted by the initrd, possibly in addition to the root file 
 system specified
-on the kernel command line via @option{root}. 
 @var{mapped-devices} is a list of device
-mappings to realize before @var{file-systems} are mounted.
+       [#:linux-modules '()] [#:linux-extra-module-paths '()]
+Return as a file-like object a generic initrd, with kernel 
modules taken
+from @var{linux} and @var{linux-extra-module-paths}. 
@var{file-systems}
+is a list of file-systems to be mounted by the initrd, possibly 
in
+addition to the root file system specified on the kernel command 
line
+via @option{root}.  @var{mapped-devices} is a list of device 
mappings to
+realize before @var{file-systems} are mounted.
 
 When true, @var{keyboard-layout} is a @code{<keyboard-layout>} 
 record denoting
 the desired console keyboard layout.  This is done before 
 @var{mapped-devices}
-- 
2.35.1