From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:46559) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJNE1-0003SV-T2 for guix-patches@gnu.org; Tue, 31 Mar 2020 16:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJNE0-0000I8-72 for guix-patches@gnu.org; Tue, 31 Mar 2020 16:11:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53761) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJNE0-0000He-0V for guix-patches@gnu.org; Tue, 31 Mar 2020 16:11:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jJNDy-0001jZ-T7 for guix-patches@gnu.org; Tue, 31 Mar 2020 16:11:02 -0400 Subject: [bug#40274] [PATCH] gnu: Add kernel-module-loader-service. Resent-Message-ID: From: =?UTF-8?Q?Nicol=C3=B2?= Balzarotti In-Reply-To: <20200328135908.2540-1-brice@waegenei.re> References: <20200328135908.2540-1-brice@waegenei.re> Date: Tue, 31 Mar 2020 22:10:30 +0200 Message-ID: <87ftdoe155.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Brice Waegeneire , 40274@debbugs.gnu.org Hi, I found a typo /usefull/useful/ Nicol=C3=B2 Brice Waegeneire writes: > * doc/guix.texi (Linux Services): Add a new subsection and document the > new service and its configuration. > * gnu/services/linux.scm (kernel-module-loader-service): New procedure. > (kernel-module-loader-service-type, kernel-module-loader-configuration): > New types. > --- > > This patch is related to the following thread: > https://lists.gnu.org/archive/html/guix-devel/2020-03/msg00381.html > > doc/guix.texi | 48 ++++++++++++++++++++++++++++++++++ > gnu/services/linux.scm | 58 +++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 105 insertions(+), 1 deletion(-) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 77a4b8ed71..a297ec249f 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -75,6 +75,7 @@ Copyright @copyright{} 2020 Wiktor =C5=BBelazny@* > Copyright @copyright{} 2020 Damien Cassou@* > Copyright @copyright{} 2020 Jakub K=C4=85dzio=C5=82ka@* > Copyright @copyright{} 2020 Jack Hill@* > +Copyright @copyright{} 2020 Brice Waegeneire@* >=20=20 > Permission is granted to copy, distribute and/or modify this document > under the terms of the GNU Free Documentation License, Version 1.3 or > @@ -25382,6 +25383,53 @@ notifications. > @end table > @end deftp >=20=20 > +@cindex modprobe > +@cindex kernel module loader > +@subsubsection Kernel Module Loader Service > + > +The @code{kernel-module-loader-service} provides a service to load > +kernel modules at boot. This is especially usefull for modules that > +don't autoload and need to be manually loaded, like it's the case with > +@code{ddcci} for example. > + > +@deffn {Scheme Procedure} kernel-module-loader-service @var{modules} > +Return a service that run @command{modprobe} with arguments > +@var{modules} at boot. For example loading the drivers provided by > +@code{ddci-driver-linux} can be done as follow: > + > +@lisp > +(use-modules (gnu)) > +(use-package-modules linux) > +(use-service-modules linux) > +(operating-system > + ... > + (services (cons* (kernel-module-loader-service > + '("ddcci""ddcci_backlight")) > + %base-services)) > + (kernel-loadable-modules (list ddcci-driver-linux))) > +@end lisp > +@end defvr > + > +@deffn {Scheme Variable} kernel-module-loader-service-type > +The service type for loading kernel modules, that can't autoload, at > +boot, @command{modprobe}, on. Its value must be a > +@code{kernel-module-loader-configuration} object, described below. > + > +@deftp {Data Type} kernel-module-loader-configuration > +The data type representing the configuration of @command{sysctl}. > + > +@deftp {Data Type} kernel-module-loader-configuration > +This is the configuration record for the > +@code{kernel-module-loader-service-type}. > + > +@table @asis > +@item @code{modprobe} (default: @code{(file-append kmod "/bin/modprobe"}) > +The @command{modprobe} executable to use. > + > +@item @code{modules} (default: @code{'()}) > +A list specifying the modules to load. > +@end table > +@end deftp >=20=20 > @node Miscellaneous Services > @subsection Miscellaneous Services > diff --git a/gnu/services/linux.scm b/gnu/services/linux.scm > index caa0326c31..99ab4a3329 100644 > --- a/gnu/services/linux.scm > +++ b/gnu/services/linux.scm > @@ -1,5 +1,6 @@ > ;;; GNU Guix --- Functional package management for GNU > ;;; Copyright =C2=A9 2020 Maxim Cournoyer > +;;; Copyright =C2=A9 2020 Brice Waegeneire > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -37,7 +38,14 @@ > earlyoom-configuration-ignore-positive-oom-score-adj? > earlyoom-configuration-show-debug-messages? > earlyoom-configuration-send-notification-command > - earlyoom-service-type)) > + earlyoom-service-type > + > + kernel-module-loader-configuration > + kernel-module-loader-configuration? > + kernel-module-loader-configuration-modprobe > + kernel-module-loader-configuration-modules > + kernel-module-loader-service-type > + kernel-module-loader-service)) >=20=20 > > ;;; > @@ -123,3 +131,51 @@ representation." > (list (service-extension shepherd-root-service-type > (compose list earlyoom-shepherd-service)))) > (description "Run @command{earlyoom}, the Early OOM daemon."))) > + > +;;; > +;;; Kernel module loader. > +;;; > + > +(define-record-type* > + kernel-module-loader-configuration make-kernel-module-loader-configura= tion > + kernel-module-loader-configuration? > + (modprobe kernel-module-loader-configuration-modprobe ; path of the 'm= odprobe' command > + (default (file-append kmod "/bin/modprobe"))) > + (modules kernel-module-loader-configuration-modules ; list of strings > + (default '()))) > + > +(define kernel-module-loader-shepherd-service > + (match-lambda > + (($ modprobe modules) > + (list > + (shepherd-service > + (documentation "Load kernel modules.") > + (provision '(kernel-module-loader)) > + (respawn? #f) > + (one-shot? #t) > + (start > + #~(lambda _ > + (zero? (system* #$modprobe #$@modules))))))))) > + > +(define kernel-module-loader-service-type > + (service-type > + (name 'kernel-module-loader) > + (description "Load kernel modules.") > + (extensions > + (list > + (service-extension shepherd-root-service-type > + kernel-module-loader-shepherd-service))) > + (compose concatenate) > + (extend (lambda (config modules) > + (kernel-module-loader-configuration > + (inherit config) > + (modules (append > + (kernel-module-loader-configuration-modules conf= ig) > + modules))))) > + (default-value (kernel-module-loader-configuration)))) > + > +(define* (kernel-module-loader-service modules) > + "Return a service that loads kernel MODULES." > + (service kernel-module-loader-service-type > + (kernel-module-loader-configuration > + (modules modules)))) > --=20 > 2.25.1