From: Danny Milosavljevic <dannym@scratchpost.org>
To: Jelle Licht <jlicht@fsfe.org>
Cc: guix-devel@gnu.org
Subject: Re: Loading modules built using linux-module-build-system
Date: Mon, 21 Oct 2019 23:39:25 +0200 [thread overview]
Message-ID: <20191021233925.0ba18a4c@scratchpost.org> (raw)
In-Reply-To: <20191021204857.5dff6e9b@scratchpost.org>
[-- Attachment #1: Type: text/plain, Size: 5735 bytes --]
A patch to guix master which
* Puts the kernel modules (including any other packages that have "lib/modules"
inside their derivation) into /run/booted-system/profile/lib/modules
* Ensures that depmod is invoked on that
* Makes the modprobe wrapper use it
is provided below.
The case when there's only one package in the system profile (the package is the
kernel) could still be optimized:
Then, depmod doesn't need to run (it already ran when building the kernel in the
first place).
Probably, the profile hook will fail in some cases because modules.dep already
exists in the source. The patch still needs to be adapted for that.
Also, tests need to be added (system test in vm). Help wanted :)
(Right now I didn't test it because "guix system reconfigure" fails when
building qemu-4.1.0 three times in a row (for now), wasting many hours)
Also, long term, it might make sense to use something else instead of
profile-service-type (something like a new linux-module-service-type).
diff --git a/gnu/services.scm b/gnu/services.scm
index 6ee05d4580..d2977c2012 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -491,7 +491,11 @@ ACTIVATION-SCRIPT-TYPE."
(program-file "modprobe"
#~(begin
(setenv "LINUX_MODULE_DIRECTORY"
- "/run/booted-system/kernel/lib/modules")
+ (if (file-exists? "/run/booted-system/profile/lib/modules")
+ "/run/booted-system/profile/lib/modules"
+ ;; Provides compatibility with previous
+ ;; Guix generations.
+ "/run/booted-system/kernel/lib/modules"))
(apply execl #$modprobe
(cons #$modprobe (cdr (command-line))))))))
diff --git a/gnu/system.scm b/gnu/system.scm
index a353b1a5c8..2dfbb9e73f 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -887,9 +887,11 @@ we're running in the final root."
(define* (operating-system-profile os)
"Return a derivation that builds the system profile of OS."
(mlet* %store-monad
- ((services -> (operating-system-services os))
- (profile (fold-services services
- #:target-type profile-service-type)))
+ ((kernel -> (operating-system-kernel os))
+ (services -> (operating-system-services os))
+ (profile (cons kernel (fold-services services
+ #:target-type
+ profile-service-type))))
(match profile
(("profile" profile)
(return profile)))))
diff --git a/guix/profiles.scm b/guix/profiles.scm
index cd3b21e390..13b5bf1a85 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2017 Huang Ying <huang.ying.caritas@gmail.com>
;;; Copyright © 2017 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2019 Kyle Meyer <kyle@kyleam.com>
+;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1125,6 +1126,43 @@ for both major versions of GTK+."
(hook . gtk-im-modules)))
(return #f)))))
+(define (linux-module-database manifest)
+ (mlet %store-monad
+ ((kmod (manifest-lookup-package manifest "kmod")))
+ (define build
+ (with-imported-modules '((guix build utils)
+ (guix build union))
+ #~(begin
+ (use-modules (srfi srfi-26)
+ (guix build utils)
+ (guix build union)
+ (ice-9 match))
+ (let ((destdir (string-append #$output "/lib/modules"))
+ (dirs (filter file-exists?
+ (map (cut string-append <>
+ "/lib/modules")
+ '#$(manifest-inputs manifest))))
+ (System.maps (filter file-exists?
+ (map (cut string-append <> "/System.map")
+ '#$(manifest-inputs manifest))))
+ (Module.symvers (filter file-exists?
+ (map (cut string-append <> "/Module.symvers")
+ '#$(manifest-inputs manifest)))))
+ (mkdir-p (string-append #$output "/lib"))
+ (union-build destdir dirs #:create-all-directories? #t)
+ (exit (zero? (system* (string-append #$kmod "/bin/depmod")
+ "-e" ; Report symbols that aren't supplied
+ "-w" ; Warn on duplicates
+ "-b" destdir
+ "-F" (match System.maps ((x) x))
+ "-E" (match Module.symvers ((x) x)))))))))
+ (gexp->derivation "linux-module-database" build
+ #:local-build? #t
+ #:substitutable? #f
+ #:properties
+ `((type . profile-hook)
+ (hook . linux-module-database)))))
+
(define (xdg-desktop-database manifest)
"Return a derivation that builds the @file{mimeinfo.cache} database from
desktop files. It's used to query what applications can handle a given
@@ -1425,7 +1463,8 @@ MANIFEST."
gtk-im-modules
texlive-configuration
xdg-desktop-database
- xdg-mime-database))
+ xdg-mime-database
+ linux-module-database))
(define* (profile-derivation manifest
#:key
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-10-21 21:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-08 22:50 Loading modules built using linux-module-build-system Jelle Licht
2019-10-21 15:30 ` Jelle Licht
2019-10-21 18:27 ` Danny Milosavljevic
2019-10-21 18:49 ` Danny Milosavljevic
2019-10-21 21:39 ` Danny Milosavljevic [this message]
2019-10-22 12:24 ` Ludovic Courtès
2019-11-14 16:31 ` Danny Milosavljevic
2019-11-17 20:35 ` Ludovic Courtès
2019-12-22 20:06 ` Danny Milosavljevic
2019-12-30 18:55 ` Ludovic Courtès
2019-10-22 6:52 ` Giovanni Biscuolo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191021233925.0ba18a4c@scratchpost.org \
--to=dannym@scratchpost.org \
--cc=guix-devel@gnu.org \
--cc=jlicht@fsfe.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.