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

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 16 Feb 2025 16:31:53 +0900

Hi Morgan, Brian and all,

Morgan Arnold <[email-masked]> writes:

> From: Brian Cully <[email-masked]>
>
> With this patch, modules for ‘initrd-modules’ will not only be searched for in
> the in-tree Linux modules, but also any additional modules specified in
> ‘kernel-loadable-modules’.
>
> * gnu/build/linux-modules.scm (find-module-file): change DIRECTORY argument to
> DIRECTORIES. Now takes a list of directories to search, rather than a single
> one.
> * gnu/system/linux-initrd.scm (flat-linux-module-directory): change LINUX
> argument to PACKAGES. Now contains a list of file-likes to search for modules.
> (raw-initrd): Add LINUX-EXTRA-MODULE-DIRECTORIES keyword argument. Pass it
> to (flat-linux-module-directory) along with the selected LINUX package.
> (base-initrd): Add LINUX-EXTRA-MODULE-DIRECTORIES keyword argument. Pass it
> to (raw-initrd).
> * gnu/system.scm (operating-system-initrd-file): pass in operating system
> definition's kernel-loadable-modules into (make-initrd) as
> LINUX-EXTRA-MODULE-DIRECTORIES.

This change looks reasonable to me, *if* we can make the possible
copyright violation fix that Morgan is working on work correctly.  I've
applied it locally and made the following small changes, also
normalizing the commit message a bit and squashing the documentation
change along the actual change commit:

--8<---------------cut here---------------start------------->8---
modified   doc/guix.texi
@@ -43414,11 +43414,11 @@ Initial RAM Disk
 @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
+Linux-libre kernel, then its location must be provided via the
 @code{kernel-loadable-modules} list.
 
-For example, if you need the driver for a Realtek RTL8821CE wireless
-network adapter for mounting the root filesystem over NFS, your
+As an example, if you need the driver for a Realtek RTL8821CE wireless
+network adapter for mounting the root file system over NFS, your
 configuration might include the following:
 
 @lisp
modified   gnu/build/linux-modules.scm
@@ -255,6 +255,9 @@ (define (find-module-file directories module)
 module names usually (always?) use underscores as the inter-word separator,
 whereas file names often, but not always, use hyphens.  Examples:
 \"usb-storage.ko\", \"serpent_generic.ko\"."
+  (define directories (if pair? directories
+                          directories
+                          (list directories))) ;for backward compatibility
   (define names
     ;; List of possible file names.  XXX: It would of course be cleaner to
     ;; have a database that maps module names to file names and vice versa,
@@ -270,7 +273,7 @@ (define (find-module-file directories module)
 
   (match (append-map (lambda (directory)
                        (find-files directory
-                                   (lambda (file _stat)
+                                   (lambda (file _)
                                      (member (strip-extension
                                               (basename file))
                                              names))))
modified   gnu/system/linux-initrd.scm
@@ -128,10 +128,9 @@ (define (flat-linux-module-directory packages modules)
                              (guix build utils))))
 
   (define package-inputs
-    (map (lambda (p)
-           (match p
-             ((p o) (gexp-input p o))
-             (p     (gexp-input p "out"))))
+    (map (match-lambda
+           ((p o) (gexp-input p o))
+           (p     (gexp-input p "out")))
          packages))
 
   (define build-exp
--8<---------------cut here---------------end--------------->8---

I'll now take a look at the initrd substitutability issue/potential fix
from Morgan.

-- 
Thanks,
Maxim