services: desktop: Extract a new gnome-package procedure.

* gnu/services/desktop.scm (<gnome-desktop-configuration>): Rename gnome
package accessor to gnome-desktop-configuration-gnome, to avoid name conflict.
(gnome-packages): Change first argument from a config object to a the gnome
package used.  Rename second argument from package to name.  Extract core
logic into...
(gnome-package): ... this.
(gnome-udev-rules, gnome-polkit-settings): Adjust accordingly.
(gnome-desktop-service-type): Likewise.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
Maxim Cournoyer 2023-02-17 09:16:17 -05:00
parent acbb112c1b
commit abadd0f81f
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -73,6 +73,7 @@ (define-module (gnu services desktop)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 format) #:use-module (ice-9 format)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:export (<upower-configuration> #:export (<upower-configuration>
@ -1347,31 +1348,36 @@ (define sane-service-type
(define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration (define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration
make-gnome-desktop-configuration make-gnome-desktop-configuration
gnome-desktop-configuration? gnome-desktop-configuration?
(gnome gnome-package (default gnome))) (gnome gnome-desktop-configuration-gnome
(default gnome)))
(define (gnome-packages config packages) (define (gnome-package gnome name)
"Return the list of GNOME dependencies from CONFIG which names are part of "Return the package NAME among the GNOME package inputs. NAME can be a
the given PACKAGES list." single name or a tree-like, e.g. @code{'(\"gnome-boxes\" \"spice-gtk\")} to
(let ((gnome (gnome-package config))) denote the spice-gtk input of the gnome-boxes input of the GNOME meta-package."
(map (lambda (name)
((package-direct-input-selector name) gnome)) ((package-direct-input-selector name) gnome))
packages)))
(define (gnome-packages gnome names)
"Return the package NAMES among the GNOME package inputs."
(map (cut gnome-package gnome <>) names))
(define (gnome-udev-rules config) (define (gnome-udev-rules config)
"Return the list of GNOME dependencies that provide udev rules." "Return the list of GNOME dependencies that provide udev rules."
(gnome-packages config '("gnome-settings-daemon"))) (let ((gnome (gnome-desktop-configuration-gnome config)))
(gnome-packages gnome '("gnome-settings-daemon"))))
(define (gnome-polkit-settings config) (define (gnome-polkit-settings config)
"Return the list of GNOME dependencies that provide polkit actions and "Return the list of GNOME dependencies that provide polkit actions and
rules." rules."
(gnome-packages config (let ((gnome (gnome-desktop-configuration-gnome config)))
(gnome-packages gnome
'("gnome-settings-daemon" '("gnome-settings-daemon"
"gnome-control-center" "gnome-control-center"
"gnome-system-monitor" "gnome-system-monitor"
"gvfs" "gvfs"
;; spice-gtk provides polkit actions for USB redirection ;; spice-gtk provides polkit actions for USB redirection
;; in GNOME Boxes. ;; in GNOME Boxes.
("gnome-boxes" "spice-gtk")))) ("gnome-boxes" "spice-gtk")))))
(define gnome-desktop-service-type (define gnome-desktop-service-type
(service-type (service-type
@ -1382,8 +1388,7 @@ (define gnome-desktop-service-type
(service-extension polkit-service-type (service-extension polkit-service-type
gnome-polkit-settings) gnome-polkit-settings)
(service-extension profile-service-type (service-extension profile-service-type
(compose list (compose list gnome-desktop-configuration-gnome))))
gnome-package))))
(default-value (gnome-desktop-configuration)) (default-value (gnome-desktop-configuration))
(description "Run the GNOME desktop environment."))) (description "Run the GNOME desktop environment.")))