unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Brice Waegeneire <brice@waegenei.re>
To: 42193@debbugs.gnu.org
Subject: [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type'.
Date: Sat,  4 Jul 2020 20:54:27 +0200	[thread overview]
Message-ID: <20200704185431.13739-3-brice@waegenei.re> (raw)
In-Reply-To: <20200704185234.12571-1-brice@waegenei.re>

* 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





  parent reply	other threads:[~2020-07-04 18:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200704185234.12571-1-brice@waegenei.re>
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-06 12:31     ` Brice Waegeneire
2020-07-04 18:54 ` Brice Waegeneire [this message]
2020-07-08 11:29   ` [bug#42193] [WIP 2/6] services: Add 'kernel-profile-service-type' pelzflorian (Florian Pelz)
2020-07-08 16:22     ` Brice Waegeneire
2020-07-11 17:30       ` pelzflorian (Florian Pelz)
2020-07-04 18:54 ` [bug#42193] [WIP 3/6] services: Add 'modprobe-service-type' Brice Waegeneire
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
2021-01-06 18:20     ` 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

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=20200704185431.13739-3-brice@waegenei.re \
    --to=brice@waegenei.re \
    --cc=42193@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).