From: Danny Milosavljevic <dannym@scratchpost.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: Mark H Weaver <mhw@netris.org>, 37868@debbugs.gnu.org
Subject: [bug#37868] [PATCH] guix: Allow multiple packages to provide Linux modules in the system profile.
Date: Mon, 17 Feb 2020 18:10:45 +0100 [thread overview]
Message-ID: <20200217181045.7d41f231@scratchpost.org> (raw)
In-Reply-To: <87a78zq4xb.fsf@gnu.org>
[-- Attachment #1.1: Type: text/plain, Size: 260 bytes --]
Hi Ludo,
should the following work (patch to guix master attached)?
Because I get
guix system: error: #<procedure 7f990dded140 at guix/profiles.scm:1538:2 (state)>: invalid G-expression input
on
./pre-inst-env guix system vm /etc/config.scm
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: a.patch --]
[-- Type: text/x-patch, Size: 7267 bytes --]
diff --git a/gnu/system.scm b/gnu/system.scm
index 01baa248a2..9874861041 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -164,6 +164,8 @@
(kernel operating-system-kernel ; package
(default linux-libre))
+ (kernel-module-packages operating-system-kernel-module-packages
+ (default '())) ; list of packages
(kernel-arguments operating-system-user-kernel-arguments
(default '("quiet"))) ; list of gexps/strings
(bootloader operating-system-bootloader) ; <bootloader-configuration>
@@ -469,9 +471,18 @@ OS."
value of the SYSTEM-SERVICE-TYPE service."
(let ((locale (operating-system-locale-directory os)))
(mlet %store-monad ((kernel -> (operating-system-kernel os))
+ (kernel-module-packages ->
+ (operating-system-kernel-module-packages os))
(initrd -> (operating-system-initrd-file os))
(params (operating-system-boot-parameters-file os)))
(return `(("kernel" ,kernel)
+ ("kernel-modules"
+ ,(profile-derivation
+ (packages->manifest (cons kernel kernel-module-packages))
+ ; TODO: system, target.
+ #:hooks (list linux-module-database)
+ #:system #f
+ #:target #f))
("parameters" ,params)
("initrd" ,initrd)
("locale" ,locale)))))) ;used by libc
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 0d38b2513f..ecc0d3ae5a 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>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -139,7 +140,9 @@
%current-profile
ensure-profile-directory
canonicalize-profile
- user-friendly-profile))
+ user-friendly-profile
+
+ linux-module-database))
;;; Commentary:
;;;
@@ -1137,6 +1140,77 @@ 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-1)
+ (srfi srfi-26)
+ (guix build utils)
+ (guix build union)
+ (ice-9 ftw)
+ (ice-9 match))
+ (let* ((inputs '#$(manifest-inputs manifest))
+ (input-files (lambda (path)
+ (filter file-exists?
+ (map (cut string-append <> path) inputs))))
+ (module-directories (input-files "/lib/modules"))
+ (System.maps (input-files "/System.map"))
+ (Module.symverss (input-files "/Module.symvers"))
+ (directory-entries (lambda (directory-name)
+ (filter (lambda (basename)
+ (not (string-prefix? "."
+ basename)))
+ (scandir directory-name))))
+ ;; Note: Should result in one entry.
+ (versions (append-map directory-entries module-directories)))
+ ;; TODO: if len(module-directories) == 1: return module-directories[0]
+ (mkdir-p (string-append #$output "/lib/modules"))
+ ;; Iterate over each kernel version directory (usually one).
+ (for-each (lambda (version)
+ (let ((destination-directory (string-append #$output "/lib/modules/" version)))
+ (when (not (file-exists? destination-directory)) ; unique
+ (union-build destination-directory
+ ;; All directories with the same version as us.
+ (filter-map (lambda (directory-name)
+ (if (member version
+ (directory-entries directory-name))
+ (string-append directory-name "/" version)
+ #f))
+ module-directories)
+ #:create-all-directories? #t)
+ ;; Delete generated files (they will be recreated shortly).
+ (for-each (lambda (basename)
+ (when (string-prefix? "modules." basename)
+ (false-if-file-not-found
+ (delete-file
+ (string-append
+ destination-directory "/"
+ basename)))))
+ (directory-entries destination-directory))
+ (unless (zero? (system* (string-append #$kmod "/bin/depmod")
+ "-e" ; Report symbols that aren't supplied
+ "-w" ; Warn on duplicates
+ "-b" #$output ; destination-directory
+ "-F" (match System.maps
+ ((x) x))
+ "-E" (match Module.symverss
+ ((x) x))
+ version))
+ (display "FAILED\n" (current-error-port))
+ (exit #f)))))
+ versions)
+ (exit #t)))))
+ (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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-02-17 17:11 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 15:22 [bug#37868] [PATCH] guix: Allow multiple packages to provide Linux modules in the system profile Danny Milosavljevic
2019-11-12 16:20 ` Danny Milosavljevic
2019-11-12 17:47 ` Giovanni Biscuolo
2019-11-12 18:11 ` Giovanni Biscuolo
2019-11-13 13:30 ` Ludovic Courtès
2019-11-14 16:21 ` Danny Milosavljevic
2020-02-17 17:10 ` Danny Milosavljevic [this message]
2020-02-18 8:31 ` Ludovic Courtès
2019-11-14 17:48 ` Mark H Weaver
2020-02-18 9:42 ` [bug#37868] [PATCH v2 0/2] system: Add kernel-module-packages to operating-system and use it Danny Milosavljevic
2020-02-18 9:42 ` [bug#37868] [PATCH v2 1/2] build-system/linux-module: Disable depmod Danny Milosavljevic
2020-02-23 16:22 ` Ludovic Courtès
2020-02-25 10:11 ` Danny Milosavljevic
2020-02-18 9:42 ` [bug#37868] [PATCH v2 2/2] system: Add kernel-module-packages to operating-system Danny Milosavljevic
2020-02-18 12:31 ` Mathieu Othacehe
2020-02-23 16:36 ` Ludovic Courtès
2020-02-24 16:18 ` Danny Milosavljevic
2020-02-25 10:21 ` [bug#37868] [PATCH v3] " Danny Milosavljevic
2020-02-25 10:55 ` [bug#37868] [PATCH v4] " Danny Milosavljevic
2020-02-25 11:32 ` Danny Milosavljevic
2020-02-25 13:34 ` Danny Milosavljevic
2020-02-26 19:59 ` [bug#37868] [PATCH v5] " Danny Milosavljevic
2020-02-27 11:15 ` Danny Milosavljevic
2020-02-27 12:25 ` [bug#37868] [PATCH v6] " Danny Milosavljevic
2020-02-27 13:51 ` [bug#37868] [PATCH v7] " Danny Milosavljevic
2020-02-27 15:50 ` [bug#37868] [PATCH v8] " Danny Milosavljevic
2020-03-14 18:40 ` Danny Milosavljevic
2020-03-15 10:28 ` Mathieu Othacehe
2020-03-15 10:33 ` Mathieu Othacehe
2020-03-15 18:17 ` Danny Milosavljevic
2020-03-16 9:55 ` Mathieu Othacehe
2020-03-16 20:10 ` Danny Milosavljevic
2020-03-17 9:29 ` Ludovic Courtès
2020-03-18 14:50 ` Mathieu Othacehe
2020-03-18 16:06 ` Danny Milosavljevic
2020-03-18 17:00 ` Danny Milosavljevic
2020-03-18 17:35 ` Ludovic Courtès
2020-03-20 10:19 ` Danny Milosavljevic
2020-03-20 10:32 ` Mathieu Othacehe
2020-03-20 15:13 ` Mathieu Othacehe
2020-03-20 17:52 ` Mathieu Othacehe
2020-03-21 10:06 ` Danny Milosavljevic
2020-03-22 13:36 ` Danny Milosavljevic
2020-03-22 21:11 ` Ludovic Courtès
2020-03-15 21:02 ` Ludovic Courtès
2020-03-15 21:00 ` [bug#37868] [PATCH v6] " Ludovic Courtès
2020-03-15 22:09 ` Danny Milosavljevic
2020-03-16 8:55 ` Ludovic Courtès
2020-03-16 20:04 ` Danny Milosavljevic
2020-03-16 20:31 ` Danny Milosavljevic
2020-03-17 9:20 ` Ludovic Courtès
2020-03-16 20:17 ` [bug#37868] [PATCH v9] system: Add kernel-loadable-modules " Danny Milosavljevic
2020-03-19 14:22 ` [bug#37868] [PATCH v10] " Danny Milosavljevic
2020-03-22 12:01 ` bug#37868: " Danny Milosavljevic
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=20200217181045.7d41f231@scratchpost.org \
--to=dannym@scratchpost.org \
--cc=37868@debbugs.gnu.org \
--cc=ludo@gnu.org \
--cc=mhw@netris.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.