[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issues and improvement for `kernel-loadable-modules'
From: |
Brice Waegeneire |
Subject: |
Issues and improvement for `kernel-loadable-modules' |
Date: |
Thu, 26 Mar 2020 14:34:03 +0000 |
User-agent: |
Roundcube Webmail/1.3.8 |
Hello Guix,
Thanks to Danny's work in[0] we have, since a few days, a way for
packages
to provide Linux modules in the system profile. I have been waiting for
such a feature since I packaged `ddcci-driver-linux', which was kind of
useless without it. Using the new field `kernel-loadable-modules' I
stumbled upon three issues.
First I was expecting the packages in `kernel-loadable-modules' to use
the
`kernel' field as their kernel input or to have a simple procedure to do
so. Otherwise you get a “Specified Linux kernel and Linux kernel modules
are not all of the same version”. It makes it more difficult that it
needs
to be to write composable configurations; IOW why would I want to use a
module built with a different kernel that the one I'm specifying in my
`operating-system'.
Second issue, I can't manage to use an inferior as the kernel input for
the
packages in `kernel-loadable-modules'. See the two following
snippets:
--8<---------------cut here---------------start------------->8---
LANGUAGE=C guix system vm kernel-loadable-modules-barbones.scm
Updating channel 'guix' from Git repository at
'https://git.savannah.gnu.org/git/guix.git'...
Backtrace:
1 (primitive-load "/home/bricewge/.config/guix/current/bi…")
In guix/ui.scm:
1894:12 0 (run-guix-command _ . _)
guix/ui.scm:1894:12: In procedure run-guix-command:
In procedure %package-native-inputs-real: Wrong type argument:
#<inferior-package linux-libre@5.4.27 7f90570fc600>
--8<---------------cut here---------------end--------------->8---
Following is `kernel-loadable-modules-barbones.scm':
--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
"591faabd8c93bfb6879910d8a424f0db835066c2"))))
(define my-linux
(let ((inferior (inferior-for-channels channels)))
(first (lookup-inferior-packages inferior "linux-libre"
"4.4.217"))))
;; ;; NOTE It is already in master
;; (define operating-system-kernel-loadable-modules
;; (@@ (gnu system) operating-system-kernel-loadable-modules))
(define os
(operating-system
(host-name "komputilo")
(timezone "Europe/Berlin")
(locale "en_US.utf8")
(bootloader (bootloader-configuration
(bootloader grub-bootloader)
(target "/dev/sdX")))
(file-systems (cons (file-system
(device (file-system-label "my-root"))
(mount-point "/")
(type "ext4"))
%base-file-systems))
(kernel-loadable-modules (list ddcci-driver-linux))))
(operating-system
(inherit os)
(kernel my-linux)
(kernel-loadable-modules
(map (lambda (module)
(package/inherit module
(arguments
(ensure-keyword-arguments
(package-arguments module)
;; `(#:linux ,(specification->package
"linux@4.4.217")) ; NOTE It should works
`(#:linux ,my-linux) ; NOTE That's issue #2
))))
(operating-system-kernel-loadable-modules os))))
--8<---------------cut here---------------end--------------->8---
And last issue, we are missing a service to load module manually when
they
can't be auto-loaded as it's the case with `ddcci`[1]. I have managed to
solve this one by writing my first service
`load-kernel-modules-service'.
What can I improve before submitting it as a patch -- except the missing
documentation?
--8<---------------cut here---------------start------------->8---
(define-record-type* <load-kernel-modules-configuration>
load-kernel-modules-configuration make-load-kernel-modules-configuration
load-kernel-modules-configuration? (modules
load-kernel-modules-configuration-modules ; list of strings (default
'())))
(define load-kernel-modules-shepherd-service
(match-lambda
(($ <load-kernel-modules-configuration> modules)
(list
(shepherd-service
(documentation "Load kernel modules.")
(provision '(load-kernel-modules))
(respawn? #f)
(one-shot? #t)
(start
#~(lambda _
(zero? (system* #$(file-append kmod "/bin/modprobe")
#$@modules)))))))))
(define load-kernel-modules-service-type
(service-type
(name 'load-kernel-modules)
(description "Load kernel modules.")
(extensions
(list
(service-extension shepherd-root-service-type
load-kernel-modules-shepherd-service)))
(compose concatenate)
(extend (lambda (config modules)
(load-kernel-modules-configuration
(inherit config)
(modules (append
(load-kernel-modules-configuration-modules
config)
modules)))))
(default-value (load-kernel-modules-configuration))))
(define* (load-kernel-modules-service modules)
"Return a service that loads kernel MODULES."
(service load-kernel-modules-service-type
(load-kernel-modules-configuration
(modules modules))))
--8<---------------cut here---------------end--------------->8---
[0]: https://issues.guix.info/issue/37868
[1]:
https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux#ddcci-bus-driver
Brice.
- Issues and improvement for `kernel-loadable-modules',
Brice Waegeneire <=