* [bug#42193] [WIP 1/6] services: simulated-wifi: Use 'kernel-module-loader'.
2020-07-04 18:52 [WIP 0/6] Add kernel-module-configuration service Brice Waegeneire
@ 2020-07-04 18:54 ` Brice Waegeneire
2020-07-04 18:54 ` Brice Waegeneire
` (5 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-04 18:54 UTC (permalink / raw)
To: 42193
* gnu/services/networking.scm (simulated-wifi-shepherd-services):
Change 'mac-simulation-module' service to use 'kernel-module-loader'.
---
gnu/services/networking.scm | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 348dc369d8..353fdce2bb 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -13,6 +13,7 @@
;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2019 Sou Bunnbu <iyzsong@member.fsf.org>
;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -33,6 +34,7 @@
#:use-module (gnu services)
#:use-module (gnu services base)
#:use-module (gnu services configuration)
+ #:use-module (gnu services linux)
#:use-module (gnu services shepherd)
#:use-module (gnu services dbus)
#:use-module (gnu system shadow)
@@ -1442,10 +1444,10 @@ simulation."
(append (hostapd-shepherd-services config
#:requirement
'(unblocked-wifi
- mac-simulation-module))
+ kernel-module-loader))
(list (shepherd-service
(provision '(unblocked-wifi))
- (requirement '(file-systems mac-simulation-module))
+ (requirement '(file-systems kernel-module-loader))
(documentation
"Unblock WiFi devices for use by mac80211_hwsim.")
(start #~(lambda _
@@ -1453,21 +1455,6 @@ simulation."
"unblock" "0")
(invoke #$(file-append util-linux "/sbin/rfkill")
"unblock" "1")))
- (one-shot? #t))
- (shepherd-service
- (provision '(mac-simulation-module))
- (requirement '(file-systems))
- (modules '((guix build utils)))
- (documentation
- "Load the mac80211_hwsim Linux kernel module.")
- (start (with-imported-modules '((guix build utils))
- #~(lambda _
- ;; XXX: We can't use 'load-linux-module*' here because it
- ;; expects a flat module directory.
- (setenv "LINUX_MODULE_DIRECTORY"
- "/run/booted-system/kernel/lib/modules")
- (invoke #$(file-append kmod "/bin/modprobe")
- "mac80211_hwsim"))))
(one-shot? #t)))))
(define simulated-wifi-service-type
@@ -1475,7 +1462,9 @@ simulation."
(name 'simulated-wifi)
(extensions
(list (service-extension shepherd-root-service-type
- simulated-wifi-shepherd-services)))
+ simulated-wifi-shepherd-services)
+ (service-extension kernel-module-loader-service-type
+ (const '("mac80211_hwsim")))))
(default-value (hostapd-configuration
(interface "wlan1")
(ssid "Test Network")))
--
2.26.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 1/6] services: simulated-wifi: Use 'kernel-module-loader'.
2020-07-04 18:52 [WIP 0/6] Add kernel-module-configuration service Brice Waegeneire
2020-07-04 18:54 ` [bug#42193] [WIP 1/6] services: simulated-wifi: Use 'kernel-module-loader' Brice Waegeneire
@ 2020-07-04 18:54 ` Brice Waegeneire
2020-07-06 11:08 ` Danny Milosavljevic
2020-07-04 18:54 ` [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type' Brice Waegeneire
` (4 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-04 18:54 UTC (permalink / raw)
To: 42193
* gnu/services/networking.scm (simulated-wifi-shepherd-services):
Change 'mac-simulation-module' service to use 'kernel-module-loader'.
---
gnu/services/networking.scm | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 348dc369d8..353fdce2bb 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -13,6 +13,7 @@
;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2019 Sou Bunnbu <iyzsong@member.fsf.org>
;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -33,6 +34,7 @@
#:use-module (gnu services)
#:use-module (gnu services base)
#:use-module (gnu services configuration)
+ #:use-module (gnu services linux)
#:use-module (gnu services shepherd)
#:use-module (gnu services dbus)
#:use-module (gnu system shadow)
@@ -1442,10 +1444,10 @@ simulation."
(append (hostapd-shepherd-services config
#:requirement
'(unblocked-wifi
- mac-simulation-module))
+ kernel-module-loader))
(list (shepherd-service
(provision '(unblocked-wifi))
- (requirement '(file-systems mac-simulation-module))
+ (requirement '(file-systems kernel-module-loader))
(documentation
"Unblock WiFi devices for use by mac80211_hwsim.")
(start #~(lambda _
@@ -1453,21 +1455,6 @@ simulation."
"unblock" "0")
(invoke #$(file-append util-linux "/sbin/rfkill")
"unblock" "1")))
- (one-shot? #t))
- (shepherd-service
- (provision '(mac-simulation-module))
- (requirement '(file-systems))
- (modules '((guix build utils)))
- (documentation
- "Load the mac80211_hwsim Linux kernel module.")
- (start (with-imported-modules '((guix build utils))
- #~(lambda _
- ;; XXX: We can't use 'load-linux-module*' here because it
- ;; expects a flat module directory.
- (setenv "LINUX_MODULE_DIRECTORY"
- "/run/booted-system/kernel/lib/modules")
- (invoke #$(file-append kmod "/bin/modprobe")
- "mac80211_hwsim"))))
(one-shot? #t)))))
(define simulated-wifi-service-type
@@ -1475,7 +1462,9 @@ simulation."
(name 'simulated-wifi)
(extensions
(list (service-extension shepherd-root-service-type
- simulated-wifi-shepherd-services)))
+ simulated-wifi-shepherd-services)
+ (service-extension kernel-module-loader-service-type
+ (const '("mac80211_hwsim")))))
(default-value (hostapd-configuration
(interface "wlan1")
(ssid "Test Network")))
--
2.26.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type'.
2020-07-04 18:52 [WIP 0/6] Add kernel-module-configuration service Brice Waegeneire
2020-07-04 18:54 ` [bug#42193] [WIP 1/6] services: simulated-wifi: Use 'kernel-module-loader' Brice Waegeneire
2020-07-04 18:54 ` Brice Waegeneire
@ 2020-07-04 18:54 ` Brice Waegeneire
2020-07-08 11:29 ` pelzflorian (Florian Pelz)
2020-07-04 18:54 ` [bug#42193] [WIP 3/6] services: Add 'modprobe-service-type' Brice Waegeneire
` (3 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-04 18:54 UTC (permalink / raw)
To: 42193
* gnu/system.scm (operating-system-default-essential-services): Use
'kernel-profile-service-type'.
(operating-system-default-essential-services): Remove kernel profile.
(package-for-kernel): Move it to …
* gnu/services.scm (package-for-kernel): … here.
(kernel-profile-configuration,
kernel-profile-configuration->profile-entry,
kernel-profile-service-type): New variables.
* gnu/tests/linux-modules.scm (run-loadable-kernel-modules-test): Test
'kernel-profile-service-type'.
---
gnu/services.scm | 66 ++++++++++++++++++++++++++++++++++++-
gnu/system.scm | 14 +++-----
gnu/tests/linux-modules.scm | 10 +++---
3 files changed, 75 insertions(+), 15 deletions(-)
diff --git a/gnu/services.scm b/gnu/services.scm
index f6dc56d940..b5ec222207 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -30,9 +31,11 @@
#:use-module (guix describe)
#:use-module (guix sets)
#:use-module (guix ui)
- #:use-module ((guix utils) #:select (source-properties->location))
+ #:use-module ((guix utils) #:select (source-properties->location
+ substitute-keyword-arguments))
#:autoload (guix openpgp) (openpgp-format-fingerprint)
#:use-module (guix modules)
+ #:use-module (guix packages)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages hurd)
@@ -105,6 +108,12 @@
firmware-service-type
gc-root-service-type
+ kernel-profile-configuration
+ kernel-profile-configuration?
+ kernel-profile-configuration-kernel
+ kernel-profile-configuration-packages
+ kernel-profile-service-type
+
%boot-service
%activation-service
etc-service))
@@ -474,6 +483,61 @@ channels in use and CONFIG-FILE, if it is true."
itself: the channels used when building the system, and its configuration
file, when available.")))
+\f
+;;;
+;;; Kernel profile.
+;;;
+
+(define-record-type* <kernel-profile-configuration>
+ kernel-profile-configuration make-kernel-profile-configuration
+ kernel-profile-configuration?
+ (kernel kernel-profile-configuration-kernel) ; <package>
+ (packages kernel-profile-configuration-packages ; list of <package>
+ (default '())))
+
+(define (package-for-kernel target-kernel module-package)
+ "Return a package like MODULE-PACKAGE, adapted for TARGET-KERNEL, if
+possible (that is if there's a LINUX keyword argument in the build system)."
+ (package
+ (inherit module-package)
+ (arguments
+ (substitute-keyword-arguments (package-arguments module-package)
+ ((#:linux kernel #f)
+ target-kernel)))))
+
+(define (kernel-profile-configuration->profile-entry config)
+ "Return a system entry for the kernel profile CONFIG."
+ (let* ((kernel (kernel-profile-configuration-kernel config))
+ (packages (map (lambda (package)
+ (if (package? package)
+ (package-for-kernel kernel
+ package)
+ package))
+ (kernel-profile-configuration-packages config))))
+ (with-monad %store-monad
+ (return `(("kernel"
+ ,(profile
+ (content (packages->manifest
+ (cons kernel
+ (delete-duplicates packages eq?))))
+ (hooks (list linux-module-database)))))))))
+
+(define kernel-profile-service-type
+ (service-type (name 'kernel-profile)
+ (description "This is the @dfn{kernel profile}, available as
+@file{/run/current-system/kernel}.")
+ (extensions
+ (list (service-extension
+ system-service-type
+ kernel-profile-configuration->profile-entry)))
+ (compose concatenate)
+ (extend (lambda (config additional-packages)
+ (match-record config <kernel-profile-configuration>
+ (kernel packages)
+ (kernel-profile-configuration
+ (kernel kernel) ;the kernel package to use
+ (packages (append packages additional-packages))))))))
+
\f
;;;
;;; Cleanup.
diff --git a/gnu/system.scm b/gnu/system.scm
index bfbcb6fbdd..ff374dddda 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -511,16 +511,6 @@ OS."
(file-append (operating-system-kernel os)
"/" (system-linux-image-file-name))))
-(define (package-for-kernel target-kernel module-package)
- "Return a package like MODULE-PACKAGE, adapted for TARGET-KERNEL, if
-possible (that is if there's a LINUX keyword argument in the build system)."
- (package
- (inherit module-package)
- (arguments
- (substitute-keyword-arguments (package-arguments module-package)
- ((#:linux kernel #f)
- target-kernel)))))
-
(define %default-modprobe-blacklist
;; List of kernel modules to blacklist by default.
'("usbmouse" ;races with bcm5974, see <https://bugs.gnu.org/35574>
@@ -574,6 +564,10 @@ bookkeeping."
(host-name (host-name-service (operating-system-host-name os)))
(entries (operating-system-directory-base-entries os)))
(cons* (service system-service-type entries)
+ (service kernel-profile-service-type
+ (kernel-profile-configuration
+ (kernel (operating-system-kernel os))
+ (packages (operating-system-kernel-loadable-modules os))))
%boot-service
;; %SHEPHERD-ROOT-SERVICE must come last so that the gexp that
diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scm
index 953b132ef7..22e9a0c65c 100644
--- a/gnu/tests/linux-modules.scm
+++ b/gnu/tests/linux-modules.scm
@@ -73,10 +73,12 @@ are loaded in memory."
(marionette-operating-system
(operating-system
(inherit (simple-operating-system))
- (services (cons (service kernel-module-loader-service-type module-names)
- (operating-system-user-services
- (simple-operating-system))))
- (kernel-loadable-modules module-packages))
+ (services (cons* (service kernel-module-loader-service-type module-names)
+ (simple-service 'kernel-module-packages
+ kernel-profile-service-type
+ module-packages)
+ (operating-system-user-services
+ (simple-operating-system)))))
#:imported-modules '((guix combinators))))
(define vm (virtual-machine os))
(define (test script)
--
2.26.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type'.
2020-07-04 18:54 ` [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type' Brice Waegeneire
@ 2020-07-08 11:29 ` pelzflorian (Florian Pelz)
2020-07-08 16:22 ` Brice Waegeneire
0 siblings, 1 reply; 17+ messages in thread
From: pelzflorian (Florian Pelz) @ 2020-07-08 11:29 UTC (permalink / raw)
To: Brice Waegeneire; +Cc: 42193
Thank you for your work!
After I apply this kernel profile patch, I get an error:
florian@florianmacbook ~/git/guix [env]$ ./pre-inst-env guix system disk-image --file-system-type=iso9660 gnu/system/install.scm
substitute: Liste der Substitute von „https://ci.guix.gnu.org“ wird aktualisiert … 100.0%
The following derivations will be built:
/gnu/store/l51h17zylvjmapvcpdmmqmvrylv8b2cb-iso9660-image.drv
/gnu/store/mhdkqnh4iri5rk1ayqd3xlw04q86zj29-grub.cfg.drv
/gnu/store/xvgn60irpzzdwvk30lqpsj2hh81h8jyh-system.drv
/gnu/store/6y2r0ab5jcflbajd6843v9g1j0v9xrzj-gc-roots.drv
/gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv
building /gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv...
|builder for `/gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv' failed with exit code 1
build of /gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv failed
View build log at '/var/log/guix/drvs/15/6m13243bcn2429swq8brp2qmfifi3b-system.drv.bz2'.
cannot build derivation `/gnu/store/6y2r0ab5jcflbajd6843v9g1j0v9xrzj-gc-roots.drv': 1 dependencies couldn't be built
cannot build derivation `/gnu/store/xvgn60irpzzdwvk30lqpsj2hh81h8jyh-system.drv': 1 dependencies couldn't be built
cannot build derivation `/gnu/store/l51h17zylvjmapvcpdmmqmvrylv8b2cb-iso9660-image.drv': 1 dependencies couldn't be built
guix system: error: build of `/gnu/store/l51h17zylvjmapvcpdmmqmvrylv8b2cb-iso9660-image.drv' failed
florian@florianmacbook ~/git/guix [env]$ bzcat /var/log/guix/drvs/15/6m13243bcn2429swq8brp2qmfifi3b-system.drv.bz2
Backtrace:
1 (primitive-load "/gnu/store/59nx7bbflcqzavwsjj3wkq3lwfb?")
0 (symlink "/gnu/store/86xgvarqwir47c16x6crx0jra5dgzr62-?" ?)
ERROR: In procedure symlink:
In procedure symlink: File exists
I have no idea where this comes from but I hope you can reproduce the error.
In general, I would be happy to use the kernel module configuration
service for replacing the uvesafb-service-type by something like
(simple-service 'uvesafb-module
kernel-module-configuration-service-type
(list (kernel-module
(name "uvesafb")
(options
(list #~(string-append "v86d=" #$v86d "/sbin/v86d")
"mode_option=1024x768\n"))))))))
Even better would be if it were possible to detect the resolution to
use for uvesafb at runtime before the module is loaded. Is it
possible to execute as root at runtime before modprobe a script like
testvbe.scm attached to the first message from
<https://issues.guix.gnu.org/40538#0> to compute the mode_option to
use?
Regards,
Florian
^ permalink raw reply [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type'.
2020-07-08 11:29 ` pelzflorian (Florian Pelz)
@ 2020-07-08 16:22 ` Brice Waegeneire
2020-07-11 17:30 ` pelzflorian (Florian Pelz)
0 siblings, 1 reply; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-08 16:22 UTC (permalink / raw)
To: pelzflorian (Florian Pelz); +Cc: 42193
On 2020-07-08 11:29, pelzflorian (Florian Pelz) wrote:
> Thank you for your work!
Note that it's not finished yet.
> After I apply this kernel profile patch, I get an error:
>
> florian@florianmacbook ~/git/guix [env]$ ./pre-inst-env guix system
> disk-image --file-system-type=iso9660 gnu/system/install.scm
> substitute: Liste der Substitute von „https://ci.guix.gnu.org“ wird
> aktualisiert … 100.0%
> The following derivations will be built:
> /gnu/store/l51h17zylvjmapvcpdmmqmvrylv8b2cb-iso9660-image.drv
> /gnu/store/mhdkqnh4iri5rk1ayqd3xlw04q86zj29-grub.cfg.drv
> /gnu/store/xvgn60irpzzdwvk30lqpsj2hh81h8jyh-system.drv
> /gnu/store/6y2r0ab5jcflbajd6843v9g1j0v9xrzj-gc-roots.drv
> /gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv
> building /gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv...
> |builder for `/gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv'
> failed with exit code 1
> build of /gnu/store/156m13243bcn2429swq8brp2qmfifi3b-system.drv failed
> View build log at
> '/var/log/guix/drvs/15/6m13243bcn2429swq8brp2qmfifi3b-system.drv.bz2'.
> cannot build derivation
> `/gnu/store/6y2r0ab5jcflbajd6843v9g1j0v9xrzj-gc-roots.drv': 1
> dependencies couldn't be built
> cannot build derivation
> `/gnu/store/xvgn60irpzzdwvk30lqpsj2hh81h8jyh-system.drv': 1
> dependencies couldn't be built
> cannot build derivation
> `/gnu/store/l51h17zylvjmapvcpdmmqmvrylv8b2cb-iso9660-image.drv': 1
> dependencies couldn't be built
> guix system: error: build of
> `/gnu/store/l51h17zylvjmapvcpdmmqmvrylv8b2cb-iso9660-image.drv' failed
> florian@florianmacbook ~/git/guix [env]$ bzcat
> /var/log/guix/drvs/15/6m13243bcn2429swq8brp2qmfifi3b-system.drv.bz2
> Backtrace:
> 1 (primitive-load "/gnu/store/59nx7bbflcqzavwsjj3wkq3lwfb?")
> 0 (symlink "/gnu/store/86xgvarqwir47c16x6crx0jra5dgzr62-?"
> ?)
>
> ERROR: In procedure symlink:
> In procedure symlink: File exists
>
>
> I have no idea where this comes from but I hope you can reproduce the
> error.
Unfortunately I can't, it build successfully for me when applied on top
of
6f3ede9ae2b2268181ebc0ca3764d865bd06bd63. You probably just need to
clean
your Guix repository and rebuild it from scratch
> In general, I would be happy to use the kernel module configuration
> service for replacing the uvesafb-service-type by something like
>
> (simple-service 'uvesafb-module
> kernel-module-configuration-service-type
> (list (kernel-module
> (name "uvesafb")
> (options
> (list #~(string-append "v86d=" #$v86d
> "/sbin/v86d")
> "mode_option=1024x768\n"))))))))
I think it should work without gexp/ungexp and the "\n".
> Even better would be if it were possible to detect the resolution to
> use for uvesafb at runtime before the module is loaded. Is it
> possible to execute as root at runtime before modprobe a script like
> testvbe.scm attached to the first message from
> <https://issues.guix.gnu.org/40538#0> to compute the mode_option to
> use?
AFAIU it's not possible because service extensions are generated at
build time,
not run time so you can't extend KMCS with a value generated when your
service
is executed. It is a limitation of the service extension paradigm.
A kind of dirty way to achieve what you want would be for KMCS' options
field
to accept an arbitrary configuration path that will be symlinked to,
like
“(options "/var/run/uvesafb/uvesafb.conf")”. That way from uvesafb
service
you generate that modprobe configuration file at run time (before KMCS)
and
so when KMCS run modprobe it's direcotry configuration contains a
symlink
named "uvesafb.conf" which point to "/var/run/uvesafb/uvesafb.conf". But
it doesn't seems Guixy to me.
- Brice
^ permalink raw reply [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type'.
2020-07-08 16:22 ` Brice Waegeneire
@ 2020-07-11 17:30 ` pelzflorian (Florian Pelz)
0 siblings, 0 replies; 17+ messages in thread
From: pelzflorian (Florian Pelz) @ 2020-07-11 17:30 UTC (permalink / raw)
To: Brice Waegeneire; +Cc: 42193
On Wed, Jul 08, 2020 at 04:22:06PM +0000, Brice Waegeneire wrote:
> > After I apply this kernel profile patch, I get an error:
> >
> > florian@florianmacbook ~/git/guix [env]$ ./pre-inst-env guix system
> > disk-image --file-system-type=iso9660 gnu/system/install.scm
> > […]
> > failed with exit code 1
> > […]
> > In procedure symlink: File exists
> >
> >
> > I have no idea where this comes from but I hope you can reproduce the
> > error.
>
> Unfortunately I can't, it build successfully for me when applied on top of
> 6f3ede9ae2b2268181ebc0ca3764d865bd06bd63. You probably just need to clean
> your Guix repository and rebuild it from scratch
I still have the error after pulling current guix (commit f2dce740b2)
and applying your patch.
florian@florianmacbook ~/.config/guix/current/share/guile/site/3.0$ guix system disk-image --file-system-type=iso9660 gnu/system/install.scm
[…]
build of /gnu/store/v9jzdiykyz1rdb1an7jpsfhnnkvx21mq-system.drv failed
View build log at '/var/log/guix/drvs/v9/jzdiykyz1rdb1an7jpsfhnnkvx21mq-system.drv.bz2'.
Indeed /gnu/store/v9jzdiykyz1rdb1an7jpsfhnnkvx21mq-system.drv contains
Derive([("out","/gnu/store/xzavg5awkmbcx556f3a0h329w5ninhyk-system","","")],[("/gnu/store/28zlas3x4ry6q88fgq625ixh40igjws5-guile-3.0.2.drv",["out"]),("/gnu/store/32yj3cnz8rjipd6lw27d08rb272rcmbp-boot.drv",["out"]),("/gnu/store/6iwq8qmqpf9sy84jvbbsd6lwwb05rvlf-etc.drv",["out"]),("/gnu/store/8rfp2v0vz8w72621qsr0mr21zgr5f062-profile.drv",["out"]),("/gnu/store/92sqsa639hl3ixy6ryys38xha7mgkyb0-profile.drv",["out"]),("/gnu/store/ca0g4jfdqx4fhsp67jr2ra17sdwajczc-parameters.drv",["out"]),("/gnu/store/fi6hy331yp7pn03zhlxavdd4d9kv6l6i-raw-initrd.drv",["out"]),("/gnu/store/i3fx8c0k6yna92cf9h7r57amdjzii7l3-locale-multiple-versions.drv",["out"]),("/gnu/store/zcz3jhx84q3zmz37wddwlfk2w3rnn5fc-module-import-compiled.drv",["out"])],["/gnu/store/ah60schb9jlzx12jzi6v872q3j099afi-system-builder","/gnu/store/xv5ylv9hxvs1wraw375b5g9jwy57vs8p-module-import"],"x86_64-linux","/gnu/store/0m0vd873jp61lcm4xa3ljdgx381qa782-guile-3.0.2/bin/guile",["--no-auto-compile","-L","/gnu/store/xv5ylv9hxvs1wraw375b5g9jwy57vs8p-module-import","-C","/gnu/store/08da6i38fzn9g36gyq443k03f84nk8rk-module-import-compiled","/gnu/store/ah60schb9jlzx12jzi6v872q3j099afi-system-builder"],[("out","/gnu/store/xzavg5awkmbcx556f3a0h329w5ninhyk-system"),("preferLocalBuild","1")])
and /gnu/store/ah60schb9jlzx12jzi6v872q3j099afi-system-builder
contains (with indentation added by me):
(begin (use-modules (guix build utils))
(mkdir ((@ (guile) getenv) "out"))
(chdir ((@ (guile) getenv) "out"))
(begin (stat "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile")
(mkdir-p (dirname "kernel"))
(symlink "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile" "kernel"))
(begin (stat "/gnu/store/7wjapypmzz4n93rwrnrrqwalwg8hhh3h-parameters")
(mkdir-p (dirname "parameters"))
(symlink "/gnu/store/7wjapypmzz4n93rwrnrrqwalwg8hhh3h-parameters" "parameters"))
(begin (stat "/gnu/store/j27l3k8zjg9gn9j04y90gsjrqsryjapw-raw-initrd/initrd.cpio.gz")
(mkdir-p (dirname "initrd"))
(symlink "/gnu/store/j27l3k8zjg9gn9j04y90gsjrqsryjapw-raw-initrd/initrd.cpio.gz" "initrd"))
(begin (stat "/gnu/store/bhnyk7bpzlzna28njkx21dd3940m1m4a-locale-multiple-versions")
(mkdir-p (dirname "locale"))
(symlink "/gnu/store/bhnyk7bpzlzna28njkx21dd3940m1m4a-locale-multiple-versions" "locale"))
(begin (stat "/gnu/store/24irabcnv3pn2mpx4cjrggmlvn30k053-profile")
(mkdir-p (dirname "profile"))
(symlink "/gnu/store/24irabcnv3pn2mpx4cjrggmlvn30k053-profile" "profile"))
(begin (stat "/gnu/store/z9jm8d8rrrpq19y1pmahpp73ja5ydw6h-etc")
(mkdir-p (dirname "etc"))
(symlink "/gnu/store/z9jm8d8rrrpq19y1pmahpp73ja5ydw6h-etc" "etc"))
(begin (stat "/gnu/store/w90vvv7mx8g17i6frd34yvmbfi0nhnl1-boot")
(mkdir-p (dirname "boot"))
(symlink "/gnu/store/w90vvv7mx8g17i6frd34yvmbfi0nhnl1-boot" "boot"))
(begin (stat "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile")
(mkdir-p (dirname "kernel"))
(symlink "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile" "kernel")))
Without your patch I get a
/gnu/store/c74g6pazpx9z5c1jkfi4rn8h42lf36dy-system-builder with only
one "kernel":
(begin (use-modules (guix build utils))
(mkdir ((@ (guile) getenv) "out"))
(chdir ((@ (guile) getenv) "out"))
(begin (stat "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile")
(mkdir-p (dirname "kernel"))
(symlink "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile" "kernel"))
(begin (stat "/gnu/store/7wjapypmzz4n93rwrnrrqwalwg8hhh3h-parameters")
(mkdir-p (dirname "parameters"))
(symlink "/gnu/store/7wjapypmzz4n93rwrnrrqwalwg8hhh3h-parameters" "parameters"))
(begin (stat "/gnu/store/j27l3k8zjg9gn9j04y90gsjrqsryjapw-raw-initrd/initrd.cpio.gz")
(mkdir-p (dirname "initrd"))
(symlink "/gnu/store/j27l3k8zjg9gn9j04y90gsjrqsryjapw-raw-initrd/initrd.cpio.gz" "initrd"))
(begin (stat "/gnu/store/bhnyk7bpzlzna28njkx21dd3940m1m4a-locale-multiple-versions")
(mkdir-p (dirname "locale"))
(symlink "/gnu/store/bhnyk7bpzlzna28njkx21dd3940m1m4a-locale-multiple-versions" "locale"))
(begin (stat "/gnu/store/24irabcnv3pn2mpx4cjrggmlvn30k053-profile")
(mkdir-p (dirname "profile"))
(symlink "/gnu/store/24irabcnv3pn2mpx4cjrggmlvn30k053-profile" "profile"))
(begin (stat "/gnu/store/z9jm8d8rrrpq19y1pmahpp73ja5ydw6h-etc")
(mkdir-p (dirname "etc"))
(symlink "/gnu/store/z9jm8d8rrrpq19y1pmahpp73ja5ydw6h-etc" "etc"))
(begin (stat "/gnu/store/w90vvv7mx8g17i6frd34yvmbfi0nhnl1-boot")
(mkdir-p (dirname "boot"))
(symlink "/gnu/store/w90vvv7mx8g17i6frd34yvmbfi0nhnl1-boot" "boot")))
The diff is only the three lines at the bottom
(begin (stat "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile")
(mkdir-p (dirname "kernel"))
(symlink "/gnu/store/x22lj7pv64cg58dlwsg1q1srqawjbahi-profile" "kernel")))
Regards,
Florian
^ permalink raw reply [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 3/6] services: Add 'modprobe-service-type'.
2020-07-04 18:52 [WIP 0/6] Add kernel-module-configuration service Brice Waegeneire
` (2 preceding siblings ...)
2020-07-04 18:54 ` [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type' Brice Waegeneire
@ 2020-07-04 18:54 ` Brice Waegeneire
2020-07-04 18:54 ` [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service' Brice Waegeneire
` (2 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-04 18:54 UTC (permalink / raw)
To: 42193
* gnu/services.scm (%linux-kernel-activation): Remove
'activate-modprobe' from it.
(%modprobe-wrapper): Move it…
* gnu/services/linux.scm (%modprobe-wrapper): …here and make it a
procedure taking one argument specifying the configuration directory.
(modprobe-service-type, modprobe-environment,
modprobe->activation-gexp): New variables.
* gnu/system.scm (operating-system-default-essential-services): Add
'modprobe-service-type'.
* gnu/system/linux-container.scm (container-essential-services): Add
'modprobe-service-type' to the list of services to be removed.
---
gnu/services.scm | 22 +-------------
gnu/services/linux.scm | 53 +++++++++++++++++++++++++++++++++-
gnu/system.scm | 2 ++
gnu/system/linux-container.scm | 2 ++
4 files changed, 57 insertions(+), 22 deletions(-)
diff --git a/gnu/services.scm b/gnu/services.scm
index b5ec222207..7df9bf9d46 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -654,31 +654,11 @@ ACTIVATION-SCRIPT-TYPE."
;; receives.
(service activation-service-type #t))
-(define %modprobe-wrapper
- ;; Wrapper for the 'modprobe' command that knows where modules live.
- ;;
- ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
- ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
- ;; environment variable is not set---hence the need for this wrapper.
- (let ((modprobe "/run/current-system/profile/bin/modprobe"))
- (program-file "modprobe"
- #~(begin
- (setenv "LINUX_MODULE_DIRECTORY"
- "/run/booted-system/kernel/lib/modules")
- ;; FIXME: Remove this crutch when the patch #40422,
- ;; updating to kmod 27 is merged.
- (setenv "MODPROBE_OPTIONS"
- "-C /etc/modprobe.d")
- (apply execl #$modprobe
- (cons #$modprobe (cdr (command-line))))))))
-
+;; TODO Maybe rename it
(define %linux-kernel-activation
;; Activation of the Linux kernel running on the bare metal (as opposed to
;; running in a container.)
#~(begin
- ;; Tell the kernel to use our 'modprobe' command.
- (activate-modprobe #$%modprobe-wrapper)
-
;; Let users debug their own processes!
(activate-ptrace-attach)))
diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index 12934c2084..c608cc4d8d 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -23,6 +23,7 @@
#:use-module (guix modules)
#:use-module (gnu services)
#:use-module (gnu services shepherd)
+ #:use-module (gnu system pam)
#:use-module (gnu packages linux)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
@@ -42,7 +43,9 @@
earlyoom-configuration-send-notification-command
earlyoom-service-type
- kernel-module-loader-service-type))
+ kernel-module-loader-service-type
+
+ modprobe-service-type))
\f
;;;
@@ -177,3 +180,51 @@ representation."
(compose concatenate)
(extend append)
(default-value '())))
+
+\f
+;;;
+;;; Modprobe service.
+;;;
+
+(define (%modprobe-wrapper directory)
+ "Return a wrapper for modprobe loading configuration files from CONFIG."
+ ;; Wrapper for the 'modprobe' command that knows where modules live.
+ ;;
+ ;; This wrapper is typically invoked by the Linux kernel ('call_modprobe',
+ ;; in kernel/kmod.c), a situation where the 'LINUX_MODULE_DIRECTORY'
+ ;; environment variable is not set---hence the need for this wrapper.
+ (let ((modprobe "/run/current-system/profile/bin/modprobe"))
+ (program-file "modprobe"
+ #~(begin
+ (setenv "LINUX_MODULE_DIRECTORY"
+ "/run/booted-system/kernel/lib/modules")
+ (setenv "MODPROBE_OPTIONS"
+ (string-append "--config=" #$directory))
+ (apply execl #$modprobe
+ (cons #$modprobe (cdr (command-line))))))))
+
+(define (modprobe->activation-gexp configs)
+ "Return a gexp to tell the kernel to use modprobe configured with CONFIGS
+files."
+ (let ((directory (file-union "modprobe.d" configs)))
+ #~(activate-modprobe #$(%modprobe-wrapper directory))))
+
+(define (modprobe-environment configs)
+ (let ((options #~(string-append
+ "--config="
+ #$(file-union "modprobe.d"
+ configs))))
+ `(("MODPROBE_OPTIONS" . ,options))))
+
+(define modprobe-service-type
+ (service-type
+ (name 'modropbe)
+ (description "Tell the kernel to use Guix's 'modprobe'.")
+ (default-value '()) ; list of <file-like>
+ (extensions
+ (list (service-extension activation-service-type
+ modprobe->activation-gexp)
+ (service-extension session-environment-service-type
+ modprobe-environment)))
+ (compose concatenate)
+ (extend append)))
diff --git a/gnu/system.scm b/gnu/system.scm
index ff374dddda..ba9eeb66b8 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -58,6 +58,7 @@
#:use-module (gnu services)
#:use-module (gnu services shepherd)
#:use-module (gnu services base)
+ #:use-module (gnu services linux)
#:use-module (gnu bootloader)
#:use-module (gnu system shadow)
#:use-module (gnu system nss)
@@ -594,6 +595,7 @@ bookkeeping."
(service profile-service-type
(operating-system-packages os))
other-fs
+ (service modprobe-service-type)
(append mappings swaps
;; Add the firmware service.
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm
index c5e2e4bf9c..b8bf88e495 100644
--- a/gnu/system/linux-container.scm
+++ b/gnu/system/linux-container.scm
@@ -31,6 +31,7 @@
#:use-module (gnu build linux-container)
#:use-module (gnu services)
#:use-module (gnu services base)
+ #:use-module (gnu services linux)
#:use-module (gnu services networking)
#:use-module (gnu services shepherd)
#:use-module (gnu system)
@@ -48,6 +49,7 @@ from OS that are needed on the bare metal and not in a container."
(remove (lambda (service)
(memq (service-kind service)
(list (service-kind %linux-bare-metal-service)
+ modprobe-service-type
firmware-service-type
system-service-type)))
(operating-system-default-essential-services os)))
--
2.26.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service'.
2020-07-04 18:52 [WIP 0/6] Add kernel-module-configuration service Brice Waegeneire
` (3 preceding siblings ...)
2020-07-04 18:54 ` [bug#42193] [WIP 3/6] services: Add 'modprobe-service-type' Brice Waegeneire
@ 2020-07-04 18:54 ` Brice Waegeneire
2020-07-06 0:03 ` Danny Milosavljevic
2020-07-17 18:49 ` Danny Milosavljevic
2020-07-04 18:54 ` [bug#42193] [WIP 5/6] WIP services: Add kernel-arguments-service-type Brice Waegeneire
2020-07-04 18:54 ` [bug#42193] [WIP 6/6] WIP services: Add kernel-module-configuration service Brice Waegeneire
6 siblings, 2 replies; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-04 18:54 UTC (permalink / raw)
To: 42193
* gnu/services/linux.scm (kernel-module-loader-shepherd-service): Return
a 'shepherd-service' instead of a list of it.
(kernel-module-loader-service-type): Adjust it.
---
gnu/services/linux.scm | 59 +++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 30 deletions(-)
diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index c608cc4d8d..7ea30a1270 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -140,35 +140,34 @@ representation."
(define kernel-module-loader-shepherd-service
(match-lambda
((and (? list? kernel-modules) ((? string?) ...))
- (list
- (shepherd-service
- (documentation "Load kernel modules.")
- (provision '(kernel-module-loader))
- (requirement '(file-systems))
- (one-shot? #t)
- (modules `((srfi srfi-1)
- (srfi srfi-34)
- (srfi srfi-35)
- (rnrs io ports)
- ,@%default-modules))
- (start
- #~(lambda _
- (cond
- ((null? '#$kernel-modules) #t)
- ((file-exists? "/proc/sys/kernel/modprobe")
- (let ((modprobe (call-with-input-file
- "/proc/sys/kernel/modprobe" get-line)))
- (guard (c ((message-condition? c)
- (format (current-error-port) "~a~%"
- (condition-message c))
- #f))
- (every (lambda (module)
- (invoke/quiet modprobe "--" module))
- '#$kernel-modules))))
- (else
- (format (current-error-port) "error: ~a~%"
- "Kernel is missing loadable module support.")
- #f)))))))))
+ (shepherd-service
+ (documentation "Load kernel modules.")
+ (provision '(kernel-module-loader))
+ (requirement '(file-systems))
+ (one-shot? #t)
+ (modules `((srfi srfi-1)
+ (srfi srfi-34)
+ (srfi srfi-35)
+ (rnrs io ports)
+ ,@%default-modules))
+ (start
+ #~(lambda _
+ (cond
+ ((null? '#$kernel-modules) #t)
+ ((file-exists? "/proc/sys/kernel/modprobe")
+ (let ((modprobe (call-with-input-file
+ "/proc/sys/kernel/modprobe" get-line)))
+ (guard (c ((message-condition? c)
+ (format (current-error-port) "~a~%"
+ (condition-message c))
+ #f))
+ (every (lambda (module)
+ (invoke/quiet modprobe "--" module))
+ '#$kernel-modules))))
+ (else
+ (format (current-error-port) "error: ~a~%"
+ "Kernel is missing loadable module support.")
+ #f))))))))
(define kernel-module-loader-service-type
(service-type
@@ -176,7 +175,7 @@ representation."
(description "Load kernel modules.")
(extensions
(list (service-extension shepherd-root-service-type
- kernel-module-loader-shepherd-service)))
+ (compose list kernel-module-loader-shepherd-service))))
(compose concatenate)
(extend append)
(default-value '())))
--
2.26.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service'.
2020-07-04 18:54 ` [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service' Brice Waegeneire
@ 2020-07-06 0:03 ` Danny Milosavljevic
2020-07-06 10:01 ` Brice Waegeneire
2020-07-17 18:49 ` Danny Milosavljevic
1 sibling, 1 reply; 17+ messages in thread
From: Danny Milosavljevic @ 2020-07-06 0:03 UTC (permalink / raw)
To: Brice Waegeneire; +Cc: 42193
[-- Attachment #1: Type: text/plain, Size: 200 bytes --]
I mean technically we could do that, but almost none of the other
"-shepherd-service"s we have avoid returning a list. Why single this one out?
Could we change all of them to not return a list?
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service'.
2020-07-06 0:03 ` Danny Milosavljevic
@ 2020-07-06 10:01 ` Brice Waegeneire
0 siblings, 0 replies; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-06 10:01 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 42193
Hello Danny,
On 2020-07-06 00:03, Danny Milosavljevic wrote:
> I mean technically we could do that, but almost none of the other
> "-shepherd-service"s we have avoid returning a list. Why single this
> one out?
Because I wrote that module, forgetting to add a plural to
'kernel-module-loader-shepherd-service' and when reading the dnsmasq
service code
I was made aware of it. It's either that patch or a stupid typo one to
go from
'kernel-module-loader-shepherd-service' to
'kernel-module-loader-shepherd-serviceS'.
There are currently 14 other services that are using that pattern.
> Could we change all of them to not return a list?
Maybe, but I don't see the point of doing so as I expect that if the
procedure's
name is plural and return a list there is no need to change it.
- Brice
^ permalink raw reply [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service'.
2020-07-04 18:54 ` [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service' Brice Waegeneire
2020-07-06 0:03 ` Danny Milosavljevic
@ 2020-07-17 18:49 ` Danny Milosavljevic
2021-01-06 18:20 ` Danny Milosavljevic
1 sibling, 1 reply; 17+ messages in thread
From: Danny Milosavljevic @ 2020-07-17 18:49 UTC (permalink / raw)
To: Brice Waegeneire; +Cc: 42193
[-- Attachment #1: Type: text/plain, Size: 22 bytes --]
Sure, OK for master.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 5/6] WIP services: Add kernel-arguments-service-type.
2020-07-04 18:52 [WIP 0/6] Add kernel-module-configuration service Brice Waegeneire
` (4 preceding siblings ...)
2020-07-04 18:54 ` [bug#42193] [WIP 4/6] services: kernel-module-loader: Return a single 'shepherd-service' Brice Waegeneire
@ 2020-07-04 18:54 ` Brice Waegeneire
2020-07-04 18:54 ` [bug#42193] [WIP 6/6] WIP services: Add kernel-module-configuration service Brice Waegeneire
6 siblings, 0 replies; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-04 18:54 UTC (permalink / raw)
To: 42193
---
gnu/services.scm | 14 ++++++++++++++
gnu/system.scm | 39 +++++++++++++++++++++++++++++++++++++--
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/gnu/services.scm b/gnu/services.scm
index 7df9bf9d46..7cf71ae97a 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -538,6 +538,20 @@ possible (that is if there's a LINUX keyword argument in the build system)."
(kernel kernel) ;the kernel package to use
(packages (append packages additional-packages))))))))
+\f
+;;;
+;;; Kernel arguments.
+;;;
+
+;; (define kernel-arguments-service-type
+;; (service-type (name 'kernel-arguments)
+;; (description "Set the kernel arguments.")
+;; (extensions
+;; (list (service-extension system-service-type
+;; kernel-arguments->profile-entry)))
+;; (compose concatenate)
+;; (extend append)))
+
\f
;;;
;;; Cleanup.
diff --git a/gnu/system.scm b/gnu/system.scm
index ba9eeb66b8..805aa2ab01 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -56,6 +56,7 @@
#:use-module (gnu packages compression)
#:use-module (gnu packages firmware)
#:use-module (gnu services)
+ #:use-module (gnu services linux)
#:use-module (gnu services shepherd)
#:use-module (gnu services base)
#:use-module (gnu services linux)
@@ -258,11 +259,37 @@
(sudoers-file operating-system-sudoers-file ; file-like
(default %sudoers-specification)))
+(define (operating-system-modules-kernel-arguments os)
+ "Return the kernel arguments for builtin modules specified in
+<kernel-module-configuration-service-type> from OS."
+ (let* ((kernel-module-configuration-service
+ (find (lambda (service)
+ (eq? (service-kind service)
+ kernel-module-configuration-service-type))
+ (operating-system-user-services os)))
+ (modules (if kernel-module-configuration-service
+ (service-value kernel-module-configuration-service)
+ '())))
+ (display kernel-module-configuration-service)
+ (display (concatenate
+ (filter-map (lambda (module)
+ (if (kernel-module-is-builtin? module)
+ (kernel-module->kernel-arguments module)
+ #f))
+ modules)))
+ (concatenate
+ (filter-map (lambda (module)
+ (if (kernel-module-is-builtin? module)
+ (kernel-module->kernel-arguments module)
+ #f))
+ modules))))
+
(define (operating-system-kernel-arguments os root-device)
"Return all the kernel arguments, including the ones not specified
directly by the user."
(append (bootable-kernel-arguments os root-device)
- (operating-system-user-kernel-arguments os)))
+ (operating-system-user-kernel-arguments os)
+ (operating-system-modules-kernel-arguments os)))
\f
;;;
@@ -512,6 +539,7 @@ OS."
(file-append (operating-system-kernel os)
"/" (system-linux-image-file-name))))
+;; TODO Migrate to KMCS
(define %default-modprobe-blacklist
;; List of kernel modules to blacklist by default.
'("usbmouse" ;races with bcm5974, see <https://bugs.gnu.org/35574>
@@ -569,6 +597,11 @@ bookkeeping."
(kernel-profile-configuration
(kernel (operating-system-kernel os))
(packages (operating-system-kernel-loadable-modules os))))
+ ;; (service kernel-arguments-service-type
+ ;; (kernel-arguments-configuration
+ ;; (root (operating-system-root-file-system os))
+ ;; (bootloader (operating-system-bootloader os))
+ ;; (parameters "TODO")))
%boot-service
;; %SHEPHERD-ROOT-SERVICE must come last so that the gexp that
@@ -1232,7 +1265,9 @@ such as '--root' and '--load' to <boot-parameters>."
(kernel-arguments
(if system-kernel-arguments?
(operating-system-kernel-arguments os root-device)
- (operating-system-user-kernel-arguments os)))
+ (append
+ (operating-system-user-kernel-arguments os)
+ (operating-system-modules-kernel-arguments os))))
(initrd initrd)
(multiboot-modules multiboot-modules)
(bootloader-name bootloader-name)
--
2.26.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [bug#42193] [WIP 6/6] WIP services: Add kernel-module-configuration service.
2020-07-04 18:52 [WIP 0/6] Add kernel-module-configuration service Brice Waegeneire
` (5 preceding siblings ...)
2020-07-04 18:54 ` [bug#42193] [WIP 5/6] WIP services: Add kernel-arguments-service-type Brice Waegeneire
@ 2020-07-04 18:54 ` Brice Waegeneire
6 siblings, 0 replies; 17+ messages in thread
From: Brice Waegeneire @ 2020-07-04 18:54 UTC (permalink / raw)
To: 42193
---
gnu/services/linux.scm | 166 +++++++++++++++++++++++++++++++++++-
gnu/tests/linux-modules.scm | 67 +++++++++------
2 files changed, 208 insertions(+), 25 deletions(-)
diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm
index 7ea30a1270..9773dd5072 100644
--- a/gnu/services/linux.scm
+++ b/gnu/services/linux.scm
@@ -45,7 +45,22 @@
kernel-module-loader-service-type
- modprobe-service-type))
+ modprobe-service-type
+
+ kernel-module
+ kernel-module?
+ kernel-module-name
+ kernel-module-package
+ kernel-module-aliases
+ kernel-module-install
+ kernel-module-remove
+ kernel-module-pre-dependencies
+ kernel-module-post-dependencies
+ kernel-module-blacklist?
+ kernel-module-load?
+ kernel-module-is-builtin?
+ kernel-module->kernel-arguments
+ kernel-module-configuration-service-type))
\f
;;;
@@ -151,6 +166,9 @@ representation."
(rnrs io ports)
,@%default-modules))
(start
+ ;; TODO Verify that we are loading a loadable kernel and not a builtin
+ ;; one looking in
+ ;; /run/booted-system/kernel/lib/modules/5.4.39/modules.builtin
#~(lambda _
(cond
((null? '#$kernel-modules) #t)
@@ -227,3 +245,149 @@ files."
modprobe-environment)))
(compose concatenate)
(extend append)))
+
+\f
+;;;
+;;; Kernel module configuration.
+;;;
+
+;; NOTE Maybe have sperate records betwwen <kernel-builtin-module> and
+;; <kernel-lodable-module>
+(define-record-type* <kernel-module>
+ kernel-module make-kernel-module
+ kernel-module?
+ (name kernel-module-name) ; string
+ ;; For out-of-tree modules
+ (package kernel-module-package
+ (default #f)) ; #f | <package>
+ ;; NOTE Maybe use an alist instead
+ (options kernel-module-options
+ (default '())) ; list of strings
+ (aliases kernel-module-aliases
+ (default '())) ; list of strings
+ (install kernel-module-install
+ (default #f)) ; #f | string
+ (remove kernel-module-remove
+ (default #f)) ; #f | string
+ (pre-dependencies kernel-module-pre-dependencies
+ (default '())) ; list of strings
+ (post-dependencies kernel-module-post-dependencies
+ (default '())) ; list of strings
+ (blacklist? kernel-module-blacklist?
+ (default #f)) ; boolean
+ ;; NOTE Only possible if it's not built-in
+ ;; TODO maybe trow an error when it's set to true on a built-in module
+ (load? kernel-module-load?
+ (default #f))) ; boolean
+
+;; FIXME use 'modules.builtin' instead
+(define (kernel-module-is-builtin? module)
+ (if (kernel-module-package module) #f
+ #t))
+
+(define (kernel-module->kernel-arguments module)
+ "Return a list of kernel arguments for MODULE."
+ (match-record module <kernel-module>
+ (name options blacklist?)
+ (filter (lambda (s) (not (string-null? s)))
+ (list (if blacklist? (string-append name ".blacklist=yes") "")
+ (if (null? options) ""
+ (map (lambda (option)
+ (string-append name "." option))
+ options))))))
+
+(define (kernel-module->config module)
+ "Return a config string for MODULE."
+ (match-record module <kernel-module>
+ (name options aliases install remove pre-dependencies
+ post-dependencies blacklist?)
+ (string-concatenate
+ (list (if (null? options) ""
+ (format #f "options ~a~{ ~a~}\n" name options))
+ (if blacklist? (format #f "blacklist ~a\n" name)
+ "")
+ (if (null? aliases) ""
+ (map (lambda (alias)
+ (format #f "alias ~a ~a\n" alias name))
+ aliases))
+ (if install (format #f "install ~a ~a\n" name install)
+ "")
+ (if remove (format #f "remove ~a ~a\n" name remove)
+ "")
+ (if (null? pre-dependencies) ""
+ (map (lambda (dependency)
+ (format #f "softdep ~a :pre ~a\n"
+ name dependency))
+ pre-dependencies))
+ (if (null? post-dependencies) ""
+ (map (lambda (dependency)
+ (format #f "softdep ~a :post ~a\n"
+ name dependency))
+ post-dependencies))))))
+
+(define (string-underscorize s)
+ "Replace '-' characters by '_' in string S."
+ (string-map (lambda (c) (if (char=? c #\-) #\_ c)) s))
+
+(define (kernel-modules->config-files modules)
+ "Return a list of pairs of file name and gexp, to be used by 'file-union',
+from MODULES."
+ (define (kernel-module->filename-gexp module)
+ (let ((config (kernel-module->config module))
+ (name (kernel-module-name module)))
+ (if (string-null? config) #f
+ (list (string-append name ".conf")
+ (plain-file (string-append name ".conf") config)))))
+ (filter-map
+ (lambda (module)
+ (let ((module (kernel-module
+ (inherit module)
+ ;; XXX The kernel replace '-' by '_' in module name, we do
+ ;; the same to make name collision visible, that would
+ ;; otherwise be hidden.
+ (name (string-underscorize (kernel-module-name module))))))
+ (if (kernel-module-is-builtin? module) #f
+ (kernel-module->filename-gexp module))))
+ modules))
+
+(define (kernel-modules->packages modules)
+ "Return a list of packages from MODULES."
+ (filter-map (lambda (module)
+ (kernel-module-package module))
+ modules))
+
+(define (kernel-modules-to-load modules)
+ "Return a list of loadable module names, from MODULES, to be loaded."
+ (filter-map (lambda (module)
+ (if (and (not (kernel-module-is-builtin? module))
+ (kernel-module-load? module))
+ (kernel-module-name module)
+ #f))
+ modules))
+
+(define kernel-module-configuration-service-type
+ (service-type
+ (name 'kernel-module-configuration)
+ (description
+ "Configure kernel modules, in similar manner as @file{modprobe.d}.")
+ (default-value '())
+ (extensions
+ (list (service-extension modprobe-service-type
+ kernel-modules->config-files)
+ (service-extension kernel-profile-service-type
+ kernel-modules->packages)
+ (service-extension kernel-module-loader-service-type
+ kernel-modules-to-load)))
+ (compose concatenate)
+ (extend append)))
+
+;; TODO Make a naked modprobe call use MODPROBE_OPTIONS environment or
+;; /proc/sys/kernel/modprobe
+
+;; TODO write a helper to load a module from guile using modprobe command from
+;; '/proc/sys/kernel/modprobe' or %modprobe-wrapper. See linux-module-builder
+;; maybe.
+
+;; NOTE Throw an error when kernel-module-name isn't unique? It may already
+;; do it by itself already because 2 loadable module will try to create
+;; separeta config file with the same name.
diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scm
index 22e9a0c65c..296066e68f 100644
--- a/gnu/tests/linux-modules.scm
+++ b/gnu/tests/linux-modules.scm
@@ -32,6 +32,7 @@
#:use-module (guix monads)
#:use-module (guix store)
#:use-module (guix utils)
+ #:use-module (srfi srfi-1)
#:export (%test-loadable-kernel-modules-0
%test-loadable-kernel-modules-1
%test-loadable-kernel-modules-2))
@@ -66,19 +67,18 @@ that MODULES are actually loaded."
(member module modules string=?))
'#$modules))))))
-(define* (run-loadable-kernel-modules-test module-packages module-names)
- "Run a test of an OS having MODULE-PACKAGES, and verify that MODULE-NAMES
-are loaded in memory."
+(define* (run-loadable-kernel-modules-test modules)
+ "Run a test of an OS having MODULES and verify that they are loaded in
+memory."
(define os
(marionette-operating-system
(operating-system
- (inherit (simple-operating-system))
- (services (cons* (service kernel-module-loader-service-type module-names)
- (simple-service 'kernel-module-packages
- kernel-profile-service-type
- module-packages)
- (operating-system-user-services
- (simple-operating-system)))))
+ (inherit (simple-operating-system))
+ (services (cons* (service kernel-module-loader-service-type)
+ (service kernel-module-configuration-service-type
+ modules)
+ (operating-system-user-services
+ (simple-operating-system)))))
#:imported-modules '((guix combinators))))
(define vm (virtual-machine os))
(define (test script)
@@ -97,15 +97,20 @@ are loaded in memory."
marionette))
(test-end)
(exit (= (test-runner-fail-count (test-runner-current)) 0)))))
- (gexp->derivation "loadable-kernel-modules"
- (test (modules-loaded?-program os module-names))))
+ (let ((modules (filter-map (lambda (module)
+ (if (kernel-module-load? module)
+ (kernel-module-name module)
+ #f))
+ modules)))
+ (gexp->derivation "loadable-kernel-modules"
+ (test (modules-loaded?-program os modules)))))
(define %test-loadable-kernel-modules-0
(system-test
(name "loadable-kernel-modules-0")
(description "Tests loadable kernel modules facility of <operating-system>
with no extra modules.")
- (value (run-loadable-kernel-modules-test '() '()))))
+ (value (run-loadable-kernel-modules-test '()))))
(define %test-loadable-kernel-modules-1
(system-test
@@ -113,8 +118,11 @@ with no extra modules.")
(description "Tests loadable kernel modules facility of <operating-system>
with one extra module.")
(value (run-loadable-kernel-modules-test
- (list ddcci-driver-linux)
- '("ddcci")))))
+ (list (kernel-module
+ (name "ddcci")
+ (package ddcci-driver-linux)
+ (options '("delay=606"))
+ (load? #t)))))))
(define %test-loadable-kernel-modules-2
(system-test
@@ -122,12 +130,23 @@ with one extra module.")
(description "Tests loadable kernel modules facility of <operating-system>
with two extra modules.")
(value (run-loadable-kernel-modules-test
- (list acpi-call-linux-module
- (package
- (inherit ddcci-driver-linux)
- (arguments
- `(#:linux #f
- ,@(strip-keyword-arguments '(#:linux)
- (package-arguments
- ddcci-driver-linux))))))
- '("acpi_call" "ddcci")))))
+ (list (kernel-module
+ (name "ddcci")
+ ;; XXX Verify that kernel modules are built with the correct
+ ;; kernel
+ (package (package
+ (inherit ddcci-driver-linux)
+ (arguments
+ `(#:linux #f
+ ,@(strip-keyword-arguments '(#:linux)
+ (package-arguments
+ ddcci-driver-linux))))))
+ (load? #t))
+ (kernel-module
+ (name "acpi_call")
+ (package acpi-call-linux-module)
+ (load? #t))
+ ;; TODO Test that a module isn't loaded
+ (kernel-module
+ (name "radeon")
+ (blacklist? #t)))))))
--
2.26.2
^ permalink raw reply related [flat|nested] 17+ messages in thread