services: base: Deprecate 'udev-service' procedure.

* doc/guix.texi (Base Services): Replace udev-service with udev-service-type.
Document <udev-configuration>. Use @defun @-commands for udev-rules-service,
udev-rule and file->udev-rule.
* gnu/services/base.scm (udev-service): Deprecate procedure.
* gnu/system/install.scm (%installation-services): Use udev-service-type.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Bruno Victal 2023-02-25 18:57:54 +00:00 committed by Ludovic Courtès
parent 6edacf2491
commit 2e7516168e
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 39 additions and 22 deletions

View file

@ -18675,15 +18675,30 @@ A list of file-like objects or strings pointing to additional directories the bu
@end table @end table
@end deftp @end deftp
@deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}] @defvar udev-service-type
Run @var{udev}, which populates the @file{/dev} directory dynamically. Type of the service that runs udev, a service which populates the
udev rules can be provided as a list of files through the @var{rules} @file{/dev} directory dynamically, whose value is a
variable. The procedures @code{udev-rule}, @code{udev-rules-service} @code{<udev-configuration>} object.
and @code{file->udev-rule} from @code{(gnu services base)} simplify the
creation of such rule files.
@end deffn
@deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}] This service type can be @emph{extended} using procedures
@code{udev-rules-service} along with @code{file->udev-rule} or
@code{udev-rule} which simplify the process of writing udev rules.
@end defvar
@deftp {Data Type} udev-configuration
Data type representing the configuration of udev.
@table @asis
@item @code{udev} (default: @code{eudev}) (type: file-like)
Package object of the udev service.
@item @code{rules} (default: @var{'()}) (type: list-of-file-like)
List of file-like objects denoting udev-rule files.
@end table
@end deftp
@defun udev-rule @var{file-name} @var{contents}
Return a udev-rule file named @var{file-name} containing the rules Return a udev-rule file named @var{file-name} containing the rules
defined by the @var{contents} literal. defined by the @var{contents} literal.
@ -18699,18 +18714,17 @@ upon detecting a USB device with a given product identifier.
"ATTR@{product@}==\"Example\", " "ATTR@{product@}==\"Example\", "
"RUN+=\"/path/to/script\""))) "RUN+=\"/path/to/script\"")))
@end lisp @end lisp
@end deffn @end defun
@deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @ @defun udev-rules-service @var{name} @var{rules} [#:groups '()]
[#:groups @var{groups}] Return a service that extends @code{udev-service-type} with @var{rules}
Return a service that extends @code{udev-service-type } with @var{rules}
and @code{account-service-type} with @var{groups} as system groups. and @code{account-service-type} with @var{groups} as system groups.
This works by creating a singleton service type This works by creating a singleton service type
@code{@var{name}-udev-rules}, of which the returned service is an @code{@var{name}-udev-rules}, of which the returned service is an
instance. instance.
Here we show how it can be used to extend @code{udev-service-type} with the Here we show how it can be used to extend @code{udev-service-type}
previously defined rule @code{%example-udev-rule}. with the previously defined rule @code{%example-udev-rule}.
@lisp @lisp
(operating-system (operating-system
@ -18719,11 +18733,11 @@ previously defined rule @code{%example-udev-rule}.
(cons (udev-rules-service 'usb-thing %example-udev-rule) (cons (udev-rules-service 'usb-thing %example-udev-rule)
%desktop-services))) %desktop-services)))
@end lisp @end lisp
@end deffn @end defun
@deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}] @defun file->udev-rule @var{file-name} @var{file}
Return a udev file named @var{file-name} containing the rules defined Return a udev-rule file named @var{file-name} containing the rules
within @var{file}, a file-like object. defined within @var{file}, a file-like object.
The following example showcases how we can use an existing rule file. The following example showcases how we can use an existing rule file.
@ -18743,7 +18757,7 @@ The following example showcases how we can use an existing rule file.
(sha256 (sha256
(base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003")))))) (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
@end lisp @end lisp
@end deffn @end defun
Additionally, Guix package definitions can be included in @var{rules} in Additionally, Guix package definitions can be included in @var{rules} in
order to extend the udev rules with the definitions found under their order to extend the udev rules with the definitions found under their

View file

@ -150,7 +150,7 @@ (define-module (gnu services base)
udev-configuration? udev-configuration?
udev-configuration-rules udev-configuration-rules
udev-service-type udev-service-type
udev-service udev-service ; deprecated
udev-rule udev-rule
file->udev-rule file->udev-rule
udev-rules-service udev-rules-service
@ -2351,7 +2351,8 @@ (define udev-service-type
directory dynamically. Get extra rules from the packages listed in the directory dynamically. Get extra rules from the packages listed in the
@code{rules} field of its value, @code{udev-configuration} object."))) @code{rules} field of its value, @code{udev-configuration} object.")))
(define* (udev-service #:key (udev eudev) (rules '())) (define-deprecated (udev-service #:key (udev eudev) (rules '()))
udev-service-type
"Run @var{udev}, which populates the @file{/dev} directory dynamically. Get "Run @var{udev}, which populates the @file{/dev} directory dynamically. Get
extra rules from the packages listed in @var{rules}." extra rules from the packages listed in @var{rules}."
(service udev-service-type (service udev-service-type

View file

@ -388,7 +388,9 @@ (define bare-bones-os
;; Start udev so that useful device nodes are available. ;; Start udev so that useful device nodes are available.
;; Use device-mapper rules for cryptsetup & co; enable the CRDA for ;; Use device-mapper rules for cryptsetup & co; enable the CRDA for
;; regulations-compliant WiFi access. ;; regulations-compliant WiFi access.
(udev-service #:rules (list lvm2 crda)) (service udev-service-type
(udev-configuration
(rules (list lvm2 crda))))
;; Add the 'cow-store' service, which users have to start manually ;; Add the 'cow-store' service, which users have to start manually
;; since it takes the installation directory as an argument. ;; since it takes the installation directory as an argument.