Subject: Re: bug#70239: (operating-system) structure requires a kernel

From: Ludovic Courtès <[email-masked]>
Date: Mon, 08 Apr 2024 14:28:58 +0200

Hi,

Tomas Volf <[email-masked]> skribis:

>     (operating-system
>       (host-name "guix")
>       ;; Servers usually use UTC regardless of the location.
>       (timezone "Etc/UTC")
>       (locale "en_US.utf8")
>       (firmware '())
>       (initrd-modules '())
>     ;  (kernel %ct-dummy-kernel)
>     (kernel #f)

[...]

>     In gnu/services.scm:
>       1031:29  7 (linux-builder-configuration->system-entry _)
>     In guix/profiles.scm:
>         439:4  6 (packages->manifest _)
>     In srfi/srfi-1.scm:
>        586:17  5 (map1 (#f))
>     In guix/inferior.scm:
>         549:2  4 (loop #f "out" #<promise #<procedure 7f8c96627f98 at gu…>)
>         529:4  3 (inferior-package-input-field #f _)
>        473:18  2 (inferior-package-field #f (compose (lambda (#) (…)) #))
>     In ice-9/boot-9.scm:
>       1685:16  1 (raise-exception _ #:continuable? _)
>       1685:16  0 (raise-exception _ #:continuable? _)
>
>     ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>     In procedure struct-vtable: Wrong type argument in position 1 (expecting struct): #f

Indeed, ‘linux-builder-configuration->system-entry’ is not prepared for
that, but we can fix it.

> The (kernel (plain-file "fake-kernel" "")) leads to a different error:
>
>     building /gnu/store/idy2sylx9zbvphzlqvhnldjvg242hd2a-linux-modules.drv...
>     find-files: /gnu/store/jfcbq6djya5pi54yhpvzj66r18h4mp09-dummy-kernel-1/lib/modules: Not a directory
>     Backtrace:
>                4 (primitive-load "/gnu/store/sckm34nzvmkcynhgn6zs5aq6xfs?")
>     In ice-9/eval.scm:
>         619:8  3 (_ #f)
>        626:19  2 (_ #<directory (guile-user) 7ffff77f7c80>)
>         159:9  1 (_ #<directory (guile-user) 7ffff77f7c80>)
>     In unknown file:
>                0 (car ())
>
>     ERROR: In procedure car:
>     In procedure car: Wrong type (expecting pair): ()

I believe this one is a regression introduced in
8f8ec56052766aa5105d672b77ad9eaca5c1ab3c.  I believe this is fixed by
this patch:

diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 561cfe2fd0..40ff2dc808 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -134,18 +134,23 @@ (define (flat-linux-module-directory linux modules)
                          (guix build utils)
                          (rnrs io ports)
                          (srfi srfi-1)
-                         (srfi srfi-26))
+                         (srfi srfi-26)
+                         (ice-9 match))
 
             (define module-dir
               (string-append #$linux "/lib/modules"))
 
             (define builtin-modules
-              (call-with-input-file
-                  (first (find-files module-dir "modules.builtin$"))
-                (lambda (port)
-                  (map file-name->module-name
-                       (string-tokenize
-                        (get-string-all port))))))
+              (match (find-files module-dir (lambda (file stat)
+                                              (string=? (basename file)
+                                                        "modules.builtin")))
+                ((file . _)
+                 (call-with-input-file file
+                   (lambda (port)
+                     (map file-name->module-name
+                          (string-tokenize (get-string-all port))))))
+                (_
+                 '())))
 
             (define modules-to-lookup
               (lset-difference string=? '#$modules builtin-modules))

Could you confirm?

> I think it would be best to just support (kernel #f) for container deployments,
> since that would simplify it and keep it manageable.

Yes, let’s do that too.

Thanks,
Ludo’.