[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
21/45: services: udev: Make udev-rule helper functions generic.
From: |
guix-commits |
Subject: |
21/45: services: udev: Make udev-rule helper functions generic. |
Date: |
Sun, 18 Feb 2024 08:41:06 -0500 (EST) |
jpoiret pushed a commit to branch core-updates-glibc-2.39
in repository guix.
commit cb69874b71ab92aa740811b31559d0c1d10054ce
Author: Vivien Kraus <vivien@planete-kraus.eu>
AuthorDate: Thu Oct 5 19:24:56 2023 +0200
services: udev: Make udev-rule helper functions generic.
* gnu/services/base.scm (udev-configurations-union): New function.
(udev-configuration-file): New function, use file->udev-configuration-file.
(file->udev-configuration-file): New function.
(udev-rules-union): Use udev-configurations-union.
(udev-rule): Use udev-configuration-file.
(file->udev-rule): Use file->udev-configuration-file.
---
gnu/services/base.scm | 50 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 2da29e65ba..9d88cc6db4 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2243,9 +2243,9 @@ command that allows you to share pre-built binaries with
others over HTTP.")))
(rules udev-configuration-rules ;list of file-like
(default '())))
-(define (udev-rules-union packages)
- "Return the union of the @code{lib/udev/rules.d} directories found in each
-item of @var{packages}."
+(define (udev-configurations-union subdirectory packages)
+ "Return the union of the lib/udev/SUBDIRECTORY.d directories found in each
+item of PACKAGES."
(define build
(with-imported-modules '((guix build union)
(guix build utils))
@@ -2256,39 +2256,57 @@ item of @var{packages}."
(srfi srfi-26))
(define %standard-locations
- '("/lib/udev/rules.d" "/libexec/udev/rules.d"))
+ '(#$(string-append "/lib/udev/" subdirectory ".d")
+ #$(string-append "/libexec/udev/" subdirectory ".d")))
- (define (rules-sub-directory directory)
- ;; Return the sub-directory of DIRECTORY containing udev rules, or
- ;; #f if none was found.
+ (define (configuration-sub-directory directory)
+ ;; Return the sub-directory of DIRECTORY containing udev
+ ;; configurations, or #f if none was found.
(find directory-exists?
(map (cut string-append directory <>) %standard-locations)))
(union-build #$output
- (filter-map rules-sub-directory '#$packages)))))
+ (filter-map configuration-sub-directory '#$packages)))))
+
+ (computed-file (string-append "udev-" subdirectory) build))
- (computed-file "udev-rules" build))
+(define (udev-rules-union packages)
+ "Return the union of the lib/udev/rules.d directories found in each
+item of PACKAGES."
+ (udev-configurations-union "rules" packages))
+
+(define (udev-configuration-file subdirectory file-name contents)
+ "Return a directory with a udev configuration file FILE-NAME containing
CONTENTS."
+ (file->udev-configuration-file subdirectory file-name (plain-file file-name
contents)))
(define (udev-rule file-name contents)
"Return a directory with a udev rule file FILE-NAME containing CONTENTS."
- (file->udev-rule file-name (plain-file file-name contents)))
+ (udev-configuration-file "rules" file-name contents))
-(define (file->udev-rule file-name file)
- "Return a directory with a udev rule file FILE-NAME which is a copy of FILE."
+(define (file->udev-configuration-file subdirectory file-name file)
+ "Return a directory with a udev configuration file FILE-NAME which is a copy
+ of FILE."
(computed-file file-name
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
- (define rules.d
- (string-append #$output "/lib/udev/rules.d"))
+ (define configuration-directory
+ (string-append #$output
+ "/lib/udev/"
+ #$subdirectory
+ ".d"))
(define file-copy-dest
- (string-append rules.d "/" #$file-name))
+ (string-append configuration-directory "/"
#$file-name))
- (mkdir-p rules.d)
+ (mkdir-p configuration-directory)
(copy-file #$file file-copy-dest)))))
+(define (file->udev-rule file-name file)
+ "Return a directory with a udev rule file FILE-NAME which is a copy of FILE."
+ (file->udev-configuration-file "rules" file-name file))
+
(define kvm-udev-rule
;; Return a directory with a udev rule that changes the group of /dev/kvm to
;; "kvm" and makes it #o660. Apparently QEMU-KVM used to ship this rule,
- 32/45: gnu: cyrus-sasl: Add libxcrypt dependency., (continued)
- 32/45: gnu: cyrus-sasl: Add libxcrypt dependency., guix-commits, 2024/02/18
- 31/45: gnu: cups-minimal: Add libxcrypt dependency., guix-commits, 2024/02/18
- 14/45: gnu: python: Add libxcrypt dependency., guix-commits, 2024/02/18
- 38/45: gnu: accountsservice: Add libxcrypt dependency., guix-commits, 2024/02/18
- 26/45: gnu: apr: Update to 1.7.4., guix-commits, 2024/02/18
- 44/45: gnu: ldb: Remove reference to crypt., guix-commits, 2024/02/18
- 45/45: gnu: slock: Add libxcrypt dependency., guix-commits, 2024/02/18
- 17/45: gnu: shadow: Add libxcrypt dependency., guix-commits, 2024/02/18
- 18/45: gnu: tcsh: Add libxcrypt dependency., guix-commits, 2024/02/18
- 28/45: gnu: apr: Add libxcrypt dependency., guix-commits, 2024/02/18
- 21/45: services: udev: Make udev-rule helper functions generic.,
guix-commits <=
- 37/45: gnu: cryptsetup: G-Expify static-library., guix-commits, 2024/02/18
- 09/45: gnu: ffmpeg: Fix builds., guix-commits, 2024/02/18
- 19/45: gnu: eudev: Update to 3.2.14., guix-commits, 2024/02/18
- 33/45: gnu: tdb: Add libxcrypt dependency., guix-commits, 2024/02/18
- 24/45: gnu: upower: Update to 1.90.2., guix-commits, 2024/02/18
- 16/45: gnu: elogind: Add libxcrypt dependency., guix-commits, 2024/02/18
- 20/45: services: udev: Rewrite udev-rule to use file->udev-rule., guix-commits, 2024/02/18
- 27/45: gnu: apr-util: Update to 1.6.3., guix-commits, 2024/02/18
- 41/45: gnu: sambda/pinned: Add libxcrypt dependency., guix-commits, 2024/02/18
- 13/45: gnu: libxcrypt: Remove python from native-inputs., guix-commits, 2024/02/18