Subject: bug#40272: linux-module-build-system don't support an inferior package as a kernel

From: Brice Waegeneire <[email-masked]>
Date: Sun, 01 Aug 2021 17:30:31 +0200

Brice Waegeneire <[email-masked]> writes:

> Message Body
> Hello,
>
> The linux-module-build-system crash when using an inferior package as 
> the
> kernel. I have first reported the issue in the second part of[0] and
> latter, reading[1] made me realize that the root cause was in `(guix
> `build-system linux-module)' and not directly related to the
> `kernel-loadable-modules' field.
>
> I tried fixing it myself but (guix inferior) seems to be missing some
> important procedures so I can manage to do it by myself - I don't have 
> the
> skills to modify that part of the code base. A way to make a package by
> inheriting from a inferior-package would greatly help because
> `make-linux-module-builder' assume that it's argument is straight 
> forward
> package.

Hello Guix,

Gentle bump.

The core of this issue is that a package can't depend on a
<inferior-package> because build systems assume the inputs are
<package>.  Having a procedure 'inferior-package->package' would solve
it, but I'm guessing this isn't possible.

Here is an updated package file to reproduce the issue:

--8<---------------cut here---------------start------------->8---
(use-modules (gnu)
             (gnu system)
             (srfi srfi-1)
             (guix inferior)
             (guix utils)
             (guix packages)
             (guix channels))
(use-package-modules linux)

(define channels
  (list (channel
         (name 'guix)
         (url "https://git.savannah.gnu.org/git/guix.git")
         (commit "6886c4960dd4d8913113ae0330cd8b2d27947a57"))))

(define my-linux
  (let ((inferior (inferior-for-channels channels)))
    (first (lookup-inferior-packages inferior "linux-libre"
                                     "5.12"))))

(package/inherit ddcci-driver-linux
  (arguments
   (ensure-keyword-arguments
    (package-arguments ddcci-driver-linux)

    ;; It works!
    ;; `(#:linux ,(specification->package
    ;;             "[email-masked]"))

    ;; It doesn't work...
    `(#:linux ,my-linux)

    )))
--8<---------------cut here---------------end--------------->8---

Here is the backtrace outputed when building the package:

--8<---------------cut here---------------start------------->8---
$ COLUMNS=999 guix build -f ./40272.scm
Backtrace:
In guix/ui.scm:
    463:3 19 (_)
In ice-9/boot-9.scm:
  1747:15 18 (with-exception-handler #<procedure 7f4ddef9c720 at ice-9/boot-9.scm:1831:7 (exn)> _ #:unwind? _ #:unwind-for-type _)
  1752:10 17 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In guix/ui.scm:
    450:6 16 (_)
In guix/scripts/build.scm:
    608:5 15 (_)
In srfi/srfi-1.scm:
   673:15 14 (append-map #<procedure 7f4df6f491c0 at guix/scripts/build.scm:608:17 (system)> ("x86_64-linux"))
   586:17 13 (map1 ("x86_64-linux"))
In guix/scripts/build.scm:
   610:20 12 (_ _)
In guix/store.scm:
   1362:4 11 (map/accumulate-builds #<store-connection 256.99 7f4deefe2460> _ _)
In srfi/srfi-1.scm:
   586:17 10 (map1 (#<package [email-masked] /home/bricewge/project/guix-config/40272.scm:21 7f4de10d3d20>))
In guix/store.scm:
   1320:8  9 (call-with-build-handler #<procedure build-accumulator (continue store things mode)> _)
In guix/scripts/build.scm:
   569:18  8 (_ _)
In guix/packages.scm:
  1177:16  7 (package-derivation _ #<package [email-masked] /home/bricewge/project/guix-config/40272.scm:21 7f4de10d3d20> _ #:graft? _)
  1494:22  6 (thunk)
  1177:16  5 (package->bag _ _ _ #:graft? _)
  1279:21  4 (thunk)
In guix/build-system/linux-module.scm:
   132:22  3 (lower "ddcci-driver-linux-0.3.3" #:source _ #:inputs _ #:native-inputs _ #:outputs _ #:system _ #:target _ #:linux _ . _)
In ice-9/boot-9.scm:
  1685:16  2 (raise-exception _ #:continuable? _)
  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 %package-native-inputs-real: Wrong type argument: #<inferior-package [email-masked] 7f4ddef23bd0>
--8<---------------cut here---------------end--------------->8---

Issue #48082¹ is probably linked with that one but I couldn't reproduce
it.

¹ https://issues.guix.gnu.org/48082

Cheers,
- Brice