unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Danny Milosavljevic <dannym@scratchpost.org>
To: 40595@debbugs.gnu.org
Cc: Danny Milosavljevic <dannym@scratchpost.org>
Subject: [bug#40595] [PATCH] system: Automatically adjust linux-module packages to use the operating-system's kernel.
Date: Mon, 13 Apr 2020 13:43:59 +0200	[thread overview]
Message-ID: <20200413114359.26652-1-dannym@scratchpost.org> (raw)

* gnu/system.scm (package-for-kernel): New procedure.
(operating-system-directory-base-entries): Use it.
* gnu/tests/linux-module.scm: Test it.
---
 gnu/system.scm              | 18 +++++++++++++++++-
 gnu/tests/linux-modules.scm | 11 ++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index fd456c6206..53c16233a1 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -32,6 +32,7 @@
   #:use-module (guix derivations)
   #:use-module (guix profiles)
   #:use-module (guix ui)
+  #:use-module (guix utils)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages guile)
@@ -472,6 +473,16 @@ 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* (operating-system-directory-base-entries os)
   "Return the basic entries of the 'system' directory of OS for use as the
 value of the SYSTEM-SERVICE-TYPE service."
@@ -486,7 +497,12 @@ value of the SYSTEM-SERVICE-TYPE service."
                          (kernel
                           (profile-derivation
                            (packages->manifest
-                            (cons kernel modules))
+                            (cons kernel
+                             (map (lambda (module)
+                                    (if (package? module)
+                                        (package-for-kernel kernel module)
+                                        module))
+                                  modules)))
                            #:hooks (if has-modules?
                                        (list linux-module-database)
                                        '())))
diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scm
index 788bdc848a..953b132ef7 100644
--- a/gnu/tests/linux-modules.scm
+++ b/gnu/tests/linux-modules.scm
@@ -28,8 +28,10 @@
   #:use-module (guix derivations)
   #:use-module (guix gexp)
   #:use-module (guix modules)
+  #:use-module (guix packages)
   #:use-module (guix monads)
   #:use-module (guix store)
+  #:use-module (guix utils)
   #:export (%test-loadable-kernel-modules-0
             %test-loadable-kernel-modules-1
             %test-loadable-kernel-modules-2))
@@ -118,5 +120,12 @@ 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 ddcci-driver-linux)
+           (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")))))

             reply	other threads:[~2020-04-13 11:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13 11:43 Danny Milosavljevic [this message]
2020-04-14  7:39 ` [bug#40595] [PATCH] system: Automatically adjust linux-module packages to use the Brice Waegeneire
2020-04-22 20:59   ` bug#40595: " Danny Milosavljevic
2020-04-22 18:57 ` [bug#40595] #40595 Need a rebase Brice Waegeneire

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200413114359.26652-1-dannym@scratchpost.org \
    --to=dannym@scratchpost.org \
    --cc=40595@debbugs.gnu.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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).