1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
4 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2017 Maxim Cournoyer <maxim.cournoyer@gmail.com>
7 ;;; Copyright © 2017 ng0 <ng0@n0.is>
8 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2017, 2019 Christopher Baines <mail@cbaines.net>
11 ;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
12 ;;; Copyright © 2019 David Wilson <david@daviwil.com>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu services desktop)
30 #:use-module (gnu services)
31 #:use-module (gnu services shepherd)
32 #:use-module (gnu services base)
33 #:use-module (gnu services dbus)
34 #:use-module (gnu services avahi)
35 #:use-module (gnu services xorg)
36 #:use-module (gnu services networking)
37 #:use-module (gnu services sound)
38 #:use-module ((gnu system file-systems)
39 #:select (%elogind-file-systems))
40 #:use-module (gnu system)
41 #:use-module (gnu system shadow)
42 #:use-module (gnu system pam)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages admin)
45 #:use-module (gnu packages cups)
46 #:use-module (gnu packages freedesktop)
47 #:use-module (gnu packages gnome)
48 #:use-module (gnu packages xfce)
49 #:use-module (gnu packages avahi)
50 #:use-module (gnu packages xdisorg)
51 #:use-module (gnu packages scanner)
52 #:use-module (gnu packages suckless)
53 #:use-module (gnu packages linux)
54 #:use-module (gnu packages libusb)
55 #:use-module (gnu packages mate)
56 #:use-module (gnu packages enlightenment)
57 #:use-module (guix deprecation)
58 #:use-module (guix records)
59 #:use-module (guix packages)
60 #:use-module (guix store)
61 #:use-module (guix utils)
62 #:use-module (guix gexp)
63 #:use-module (srfi srfi-1)
64 #:use-module (ice-9 match)
65 #:export (<upower-configuration>
68 upower-configuration-upower
69 upower-configuration-watts-up-pro?
70 upower-configuration-poll-batteries?
71 upower-configuration-ignore-lid?
72 upower-configuration-use-percentage-for-policy?
73 upower-configuration-percentage-low
74 upower-configuration-percentage-critical
75 upower-configuration-percentage-action
76 upower-configuration-time-low
77 upower-configuration-time-critical
78 upower-configuration-time-action
79 upower-configuration-critical-power-action
94 geoclue-configuration?
95 %standard-geoclue-applications
99 bluetooth-service-type
100 bluetooth-configuration
101 bluetooth-configuration?
104 elogind-configuration
105 elogind-configuration?
109 accountsservice-service-type
110 accountsservice-service
112 cups-pk-helper-service-type
115 gnome-desktop-configuration
116 gnome-desktop-configuration?
117 gnome-desktop-service
118 gnome-desktop-service-type
120 mate-desktop-configuration
121 mate-desktop-configuration?
123 mate-desktop-service-type
125 xfce-desktop-configuration
126 xfce-desktop-configuration?
128 xfce-desktop-service-type
130 x11-socket-directory-service
132 enlightenment-desktop-configuration
133 enlightenment-desktop-configuration?
134 enlightenment-desktop-service-type
136 inputattach-configuration
137 inputattach-configuration?
138 inputattach-service-type
142 gnome-keyring-configuration
143 gnome-keyring-configuration?
144 gnome-keyring-service-type
150 ;;; This module contains service definitions for a "desktop" environment.
160 (if value "true\n" "false\n"))
162 (define (package-direct-input-selector input)
164 (match (assoc-ref (package-direct-inputs package) input)
165 ((package . _) package))))
170 ;;; Upower D-Bus service.
173 (define-record-type* <upower-configuration>
174 upower-configuration make-upower-configuration
175 upower-configuration?
176 (upower upower-configuration-upower
178 (watts-up-pro? upower-configuration-watts-up-pro?
180 (poll-batteries? upower-configuration-poll-batteries?
182 (ignore-lid? upower-configuration-ignore-lid?
184 (use-percentage-for-policy? upower-configuration-use-percentage-for-policy?
186 (percentage-low upower-configuration-percentage-low
188 (percentage-critical upower-configuration-percentage-critical
190 (percentage-action upower-configuration-percentage-action
192 (time-low upower-configuration-time-low
194 (time-critical upower-configuration-time-critical
196 (time-action upower-configuration-time-action
198 (critical-power-action upower-configuration-critical-power-action
199 (default 'hybrid-sleep)))
201 (define* upower-configuration-file
202 ;; Return an upower-daemon configuration file.
204 (($ <upower-configuration> upower
205 watts-up-pro? poll-batteries? ignore-lid? use-percentage-for-policy?
206 percentage-low percentage-critical percentage-action time-low
207 time-critical time-action critical-power-action)
208 (plain-file "UPower.conf"
211 "EnableWattsUpPro=" (bool watts-up-pro?)
212 "NoPollBatteries=" (bool (not poll-batteries?))
213 "IgnoreLid=" (bool ignore-lid?)
214 "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
215 "PercentageLow=" (number->string percentage-low) "\n"
216 "PercentageCritical=" (number->string percentage-critical) "\n"
217 "PercentageAction=" (number->string percentage-action) "\n"
218 "TimeLow=" (number->string time-low) "\n"
219 "TimeCritical=" (number->string time-critical) "\n"
220 "TimeAction=" (number->string time-action) "\n"
221 "CriticalPowerAction=" (match critical-power-action
222 ('hybrid-sleep "HybridSleep")
223 ('hibernate "Hibernate")
224 ('power-off "PowerOff"))
227 (define %upower-activation
229 (use-modules (guix build utils))
230 (mkdir-p "/var/lib/upower")))
232 (define (upower-dbus-service config)
233 (list (wrapped-dbus-service (upower-configuration-upower config)
235 `(("UPOWER_CONF_FILE_NAME"
236 ,(upower-configuration-file config))))))
238 (define (upower-shepherd-service config)
239 "Return a shepherd service for UPower with CONFIG."
240 (let ((upower (upower-configuration-upower config))
241 (config (upower-configuration-file config)))
242 (list (shepherd-service
243 (documentation "Run the UPower power and battery monitor.")
244 (provision '(upower-daemon))
245 (requirement '(dbus-system udev))
247 (start #~(make-forkexec-constructor
248 (list (string-append #$upower "/libexec/upowerd"))
249 #:environment-variables
250 (list (string-append "UPOWER_CONF_FILE_NAME="
252 (stop #~(make-kill-destructor))))))
254 (define upower-service-type
255 (let ((upower-package (compose list upower-configuration-upower)))
256 (service-type (name 'upower)
258 "Run @command{upowerd}}, a system-wide monitor for power
259 consumption and battery levels, with the given configuration settings. It
260 implements the @code{org.freedesktop.UPower} D-Bus interface, and is notably
263 (list (service-extension dbus-root-service-type
265 (service-extension shepherd-root-service-type
266 upower-shepherd-service)
267 (service-extension activation-service-type
268 (const %upower-activation))
269 (service-extension udev-service-type
272 ;; Make the 'upower' command visible.
273 (service-extension profile-service-type
275 (default-value (upower-configuration)))))
277 (define-deprecated (upower-service #:key (upower upower)
281 (use-percentage-for-policy? #f)
283 (percentage-critical 3)
284 (percentage-action 2)
288 (critical-power-action 'hybrid-sleep))
290 "Return a service that runs @uref{http://upower.freedesktop.org/,
291 @command{upowerd}}, a system-wide monitor for power consumption and battery
292 levels, with the given configuration settings. It implements the
293 @code{org.freedesktop.UPower} D-Bus interface, and is notably used by GNOME."
294 (let ((config (upower-configuration
295 (watts-up-pro? watts-up-pro?)
296 (poll-batteries? poll-batteries?)
297 (ignore-lid? ignore-lid?)
298 (use-percentage-for-policy? use-percentage-for-policy?)
299 (percentage-low percentage-low)
300 (percentage-critical percentage-critical)
301 (percentage-action percentage-action)
303 (time-critical time-critical)
304 (time-action time-action)
305 (critical-power-action critical-power-action))))
306 (service upower-service-type config)))
310 ;;; GeoClue D-Bus service.
314 (define-record-type* <geoclue-configuration>
315 geoclue-configuration make-geoclue-configuration
316 geoclue-configuration?
317 (geoclue geoclue-configuration-geoclue
319 (whitelist geoclue-configuration-whitelist)
320 (wifi-geolocation-url geoclue-configuration-wifi-geolocation-url)
321 (submit-data? geoclue-configuration-submit-data?)
322 (wifi-submission-url geoclue-configuration-wifi-submission-url)
323 (submission-nick geoclue-configuration-submission-nick)
324 (applications geoclue-configuration-applications))
326 (define* (geoclue-application name #:key (allowed? #t) system? (users '()))
327 "Configure default GeoClue access permissions for an application. NAME is
328 the Desktop ID of the application, without the .desktop part. If ALLOWED? is
329 true, the application will have access to location information by default.
330 The boolean SYSTEM? value indicates that an application is a system component
331 or not. Finally USERS is a list of UIDs of all users for which this
332 application is allowed location info access. An empty users list means all
336 "allowed=" (bool allowed?)
337 "system=" (bool system?)
338 "users=" (string-join users ";") "\n"))
340 (define %standard-geoclue-applications
341 (list (geoclue-application "gnome-datetime-panel" #:system? #t)
342 (geoclue-application "epiphany" #:system? #f)
343 (geoclue-application "firefox" #:system? #f)))
345 (define* (geoclue-configuration-file config)
346 "Return a geoclue configuration file."
347 (plain-file "geoclue.conf"
351 (string-join (geoclue-configuration-whitelist config)
354 "url=" (geoclue-configuration-wifi-geolocation-url config) "\n"
355 "submit-data=" (bool (geoclue-configuration-submit-data? config))
357 (geoclue-configuration-wifi-submission-url config) "\n"
359 (geoclue-configuration-submission-nick config)
361 (string-join (geoclue-configuration-applications config)
364 (define (geoclue-dbus-service config)
365 (list (wrapped-dbus-service (geoclue-configuration-geoclue config)
367 `(("GEOCLUE_CONFIG_FILE"
368 ,(geoclue-configuration-file config))))))
370 (define %geoclue-accounts
371 (list (user-group (name "geoclue") (system? #t))
376 (comment "GeoClue daemon user")
377 (home-directory "/var/empty")
378 (shell "/run/current-system/profile/sbin/nologin"))))
380 (define geoclue-service-type
381 (service-type (name 'geoclue)
383 (list (service-extension dbus-root-service-type
384 geoclue-dbus-service)
385 (service-extension account-service-type
386 (const %geoclue-accounts))))))
388 (define* (geoclue-service #:key (geoclue geoclue)
390 (wifi-geolocation-url
391 ;; Mozilla geolocation service:
392 "https://location.services.mozilla.com/v1/geolocate?key=geoclue")
395 "https://location.services.mozilla.com/v1/submit?key=geoclue")
396 (submission-nick "geoclue")
397 (applications %standard-geoclue-applications))
398 "Return a service that runs the @command{geoclue} location service. This
399 service provides a D-Bus interface to allow applications to request access to
400 a user's physical location, and optionally to add information to online
401 location databases. By default, only the GNOME date-time panel and the Icecat
402 and Epiphany web browsers are able to ask for the user's location, and in the
403 case of Icecat and Epiphany, both will ask the user for permission first. See
404 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the geoclue web
405 site} for more information."
406 (service geoclue-service-type
407 (geoclue-configuration
409 (whitelist whitelist)
410 (wifi-geolocation-url wifi-geolocation-url)
411 (submit-data? submit-data?)
412 (wifi-submission-url wifi-submission-url)
413 (submission-nick submission-nick)
414 (applications applications))))
421 (define-record-type* <bluetooth-configuration>
422 bluetooth-configuration make-bluetooth-configuration
423 bluetooth-configuration?
424 (bluez bluetooth-configuration-bluez (default bluez))
425 (auto-enable? bluetooth-configuration-auto-enable? (default #f)))
427 (define (bluetooth-configuration-file config)
428 "Return a configuration file for the systemd bluetooth service, as a string."
431 "AutoEnable=" (bool (bluetooth-configuration-auto-enable?
434 (define (bluetooth-directory config)
435 (computed-file "etc-bluetooth"
439 (call-with-output-file "main.conf"
441 (display #$(bluetooth-configuration-file config)
444 (define (bluetooth-shepherd-service config)
445 "Return a shepherd service for @command{bluetoothd}."
447 (provision '(bluetooth))
448 (requirement '(dbus-system udev))
449 (documentation "Run the bluetoothd daemon.")
450 (start #~(make-forkexec-constructor
451 (string-append #$(bluetooth-configuration-bluez config)
452 "/libexec/bluetooth/bluetoothd")))
453 (stop #~(make-kill-destructor))))
455 (define bluetooth-service-type
459 (list (service-extension dbus-root-service-type
460 (compose list bluetooth-configuration-bluez))
461 (service-extension udev-service-type
462 (compose list bluetooth-configuration-bluez))
463 (service-extension etc-service-type
466 ,(bluetooth-directory config)))))
467 (service-extension shepherd-root-service-type
468 (compose list bluetooth-shepherd-service))))
469 (description "Run the @command{bluetoothd} daemon, which manages all the
470 Bluetooth devices and provides a number of D-Bus interfaces.")))
472 (define* (bluetooth-service #:key (bluez bluez) (auto-enable? #f))
473 "Return a service that runs the @command{bluetoothd} daemon, which manages
474 all the Bluetooth devices and provides a number of D-Bus interfaces. When
475 AUTO-ENABLE? is true, the bluetooth controller is powered automatically at
478 Users need to be in the @code{lp} group to access the D-Bus service.
480 (service bluetooth-service-type
481 (bluetooth-configuration
483 (auto-enable? auto-enable?))))
487 ;;; Colord D-Bus service.
490 (define %colord-activation
492 (use-modules (guix build utils))
493 (mkdir-p "/var/lib/colord")
494 (let ((user (getpwnam "colord")))
495 (chown "/var/lib/colord"
496 (passwd:uid user) (passwd:gid user)))))
498 (define %colord-accounts
499 (list (user-group (name "colord") (system? #t))
504 (comment "colord daemon user")
505 (home-directory "/var/empty")
506 (shell (file-append shadow "/sbin/nologin")))))
508 (define colord-service-type
509 (service-type (name 'colord)
511 (list (service-extension account-service-type
512 (const %colord-accounts))
513 (service-extension activation-service-type
514 (const %colord-activation))
516 ;; Colord is a D-Bus service that dbus-daemon can
518 (service-extension dbus-root-service-type list)
520 ;; Colord provides "color device" rules for udev.
521 (service-extension udev-service-type list)
523 ;; It provides polkit "actions".
524 (service-extension polkit-service-type list)))
525 (default-value colord)
527 "Run @command{colord}, a system service with a D-Bus
528 interface to manage the color profiles of input and output devices such as
529 screens and scanners.")))
531 (define-deprecated (colord-service #:key (colord colord))
533 "Return a service that runs @command{colord}, a system service with a D-Bus
534 interface to manage the color profiles of input and output devices such as
535 screens and scanners. It is notably used by the GNOME Color Manager graphical
536 tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
537 site} for more information."
538 (service colord-service-type colord))
545 (define-record-type* <udisks-configuration>
546 udisks-configuration make-udisks-configuration
547 udisks-configuration?
548 (udisks udisks-configuration-udisks
551 (define %udisks-activation
552 (with-imported-modules '((guix build utils))
554 (use-modules (guix build utils))
556 (let ((run-dir "/var/run/udisks2"))
558 (chmod run-dir #o700)))))
560 (define udisks-service-type
561 (let ((udisks-package (lambda (config)
562 (list (udisks-configuration-udisks config)))))
563 (service-type (name 'udisks)
565 (list (service-extension polkit-service-type
567 (service-extension dbus-root-service-type
569 (service-extension udev-service-type
571 (service-extension activation-service-type
572 (const %udisks-activation))
574 ;; Profile 'udisksctl' & co. in the system profile.
575 (service-extension profile-service-type
578 (define* (udisks-service #:key (udisks udisks))
579 "Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
580 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
581 notifications and ways to mount/unmount disks. Programs that talk to UDisks
582 include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
583 (service udisks-service-type
584 (udisks-configuration (udisks udisks))))
588 ;;; Elogind login and seat management service.
591 (define-record-type* <elogind-configuration> elogind-configuration
592 make-elogind-configuration
593 elogind-configuration?
594 (elogind elogind-package
596 (kill-user-processes? elogind-kill-user-processes?
598 (kill-only-users elogind-kill-only-users
600 (kill-exclude-users elogind-kill-exclude-users
602 (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds
604 (handle-power-key elogind-handle-power-key
606 (handle-suspend-key elogind-handle-suspend-key
608 (handle-hibernate-key elogind-handle-hibernate-key
609 ;; (default 'hibernate)
610 ;; XXX Ignore it for now, since we don't
611 ;; yet handle resume-from-hibernation in
614 (handle-lid-switch elogind-handle-lid-switch
616 (handle-lid-switch-docked elogind-handle-lid-switch-docked
618 (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited?
620 (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited?
622 (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited?
624 (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited?
626 (holdoff-timeout-seconds elogind-holdoff-timeout-seconds
628 (idle-action elogind-idle-action
630 (idle-action-seconds elogind-idle-action-seconds
632 (runtime-directory-size-percent elogind-runtime-directory-size-percent
634 (runtime-directory-size elogind-runtime-directory-size
636 (remove-ipc? elogind-remove-ipc?
639 (suspend-state elogind-suspend-state
640 (default '("mem" "standby" "freeze")))
641 (suspend-mode elogind-suspend-mode
643 (hibernate-state elogind-hibernate-state
645 (hibernate-mode elogind-hibernate-mode
646 (default '("platform" "shutdown")))
647 (hybrid-sleep-state elogind-hybrid-sleep-state
649 (hybrid-sleep-mode elogind-hybrid-sleep-mode
651 '("suspend" "platform" "shutdown"))))
653 (define (elogind-configuration-file config)
658 (_ (error "expected #t or #f, instead got:" x))))
659 (define char-set:user-name
660 (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-"))
661 (define (valid-list? l pred)
662 (and-map (lambda (x) (string-every pred x)) l))
663 (define (user-name-list users)
664 (unless (valid-list? users char-set:user-name)
665 (error "invalid user list" users))
666 (string-join users " "))
667 (define (enum val allowed)
668 (unless (memq val allowed)
669 (error "invalid value" val allowed))
670 (symbol->string val))
671 (define (non-negative-integer x)
672 (unless (exact-integer? x) (error "not an integer" x))
673 (when (negative? x) (error "negative number not allowed" x))
675 (define handle-actions
676 '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
677 (define (handle-action x)
678 (enum x handle-actions))
679 (define (sleep-list tokens)
680 (unless (valid-list? tokens char-set:user-name)
681 (error "invalid sleep list" tokens))
682 (string-join tokens " "))
683 (define-syntax ini-file-clause
685 ((_ config (prop (parser getter)))
686 (string-append prop "=" (parser (getter config)) "\n"))
688 (string-append str "\n"))))
689 (define-syntax-rule (ini-file config file clause ...)
690 (plain-file file (string-append (ini-file-clause config clause) ...)))
694 ("KillUserProcesses" (yesno elogind-kill-user-processes?))
695 ("KillOnlyUsers" (user-name-list elogind-kill-only-users))
696 ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users))
697 ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds))
698 ("HandlePowerKey" (handle-action elogind-handle-power-key))
699 ("HandleSuspendKey" (handle-action elogind-handle-suspend-key))
700 ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key))
701 ("HandleLidSwitch" (handle-action elogind-handle-lid-switch))
702 ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked))
703 ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?))
704 ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?))
705 ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?))
706 ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?))
707 ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds))
708 ("IdleAction" (handle-action elogind-idle-action))
709 ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds))
710 ("RuntimeDirectorySize"
713 (match (elogind-runtime-directory-size-percent config)
714 (#f (non-negative-integer (elogind-runtime-directory-size config)))
715 (percent (string-append (non-negative-integer percent) "%"))))))
716 ("RemoveIPC" (yesno elogind-remove-ipc?))
718 ("SuspendState" (sleep-list elogind-suspend-state))
719 ("SuspendMode" (sleep-list elogind-suspend-mode))
720 ("HibernateState" (sleep-list elogind-hibernate-state))
721 ("HibernateMode" (sleep-list elogind-hibernate-mode))
722 ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state))
723 ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
725 (define (elogind-dbus-service config)
726 (list (wrapped-dbus-service (elogind-package config)
727 "libexec/elogind/elogind"
728 `(("ELOGIND_CONF_FILE"
729 ,(elogind-configuration-file config))))))
731 (define (pam-extension-procedure config)
732 "Return an extension for PAM-ROOT-SERVICE-TYPE that ensures that all the PAM
733 services use 'pam_elogind.so', a module that allows elogind to keep track of
734 logged-in users (run 'loginctl' to see elogind's world view of users and
739 (module (file-append (elogind-package config)
740 "/lib/security/pam_elogind.so"))))
745 (session (cons pam-elogind (pam-service-session pam)))))))
747 (define (elogind-shepherd-service config)
748 "Return a Shepherd service to start elogind according to @var{config}."
749 (list (shepherd-service
750 (requirement '(dbus-system))
751 (provision '(elogind))
752 (start #~(make-forkexec-constructor
753 (list #$(file-append (elogind-package config)
754 "/libexec/elogind/elogind"))
755 #:environment-variables
756 (list (string-append "ELOGIND_CONF_FILE="
757 #$(elogind-configuration-file
759 (stop #~(make-kill-destructor)))))
761 (define elogind-service-type
762 (service-type (name 'elogind)
764 (list (service-extension dbus-root-service-type
765 elogind-dbus-service)
766 (service-extension udev-service-type
767 (compose list elogind-package))
768 (service-extension polkit-service-type
769 (compose list elogind-package))
771 ;; Start elogind from the Shepherd rather than waiting
772 ;; for bus activation. This ensures that it can handle
773 ;; events like lid close, etc.
774 (service-extension shepherd-root-service-type
775 elogind-shepherd-service)
777 ;; Provide the 'loginctl' command.
778 (service-extension profile-service-type
779 (compose list elogind-package))
781 ;; Extend PAM with pam_elogind.so.
782 (service-extension pam-root-service-type
783 pam-extension-procedure)
785 ;; We need /run/user, /run/systemd, etc.
786 (service-extension file-system-service-type
787 (const %elogind-file-systems))))
788 (default-value (elogind-configuration))))
790 (define* (elogind-service #:key (config (elogind-configuration)))
791 "Return a service that runs the @command{elogind} login and seat management
792 service. The @command{elogind} service integrates with PAM to allow other
793 system components to know the set of logged-in users as well as their session
794 types (graphical, console, remote, etc.). It can also clean up after users
796 (service elogind-service-type config))
800 ;;; AccountsService service.
803 (define %accountsservice-activation
805 (use-modules (guix build utils))
806 (mkdir-p "/var/lib/AccountsService")))
808 (define accountsservice-service-type
809 (service-type (name 'accountsservice)
811 (list (service-extension activation-service-type
812 (const %accountsservice-activation))
813 (service-extension dbus-root-service-type list)
814 (service-extension polkit-service-type list)))))
816 (define* (accountsservice-service #:key (accountsservice accountsservice))
817 "Return a service that runs AccountsService, a system service that
818 can list available accounts, change their passwords, and so on.
819 AccountsService integrates with PolicyKit to enable unprivileged users to
820 acquire the capability to modify their system configuration.
821 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
822 accountsservice web site} for more information."
823 (service accountsservice-service-type accountsservice))
827 ;;; cups-pk-helper service.
830 (define cups-pk-helper-service-type
832 (name 'cups-pk-helper)
834 "PolicyKit helper to configure CUPS with fine-grained privileges.")
836 (list (service-extension dbus-root-service-type list)
837 (service-extension polkit-service-type list)))
838 (default-value cups-pk-helper)))
842 ;;; Scanner access via SANE.
845 (define %sane-accounts
846 ;; The '60-libsane.rules' udev rules refers to the "scanner" group.
847 (list (user-group (name "scanner") (system? #t))))
849 (define sane-service-type
853 "This service provides access to scanners @i{via}
854 @uref{http://www.sane-project.org, SANE} by installing the necessary udev
856 (default-value sane-backends-minimal)
858 (list (service-extension udev-service-type list)
859 (service-extension account-service-type
860 (const %sane-accounts))))))
865 ;;; GNOME desktop service.
868 (define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration
869 make-gnome-desktop-configuration
870 gnome-desktop-configuration?
871 (gnome-package gnome-package (default gnome)))
873 (define (gnome-polkit-settings config)
874 "Return the list of GNOME dependencies that provide polkit actions and
876 (let ((gnome (gnome-package config)))
878 ((package-direct-input-selector name) gnome))
879 '("gnome-settings-daemon"
880 "gnome-control-center"
881 "gnome-system-monitor"
884 (define gnome-desktop-service-type
886 (name 'gnome-desktop)
888 (list (service-extension polkit-service-type
889 gnome-polkit-settings)
890 (service-extension profile-service-type
893 (default-value (gnome-desktop-configuration))
894 (description "Run the GNOME desktop environment.")))
896 (define-deprecated (gnome-desktop-service #:key (config
897 (gnome-desktop-configuration)))
898 gnome-desktop-service-type
899 "Return a service that adds the @code{gnome} package to the system profile,
900 and extends polkit with the actions from @code{gnome-settings-daemon}."
901 (service gnome-desktop-service-type config))
903 ;; MATE Desktop service.
904 ;; TODO: Add mate-screensaver.
906 (define-record-type* <mate-desktop-configuration> mate-desktop-configuration
907 make-mate-desktop-configuration
908 mate-desktop-configuration?
909 (mate-package mate-package (default mate)))
911 (define mate-desktop-service-type
915 (list (service-extension polkit-service-type
917 (package-direct-input-selector
918 "mate-settings-daemon")
920 (service-extension profile-service-type
923 (default-value (mate-desktop-configuration))
924 (description "Run the MATE desktop environment.")))
926 (define-deprecated (mate-desktop-service #:key
928 (mate-desktop-configuration)))
929 mate-desktop-service-type
930 "Return a service that adds the @code{mate} package to the system profile,
931 and extends polkit with the actions from @code{mate-settings-daemon}."
932 (service mate-desktop-service-type config))
936 ;;; XFCE desktop service.
939 (define-record-type* <xfce-desktop-configuration> xfce-desktop-configuration
940 make-xfce-desktop-configuration
941 xfce-desktop-configuration?
942 (xfce xfce-package (default xfce)))
944 (define (xfce-polkit-settings config)
945 "Return the list of XFCE dependencies that provide polkit actions and
947 (let ((xfce (xfce-package config)))
949 ((package-direct-input-selector name) xfce))
951 "xfce4-power-manager"))))
953 (define xfce-desktop-service-type
957 (list (service-extension polkit-service-type
958 xfce-polkit-settings)
959 (service-extension profile-service-type
960 (compose list xfce-package))))
961 (default-value (xfce-desktop-configuration))
962 (description "Run the Xfce desktop environment.")))
964 (define-deprecated (xfce-desktop-service #:key (config
965 (xfce-desktop-configuration)))
966 xfce-desktop-service-type
967 "Return a service that adds the @code{xfce} package to the system profile,
968 and extends polkit with the ability for @code{thunar} to manipulate the file
969 system as root from within a user session, after the user has authenticated
970 with the administrator's password."
971 (service xfce-desktop-service-type config))
975 ;;; X11 socket directory service
978 (define x11-socket-directory-service
979 ;; Return a service that creates /tmp/.X11-unix. When using X11, libxcb
980 ;; takes care of creating that directory. However, when using XWayland, we
981 ;; need to create beforehand. Thus, create it unconditionally here.
982 (simple-service 'x11-socket-directory
983 activation-service-type
984 (with-imported-modules '((guix build utils))
986 (use-modules (guix build utils))
987 (let ((directory "/tmp/.X11-unix"))
989 (chmod directory #o777))))))
992 ;;; Enlightenment desktop service.
995 (define-record-type* <enlightenment-desktop-configuration>
996 enlightenment-desktop-configuration make-enlightenment-desktop-configuration
997 enlightenment-desktop-configuration?
999 (enlightenment enlightenment-package
1000 (default enlightenment)))
1002 (define (enlightenment-setuid-programs enlightenment-desktop-configuration)
1003 (match-record enlightenment-desktop-configuration
1004 <enlightenment-desktop-configuration>
1006 (let ((module-arch (match (string-tokenize (%current-system)
1007 (char-set-complement (char-set #\-)))
1008 ((arch "linux") (string-append "linux-gnu-" arch))
1009 ((arch "gnu") (string-append "gnu-" arch)))))
1010 (list (file-append enlightenment
1011 "/lib/enlightenment/utils/enlightenment_sys")
1012 (file-append enlightenment
1013 "/lib/enlightenment/utils/enlightenment_backlight")
1014 ;; TODO: Move this binary to a screen-locker service.
1015 (file-append enlightenment
1016 "/lib/enlightenment/utils/enlightenment_ckpasswd")
1017 (file-append enlightenment
1019 "/lib/enlightenment/modules/cpufreq/"
1021 (package-version enlightenment)
1023 (file-append enlightenment
1025 "/lib/enlightenment/modules/sysinfo/"
1027 (package-version enlightenment)
1028 "/cpuclock_sysfs"))))))
1030 (define enlightenment-desktop-service-type
1032 (name 'enlightenment-desktop)
1034 (list (service-extension dbus-root-service-type
1036 (package-direct-input-selector
1038 enlightenment-package))
1039 (service-extension setuid-program-service-type
1040 enlightenment-setuid-programs)
1041 (service-extension profile-service-type
1043 enlightenment-package))))
1044 (default-value (enlightenment-desktop-configuration))
1046 "Return a service that adds the @code{enlightenment} package to the system
1047 profile, and extends dbus with the ability for @code{efl} to generate
1048 thumbnails and makes setuid the programs which enlightenment needs to function
1053 ;;; inputattach-service-type
1056 (define-record-type* <inputattach-configuration>
1057 inputattach-configuration
1058 make-inputattach-configuration
1059 inputattach-configuration?
1060 (device-type inputattach-configuration-device-type
1062 (device inputattach-configuration-device
1063 (default "/dev/ttyS0"))
1064 (baud-rate inputattach-configuration-baud-rate
1066 (log-file inputattach-configuration-log-file
1069 (define inputattach-shepherd-service
1071 (($ <inputattach-configuration> type device baud-rate log-file)
1072 (let ((args (append (if baud-rate
1073 (list "--baud" (number->string baud-rate))
1075 (list (string-append "--" type)
1077 (list (shepherd-service
1078 (provision '(inputattach))
1079 (requirement '(udev))
1080 (documentation "inputattach daemon")
1081 (start #~(make-forkexec-constructor
1082 (cons (string-append #$inputattach
1085 #:log-file #$log-file))
1086 (stop #~(make-kill-destructor))))))))
1088 (define inputattach-service-type
1092 (list (service-extension shepherd-root-service-type
1093 inputattach-shepherd-service)))
1094 (default-value (inputattach-configuration))
1095 (description "Return a service that runs inputattach on a device and
1096 dispatches events from it.")))
1100 ;;; gnome-keyring-service-type
1103 (define-record-type* <gnome-keyring-configuration> gnome-keyring-configuration
1104 make-gnome-keyring-configuration
1105 gnome-keyring-configuration?
1106 (keyring gnome-keyring-package (default gnome-keyring))
1107 (pam-services gnome-keyring-pam-services (default '(("gdm-password" . login)
1108 ("passwd" . passwd)))))
1110 (define (pam-gnome-keyring config)
1111 (define (%pam-keyring-entry . arguments)
1113 (control "optional")
1114 (module (file-append (gnome-keyring-package config)
1115 "/lib/security/pam_gnome_keyring.so"))
1116 (arguments arguments)))
1120 (case (assoc-ref (gnome-keyring-pam-services config)
1121 (pam-service-name service))
1125 (auth (append (pam-service-auth service)
1126 (list (%pam-keyring-entry))))
1127 (session (append (pam-service-session service)
1128 (list (%pam-keyring-entry "auto_start"))))))
1132 (password (append (pam-service-password service)
1133 (list (%pam-keyring-entry))))))
1136 (define gnome-keyring-service-type
1138 (name 'gnome-keyring)
1140 (service-extension pam-root-service-type pam-gnome-keyring)))
1141 (default-value (gnome-keyring-configuration))
1142 (description "Return a service, that adds the @code{gnome-keyring} package
1143 to the system profile and extends PAM with entries using
1144 @code{pam_gnome_keyring.so}, unlocking a user's login keyring when they log in
1145 or setting its password with passwd.")))
1149 ;;; polkit-wheel-service -- Allow wheel group to perform admin actions
1152 (define polkit-wheel
1155 `(("share/polkit-1/rules.d/wheel.rules"
1158 "polkit.addAdminRule(function(action, subject) {
1159 return [\"unix-group:wheel\"];
1163 (define polkit-wheel-service
1164 (simple-service 'polkit-wheel polkit-service-type (list polkit-wheel)))
1168 ;;; The default set of desktop services.
1171 (define %desktop-services
1172 ;; List of services typically useful for a "desktop" use case.
1173 (cons* (service gdm-service-type)
1175 ;; Screen lockers are a pretty useful thing and these are small.
1176 (screen-locker-service slock)
1177 (screen-locker-service xlockmore "xlock")
1179 ;; Add udev rules for MTP devices so that non-root users can access
1181 (simple-service 'mtp udev-service-type (list libmtp))
1182 ;; Add udev rules for scanners.
1183 (service sane-service-type)
1184 ;; Add polkit rules, so that non-root users in the wheel group can
1185 ;; perform administrative tasks (similar to "sudo").
1186 polkit-wheel-service
1188 ;; NetworkManager and its applet.
1189 (service network-manager-service-type)
1190 (service wpa-supplicant-service-type) ;needed by NetworkManager
1191 (simple-service 'network-manager-applet
1192 profile-service-type
1193 (list network-manager-applet))
1194 (service modem-manager-service-type)
1195 (service usb-modeswitch-service-type)
1197 ;; The D-Bus clique.
1198 (service avahi-service-type)
1200 (service upower-service-type)
1201 (accountsservice-service)
1202 (service cups-pk-helper-service-type)
1203 (service colord-service-type)
1205 (service polkit-service-type)
1209 (service ntp-service-type)
1211 x11-socket-directory-service
1213 (service pulseaudio-service-type)
1214 (service alsa-service-type)
1218 ;;; desktop.scm ends here