From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kKXoHUR+9F9YOAAA0tVLHw (envelope-from ) for ; Tue, 05 Jan 2021 14:57:08 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YC3CGUR+9F8XcAAA1q6Kng (envelope-from ) for ; Tue, 05 Jan 2021 14:57:08 +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 BF2CD940355 for ; Tue, 5 Jan 2021 14:57:07 +0000 (UTC) Received: from localhost ([::1]:48718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwnli-000337-Nt for larch@yhetil.org; Tue, 05 Jan 2021 09:57:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwnlX-00032y-B4 for guix-devel@gnu.org; Tue, 05 Jan 2021 09:56:55 -0500 Received: from mail-40130.protonmail.ch ([185.70.40.130]:13612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwnlT-00023V-V4 for guix-devel@gnu.org; Tue, 05 Jan 2021 09:56:54 -0500 Date: Tue, 05 Jan 2021 14:56:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1609858608; bh=4ttw+DgKpDZ8EUxuQ/LJxVhD91Cg1GuAqftXnCEtHE8=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=pK0HXznNkOnBZvSGaQiNqeQ2lc8VwqEQ1To+vPx/axckL/UMcKqTOihyTu2+fGiEi PKuAgHdR0XP7kH3QMVmOK62r0HQOzjkKtkzfIKBBI6llNeJTniY0v3zXeR4SY2m5dp MvGF42bdvzSy09DiwVn4TOovYcRdO37nY2zEaG1c= To: Carlo Zancanaro From: raid5atemyhomework Subject: Re: ZFS on Guix Message-ID: In-Reply-To: References: <_1CLe9QSGsoMlu5WxBMXm4CbFLM_M9iRG1XQF9GDsK0GP208jpngdymfix4tAfoLP94mhMTt-Tx6OP2xN_n78Jhx5KQzkiqPpIci_44C9OI=@protonmail.com> <4nnVFhbpUhipplsq55mHX9KtoMK9s0rZDC3D8rgKQ5O0nUtnapdkHZfPcAVpECgW1mnYm1BbmvyQ4SyTgvNyUgVgzM29gh6b8OL7p3YvczM=@protonmail.com> <20210103165008.6517c1bf@scratchpost.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.40.130; envelope-from=raid5atemyhomework@protonmail.com; helo=mail-40130.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: raid5atemyhomework Cc: "guix-devel@gnu.org" Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protonmail.com header.s=protonmail header.b=pK0HXznN; dmarc=pass (policy=quarantine) header.from=protonmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: BF2CD940355 X-Spam-Score: -3.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: 4aE3LagcAK94 Hi Carlo and guix-developers, I have this patch below for creating a new `kernel-loadable-module-service-= type`, which can be extended by another service to add kernel-loadable modu= les provided by packages, hope for a review. >From 984602faba1e18b9eb64e62970147aab653d997f Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Tue, 5 Jan 2021 22:27:56 +0800 Subject: [PATCH] gnu: Add 'kernel-loadable-module-service-type' for service= s to extend with kernel-loadable modules. --- doc/guix.texi | 6 +++++ gnu/services.scm | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ gnu/system.scm | 36 +++++++------------------ 3 files changed, 83 insertions(+), 27 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0f6e95a65a..78770151e3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -32409,6 +32409,12 @@ configuration when you use @command{guix system re= configure}, @command{guix system init}, or @command{guix deploy}. @end defvr +@defvr {Scheme Variable} kernel-loadable-module-service-type +Type of the service that collects lists of packages containing +kernel-loadable modules, and adds them to the set of kernel-loadable +modules. +@end defvr + @node Shepherd Services @subsection Shepherd Services diff --git a/gnu/services.scm b/gnu/services.scm index 13259dfaee..2c0bbf9725 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -33,6 +33,8 @@ #:use-module (guix diagnostics) #:autoload (guix openpgp) (openpgp-format-fingerprint) #:use-module (guix modules) + #:use-module (guix packages) + #:use-module (guix utils) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages hurd) @@ -75,6 +77,7 @@ service-back-edges instantiate-missing-services fold-services + kernel-loadable-module-service service-error? missing-value-service-error? @@ -106,6 +109,7 @@ profile-service-type firmware-service-type gc-root-service-type + kernel-loadable-module-service-type %boot-service %activation-service @@ -864,6 +868,70 @@ as Wifi cards."))) will not be reclaimed by the garbage collector.") (default-value '()))) +;; Configuration for the kernel builder. +;; Only used by the KERNEL-LOADABLE-MODULE-SERVICE-TYPE. +(define-record-type* kernel-builder-configu= ration + make-kernel-builder-configuration + kernel-builder-configuration? + this-kernel-builder-configuration + + (kernel kernel-builder-configuration-kernel (default #f)) + (hurd kernel-builder-configuration-hurd (default #f)) + (modules kernel-builder-configuration-modules (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-builder-configuration->system-entry config) + "Return the kernel and hurd entries of the 'system' directory of OS." + (mbegin %store-monad + (let* ((kernel (kernel-builder-configuration-kernel config)) + (hurd (kernel-builder-configuration-hurd config)) + (modules (kernel-builder-configuration-modules config)) + (kernel (if hurd + kernel + (profile + (content (packages->manifest + (cons kernel + (map (lambda (module) + (if (package? module) + (package-for-kernel ke= rnel module) + module)) + modules)))) + (hooks (list linux-module-database)))))) + (return `(("kernel" ,kernel) + ,@(if hurd `(("hurd" ,hurd)) '())))))) +(define (kernel-builder-configuration-add-modules config modules) + "Constructs a kernel builder configuration that has its modules extended= ." + (kernel-builder-configuration + (inherit config) + (modules (append (kernel-builder-configuration-modules config) modules= )))) + +(define kernel-loadable-module-service-type + (service-type (name 'kernel-loadable-modules) + (extensions + (list (service-extension system-service-type + kernel-builder-configuration->sy= stem-entry))) + (compose concatenate) + (extend kernel-builder-configuration-add-modules) + (description + "Register packages containing kernel-loadable modules and= adds them +to the system."))) +(define (kernel-loadable-module-service kernel hurd modules) + "Constructs the service that sets up kernel loadable modules." + (service kernel-loadable-module-service-type + (kernel-builder-configuration + (kernel kernel) + (hurd hurd) + (modules modules)))) + =0C ;;; ;;; Service folding. diff --git a/gnu/system.scm b/gnu/system.scm index c284a18379..a7f2365754 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -600,16 +600,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 @@ -625,26 +615,10 @@ possible (that is if there's a LINUX keyword argument= in the build system)." "Return the basic entries of the 'system' directory of OS for use as the value of the SYSTEM-SERVICE-TYPE service." (let* ((locale (operating-system-locale-directory os)) - (kernel (operating-system-kernel os)) (hurd (operating-system-hurd os)) - (modules (operating-system-kernel-loadable-modules os)) - (kernel (if hurd - kernel - (profile - (content (packages->manifest - (cons kernel - (map (lambda (module) - (if (package? module) - (package-for-kernel kern= el - modu= le) - module)) - modules)))) - (hooks (list linux-module-database))))) (initrd (and (not hurd) (operating-system-initrd-file os))) (params (operating-system-boot-parameters-file os))) - `(("kernel" ,kernel) - ,@(if hurd `(("hurd" ,hurd)) '()) - ("parameters" ,params) + `(("parameters" ,params) ,@(if initrd `(("initrd" ,initrd)) '()) ("locale" ,locale)))) ;used by libc @@ -663,6 +637,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) + (kernel-loadable-module-service + (operating-system-kernel os) + (operating-system-hurd os) + (operating-system-kernel-loadable-modules os)) %boot-service ;; %SHEPHERD-ROOT-SERVICE must come last so that the gexp that @@ -699,6 +677,10 @@ bookkeeping." (define (hurd-default-essential-services os) (let ((entries (operating-system-directory-base-entries os))) (list (service system-service-type entries) + (kernel-loadable-module-service + (operating-system-kernel os) + (operating-system-hurd os) + (operating-system-kernel-loadable-modules os)) %boot-service %hurd-startup-service %activation-service -- 2.29.2