From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id ePWPB5jQAF/sVAAA0tVLHw (envelope-from ) for ; Sat, 04 Jul 2020 18:55:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id CPU7A5jQAF8mGQAAbx9fmQ (envelope-from ) for ; Sat, 04 Jul 2020 18:55:20 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9AE7F9407C5 for ; Sat, 4 Jul 2020 18:55:19 +0000 (UTC) Received: from localhost ([::1]:47504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrnJm-0006vi-LD for larch@yhetil.org; Sat, 04 Jul 2020 14:55:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrnJX-0006Yf-57 for guix-patches@gnu.org; Sat, 04 Jul 2020 14:55:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48090) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jrnJW-0006qD-SS for guix-patches@gnu.org; Sat, 04 Jul 2020 14:55:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jrnJW-0005HD-SM for guix-patches@gnu.org; Sat, 04 Jul 2020 14:55:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42193] [WIP 3/6] services: Add 'modprobe-service-type'. Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 04 Jul 2020 18:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42193 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 42193@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159388888420216 (code B ref -1); Sat, 04 Jul 2020 18:55:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Jul 2020 18:54:44 +0000 Received: from localhost ([127.0.0.1]:59625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jrnJD-0005Ft-UX for submit@debbugs.gnu.org; Sat, 04 Jul 2020 14:54:44 -0400 Received: from lists.gnu.org ([209.51.188.17]:45500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jrnJB-0005FG-UC for submit@debbugs.gnu.org; Sat, 04 Jul 2020 14:54:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrnJB-0006Sc-KH for guix-patches@gnu.org; Sat, 04 Jul 2020 14:54:41 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:34659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrnJ9-0006nL-1M for guix-patches@gnu.org; Sat, 04 Jul 2020 14:54:41 -0400 X-Originating-IP: 176.181.186.101 Received: from localhost (i15-les02-ntr-176-181-186-101.sfr.lns.abo.bbox.fr [176.181.186.101]) (Authenticated sender: brice@waegenei.re) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 923BCE0004 for ; Sat, 4 Jul 2020 18:54:37 +0000 (UTC) From: Brice Waegeneire Date: Sat, 4 Jul 2020 20:54:28 +0200 Message-Id: <20200704185431.13739-4-brice@waegenei.re> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200704185234.12571-1-brice@waegenei.re> References: <20200704185234.12571-1-brice@waegenei.re> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.70.183.196; envelope-from=brice@waegenei.re; helo=relay4-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 14:54:36 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -2.6 (--) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.01 X-TUID: QViNvvE7/f97 * 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)) ;;; @@ -177,3 +180,51 @@ representation." (compose concatenate) (extend append) (default-value '()))) + + +;;; +;;; 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 + (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