1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 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>
13 ;;; This file is part of GNU Guix.
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28 (define-module (gnu services desktop)
29 #:use-module (gnu services)
30 #:use-module (gnu services shepherd)
31 #:use-module (gnu services base)
32 #:use-module (gnu services dbus)
33 #:use-module (gnu services avahi)
34 #:use-module (gnu services xorg)
35 #:use-module (gnu services networking)
36 #:use-module (gnu services sound)
37 #:use-module ((gnu system file-systems)
38 #:select (%elogind-file-systems))
39 #:use-module (gnu system)
40 #:use-module (gnu system shadow)
41 #:use-module (gnu system pam)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages admin)
44 #:use-module (gnu packages cups)
45 #:use-module (gnu packages freedesktop)
46 #:use-module (gnu packages gnome)
47 #:use-module (gnu packages xfce)
48 #:use-module (gnu packages avahi)
49 #:use-module (gnu packages xdisorg)
50 #:use-module (gnu packages suckless)
51 #:use-module (gnu packages linux)
52 #:use-module (gnu packages libusb)
53 #:use-module (gnu packages mate)
54 #:use-module (gnu packages enlightenment)
55 #:use-module (guix deprecation)
56 #:use-module (guix records)
57 #:use-module (guix packages)
58 #:use-module (guix store)
59 #:use-module (guix utils)
60 #:use-module (guix gexp)
61 #:use-module (srfi srfi-1)
62 #:use-module (ice-9 match)
63 #:export (<upower-configuration>
66 upower-configuration-upower
67 upower-configuration-watts-up-pro?
68 upower-configuration-poll-batteries?
69 upower-configuration-ignore-lid?
70 upower-configuration-use-percentage-for-policy?
71 upower-configuration-percentage-low
72 upower-configuration-percentage-critical
73 upower-configuration-percentage-action
74 upower-configuration-time-low
75 upower-configuration-time-critical
76 upower-configuration-time-action
77 upower-configuration-critical-power-action
92 geoclue-configuration?
93 %standard-geoclue-applications
97 bluetooth-service-type
98 bluetooth-configuration
99 bluetooth-configuration?
102 elogind-configuration
103 elogind-configuration?
107 accountsservice-service-type
108 accountsservice-service
110 cups-pk-helper-service-type
112 gnome-desktop-configuration
113 gnome-desktop-configuration?
114 gnome-desktop-service
115 gnome-desktop-service-type
117 mate-desktop-configuration
118 mate-desktop-configuration?
120 mate-desktop-service-type
122 xfce-desktop-configuration
123 xfce-desktop-configuration?
125 xfce-desktop-service-type
127 x11-socket-directory-service
129 enlightenment-desktop-configuration
130 enlightenment-desktop-configuration?
131 enlightenment-desktop-service-type
133 inputattach-configuration
134 inputattach-configuration?
135 inputattach-service-type
141 ;;; This module contains service definitions for a "desktop" environment.
151 (if value "true\n" "false\n"))
153 (define (package-direct-input-selector input)
155 (match (assoc-ref (package-direct-inputs package) input)
156 ((package . _) package))))
161 ;;; Upower D-Bus service.
164 (define-record-type* <upower-configuration>
165 upower-configuration make-upower-configuration
166 upower-configuration?
167 (upower upower-configuration-upower
169 (watts-up-pro? upower-configuration-watts-up-pro?
171 (poll-batteries? upower-configuration-poll-batteries?
173 (ignore-lid? upower-configuration-ignore-lid?
175 (use-percentage-for-policy? upower-configuration-use-percentage-for-policy?
177 (percentage-low upower-configuration-percentage-low
179 (percentage-critical upower-configuration-percentage-critical
181 (percentage-action upower-configuration-percentage-action
183 (time-low upower-configuration-time-low
185 (time-critical upower-configuration-time-critical
187 (time-action upower-configuration-time-action
189 (critical-power-action upower-configuration-critical-power-action
190 (default 'hybrid-sleep)))
192 (define* upower-configuration-file
193 ;; Return an upower-daemon configuration file.
195 (($ <upower-configuration> upower
196 watts-up-pro? poll-batteries? ignore-lid? use-percentage-for-policy?
197 percentage-low percentage-critical percentage-action time-low
198 time-critical time-action critical-power-action)
199 (plain-file "UPower.conf"
202 "EnableWattsUpPro=" (bool watts-up-pro?)
203 "NoPollBatteries=" (bool (not poll-batteries?))
204 "IgnoreLid=" (bool ignore-lid?)
205 "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
206 "PercentageLow=" (number->string percentage-low) "\n"
207 "PercentageCritical=" (number->string percentage-critical) "\n"
208 "PercentageAction=" (number->string percentage-action) "\n"
209 "TimeLow=" (number->string time-low) "\n"
210 "TimeCritical=" (number->string time-critical) "\n"
211 "TimeAction=" (number->string time-action) "\n"
212 "CriticalPowerAction=" (match critical-power-action
213 ('hybrid-sleep "HybridSleep")
214 ('hibernate "Hibernate")
215 ('power-off "PowerOff"))
218 (define %upower-activation
220 (use-modules (guix build utils))
221 (mkdir-p "/var/lib/upower")))
223 (define (upower-dbus-service config)
224 (list (wrapped-dbus-service (upower-configuration-upower config)
226 `(("UPOWER_CONF_FILE_NAME"
227 ,(upower-configuration-file config))))))
229 (define (upower-shepherd-service config)
230 "Return a shepherd service for UPower with CONFIG."
231 (let ((upower (upower-configuration-upower config))
232 (config (upower-configuration-file config)))
233 (list (shepherd-service
234 (documentation "Run the UPower power and battery monitor.")
235 (provision '(upower-daemon))
236 (requirement '(dbus-system udev))
238 (start #~(make-forkexec-constructor
239 (list (string-append #$upower "/libexec/upowerd"))
240 #:environment-variables
241 (list (string-append "UPOWER_CONF_FILE_NAME="
243 (stop #~(make-kill-destructor))))))
245 (define upower-service-type
246 (let ((upower-package (compose list upower-configuration-upower)))
247 (service-type (name 'upower)
249 "Run @command{upowerd}}, a system-wide monitor for power
250 consumption and battery levels, with the given configuration settings. It
251 implements the @code{org.freedesktop.UPower} D-Bus interface, and is notably
254 (list (service-extension dbus-root-service-type
256 (service-extension shepherd-root-service-type
257 upower-shepherd-service)
258 (service-extension activation-service-type
259 (const %upower-activation))
260 (service-extension udev-service-type
263 ;; Make the 'upower' command visible.
264 (service-extension profile-service-type
266 (default-value (upower-configuration)))))
268 (define-deprecated (upower-service #:key (upower upower)
272 (use-percentage-for-policy? #f)
274 (percentage-critical 3)
275 (percentage-action 2)
279 (critical-power-action 'hybrid-sleep))
281 "Return a service that runs @uref{http://upower.freedesktop.org/,
282 @command{upowerd}}, a system-wide monitor for power consumption and battery
283 levels, with the given configuration settings. It implements the
284 @code{org.freedesktop.UPower} D-Bus interface, and is notably used by GNOME."
285 (let ((config (upower-configuration
286 (watts-up-pro? watts-up-pro?)
287 (poll-batteries? poll-batteries?)
288 (ignore-lid? ignore-lid?)
289 (use-percentage-for-policy? use-percentage-for-policy?)
290 (percentage-low percentage-low)
291 (percentage-critical percentage-critical)
292 (percentage-action percentage-action)
294 (time-critical time-critical)
295 (time-action time-action)
296 (critical-power-action critical-power-action))))
297 (service upower-service-type config)))
301 ;;; GeoClue D-Bus service.
305 (define-record-type* <geoclue-configuration>
306 geoclue-configuration make-geoclue-configuration
307 geoclue-configuration?
308 (geoclue geoclue-configuration-geoclue
310 (whitelist geoclue-configuration-whitelist)
311 (wifi-geolocation-url geoclue-configuration-wifi-geolocation-url)
312 (submit-data? geoclue-configuration-submit-data?)
313 (wifi-submission-url geoclue-configuration-wifi-submission-url)
314 (submission-nick geoclue-configuration-submission-nick)
315 (applications geoclue-configuration-applications))
317 (define* (geoclue-application name #:key (allowed? #t) system? (users '()))
318 "Configure default GeoClue access permissions for an application. NAME is
319 the Desktop ID of the application, without the .desktop part. If ALLOWED? is
320 true, the application will have access to location information by default.
321 The boolean SYSTEM? value indicates that an application is a system component
322 or not. Finally USERS is a list of UIDs of all users for which this
323 application is allowed location info access. An empty users list means all
327 "allowed=" (bool allowed?)
328 "system=" (bool system?)
329 "users=" (string-join users ";") "\n"))
331 (define %standard-geoclue-applications
332 (list (geoclue-application "gnome-datetime-panel" #:system? #t)
333 (geoclue-application "epiphany" #:system? #f)
334 (geoclue-application "firefox" #:system? #f)))
336 (define* (geoclue-configuration-file config)
337 "Return a geoclue configuration file."
338 (plain-file "geoclue.conf"
342 (string-join (geoclue-configuration-whitelist config)
345 "url=" (geoclue-configuration-wifi-geolocation-url config) "\n"
346 "submit-data=" (bool (geoclue-configuration-submit-data? config))
348 (geoclue-configuration-wifi-submission-url config) "\n"
350 (geoclue-configuration-submission-nick config)
352 (string-join (geoclue-configuration-applications config)
355 (define (geoclue-dbus-service config)
356 (list (wrapped-dbus-service (geoclue-configuration-geoclue config)
358 `(("GEOCLUE_CONFIG_FILE"
359 ,(geoclue-configuration-file config))))))
361 (define %geoclue-accounts
362 (list (user-group (name "geoclue") (system? #t))
367 (comment "GeoClue daemon user")
368 (home-directory "/var/empty")
369 (shell "/run/current-system/profile/sbin/nologin"))))
371 (define geoclue-service-type
372 (service-type (name 'geoclue)
374 (list (service-extension dbus-root-service-type
375 geoclue-dbus-service)
376 (service-extension account-service-type
377 (const %geoclue-accounts))))))
379 (define* (geoclue-service #:key (geoclue geoclue)
381 (wifi-geolocation-url
382 ;; Mozilla geolocation service:
383 "https://location.services.mozilla.com/v1/geolocate?key=geoclue")
386 "https://location.services.mozilla.com/v1/submit?key=geoclue")
387 (submission-nick "geoclue")
388 (applications %standard-geoclue-applications))
389 "Return a service that runs the @command{geoclue} location service. This
390 service provides a D-Bus interface to allow applications to request access to
391 a user's physical location, and optionally to add information to online
392 location databases. By default, only the GNOME date-time panel and the Icecat
393 and Epiphany web browsers are able to ask for the user's location, and in the
394 case of Icecat and Epiphany, both will ask the user for permission first. See
395 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the geoclue web
396 site} for more information."
397 (service geoclue-service-type
398 (geoclue-configuration
400 (whitelist whitelist)
401 (wifi-geolocation-url wifi-geolocation-url)
402 (submit-data? submit-data?)
403 (wifi-submission-url wifi-submission-url)
404 (submission-nick submission-nick)
405 (applications applications))))
412 (define-record-type* <bluetooth-configuration>
413 bluetooth-configuration make-bluetooth-configuration
414 bluetooth-configuration?
415 (bluez bluetooth-configuration-bluez (default bluez))
416 (auto-enable? bluetooth-configuration-auto-enable? (default #f)))
418 (define (bluetooth-configuration-file config)
419 "Return a configuration file for the systemd bluetooth service, as a string."
422 "AutoEnable=" (bool (bluetooth-configuration-auto-enable?
425 (define (bluetooth-directory config)
426 (computed-file "etc-bluetooth"
430 (call-with-output-file "main.conf"
432 (display #$(bluetooth-configuration-file config)
435 (define (bluetooth-shepherd-service config)
436 "Return a shepherd service for @command{bluetoothd}."
438 (provision '(bluetooth))
439 (requirement '(dbus-system udev))
440 (documentation "Run the bluetoothd daemon.")
441 (start #~(make-forkexec-constructor
442 (string-append #$(bluetooth-configuration-bluez config)
443 "/libexec/bluetooth/bluetoothd")))
444 (stop #~(make-kill-destructor))))
446 (define bluetooth-service-type
450 (list (service-extension dbus-root-service-type
451 (compose list bluetooth-configuration-bluez))
452 (service-extension udev-service-type
453 (compose list bluetooth-configuration-bluez))
454 (service-extension etc-service-type
457 ,(bluetooth-directory config)))))
458 (service-extension shepherd-root-service-type
459 (compose list bluetooth-shepherd-service))))
460 (description "Run the @command{bluetoothd} daemon, which manages all the
461 Bluetooth devices and provides a number of D-Bus interfaces.")))
463 (define* (bluetooth-service #:key (bluez bluez) (auto-enable? #f))
464 "Return a service that runs the @command{bluetoothd} daemon, which manages
465 all the Bluetooth devices and provides a number of D-Bus interfaces. When
466 AUTO-ENABLE? is true, the bluetooth controller is powered automatically at
469 Users need to be in the @code{lp} group to access the D-Bus service.
471 (service bluetooth-service-type
472 (bluetooth-configuration
474 (auto-enable? auto-enable?))))
478 ;;; Colord D-Bus service.
481 (define %colord-activation
483 (use-modules (guix build utils))
484 (mkdir-p "/var/lib/colord")
485 (let ((user (getpwnam "colord")))
486 (chown "/var/lib/colord"
487 (passwd:uid user) (passwd:gid user)))))
489 (define %colord-accounts
490 (list (user-group (name "colord") (system? #t))
495 (comment "colord daemon user")
496 (home-directory "/var/empty")
497 (shell (file-append shadow "/sbin/nologin")))))
499 (define colord-service-type
500 (service-type (name 'colord)
502 (list (service-extension account-service-type
503 (const %colord-accounts))
504 (service-extension activation-service-type
505 (const %colord-activation))
507 ;; Colord is a D-Bus service that dbus-daemon can
509 (service-extension dbus-root-service-type list)
511 ;; Colord provides "color device" rules for udev.
512 (service-extension udev-service-type list)
514 ;; It provides polkit "actions".
515 (service-extension polkit-service-type list)))
517 "Run @command{colord}, a system service with a D-Bus
518 interface to manage the color profiles of input and output devices such as
519 screens and scanners.")))
521 (define* (colord-service #:key (colord colord))
522 "Return a service that runs @command{colord}, a system service with a D-Bus
523 interface to manage the color profiles of input and output devices such as
524 screens and scanners. It is notably used by the GNOME Color Manager graphical
525 tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
526 site} for more information."
527 (service colord-service-type colord))
534 (define-record-type* <udisks-configuration>
535 udisks-configuration make-udisks-configuration
536 udisks-configuration?
537 (udisks udisks-configuration-udisks
540 (define %udisks-activation
541 (with-imported-modules '((guix build utils))
543 (use-modules (guix build utils))
545 (let ((run-dir "/var/run/udisks2"))
547 (chmod run-dir #o700)))))
549 (define udisks-service-type
550 (let ((udisks-package (lambda (config)
551 (list (udisks-configuration-udisks config)))))
552 (service-type (name 'udisks)
554 (list (service-extension polkit-service-type
556 (service-extension dbus-root-service-type
558 (service-extension udev-service-type
560 (service-extension activation-service-type
561 (const %udisks-activation))
563 ;; Profile 'udisksctl' & co. in the system profile.
564 (service-extension profile-service-type
567 (define* (udisks-service #:key (udisks udisks))
568 "Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
569 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
570 notifications and ways to mount/unmount disks. Programs that talk to UDisks
571 include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
572 (service udisks-service-type
573 (udisks-configuration (udisks udisks))))
577 ;;; Elogind login and seat management service.
580 (define-record-type* <elogind-configuration> elogind-configuration
581 make-elogind-configuration
582 elogind-configuration
583 (elogind elogind-package
585 (kill-user-processes? elogind-kill-user-processes?
587 (kill-only-users elogind-kill-only-users
589 (kill-exclude-users elogind-kill-exclude-users
591 (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds
593 (handle-power-key elogind-handle-power-key
595 (handle-suspend-key elogind-handle-suspend-key
597 (handle-hibernate-key elogind-handle-hibernate-key
598 ;; (default 'hibernate)
599 ;; XXX Ignore it for now, since we don't
600 ;; yet handle resume-from-hibernation in
603 (handle-lid-switch elogind-handle-lid-switch
605 (handle-lid-switch-docked elogind-handle-lid-switch-docked
607 (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited?
609 (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited?
611 (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited?
613 (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited?
615 (holdoff-timeout-seconds elogind-holdoff-timeout-seconds
617 (idle-action elogind-idle-action
619 (idle-action-seconds elogind-idle-action-seconds
621 (runtime-directory-size-percent elogind-runtime-directory-size-percent
623 (runtime-directory-size elogind-runtime-directory-size
625 (remove-ipc? elogind-remove-ipc?
628 (suspend-state elogind-suspend-state
629 (default '("mem" "standby" "freeze")))
630 (suspend-mode elogind-suspend-mode
632 (hibernate-state elogind-hibernate-state
634 (hibernate-mode elogind-hibernate-mode
635 (default '("platform" "shutdown")))
636 (hybrid-sleep-state elogind-hybrid-sleep-state
638 (hybrid-sleep-mode elogind-hybrid-sleep-mode
640 '("suspend" "platform" "shutdown"))))
642 (define (elogind-configuration-file config)
647 (_ (error "expected #t or #f, instead got:" x))))
648 (define char-set:user-name
649 (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-"))
650 (define (valid-list? l pred)
651 (and-map (lambda (x) (string-every pred x)) l))
652 (define (user-name-list users)
653 (unless (valid-list? users char-set:user-name)
654 (error "invalid user list" users))
655 (string-join users " "))
656 (define (enum val allowed)
657 (unless (memq val allowed)
658 (error "invalid value" val allowed))
659 (symbol->string val))
660 (define (non-negative-integer x)
661 (unless (exact-integer? x) (error "not an integer" x))
662 (when (negative? x) (error "negative number not allowed" x))
664 (define handle-actions
665 '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
666 (define (handle-action x)
667 (enum x handle-actions))
668 (define (sleep-list tokens)
669 (unless (valid-list? tokens char-set:user-name)
670 (error "invalid sleep list" tokens))
671 (string-join tokens " "))
672 (define-syntax ini-file-clause
674 ((_ config (prop (parser getter)))
675 (string-append prop "=" (parser (getter config)) "\n"))
677 (string-append str "\n"))))
678 (define-syntax-rule (ini-file config file clause ...)
679 (plain-file file (string-append (ini-file-clause config clause) ...)))
683 ("KillUserProcesses" (yesno elogind-kill-user-processes?))
684 ("KillOnlyUsers" (user-name-list elogind-kill-only-users))
685 ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users))
686 ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds))
687 ("HandlePowerKey" (handle-action elogind-handle-power-key))
688 ("HandleSuspendKey" (handle-action elogind-handle-suspend-key))
689 ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key))
690 ("HandleLidSwitch" (handle-action elogind-handle-lid-switch))
691 ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked))
692 ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?))
693 ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?))
694 ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?))
695 ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?))
696 ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds))
697 ("IdleAction" (handle-action elogind-idle-action))
698 ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds))
699 ("RuntimeDirectorySize"
702 (match (elogind-runtime-directory-size-percent config)
703 (#f (non-negative-integer (elogind-runtime-directory-size config)))
704 (percent (string-append (non-negative-integer percent) "%"))))))
705 ("RemoveIPC" (yesno elogind-remove-ipc?))
707 ("SuspendState" (sleep-list elogind-suspend-state))
708 ("SuspendMode" (sleep-list elogind-suspend-mode))
709 ("HibernateState" (sleep-list elogind-hibernate-state))
710 ("HibernateMode" (sleep-list elogind-hibernate-mode))
711 ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state))
712 ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
714 (define (elogind-dbus-service config)
715 (list (wrapped-dbus-service (elogind-package config)
716 "libexec/elogind/elogind"
717 `(("ELOGIND_CONF_FILE"
718 ,(elogind-configuration-file config))))))
720 (define (pam-extension-procedure config)
721 "Return an extension for PAM-ROOT-SERVICE-TYPE that ensures that all the PAM
722 services use 'pam_elogind.so', a module that allows elogind to keep track of
723 logged-in users (run 'loginctl' to see elogind's world view of users and
728 (module (file-append (elogind-package config)
729 "/lib/security/pam_elogind.so"))))
734 (session (cons pam-elogind (pam-service-session pam)))))))
736 (define (elogind-shepherd-service config)
737 "Return a Shepherd service to start elogind according to @var{config}."
738 (list (shepherd-service
739 (requirement '(dbus-system))
740 (provision '(elogind))
741 (start #~(make-forkexec-constructor
742 (list #$(file-append (elogind-package config)
743 "/libexec/elogind/elogind"))
744 #:environment-variables
745 (list (string-append "ELOGIND_CONF_FILE="
746 #$(elogind-configuration-file
748 (stop #~(make-kill-destructor)))))
750 (define elogind-service-type
751 (service-type (name 'elogind)
753 (list (service-extension dbus-root-service-type
754 elogind-dbus-service)
755 (service-extension udev-service-type
756 (compose list elogind-package))
757 (service-extension polkit-service-type
758 (compose list elogind-package))
760 ;; Start elogind from the Shepherd rather than waiting
761 ;; for bus activation. This ensures that it can handle
762 ;; events like lid close, etc.
763 (service-extension shepherd-root-service-type
764 elogind-shepherd-service)
766 ;; Provide the 'loginctl' command.
767 (service-extension profile-service-type
768 (compose list elogind-package))
770 ;; Extend PAM with pam_elogind.so.
771 (service-extension pam-root-service-type
772 pam-extension-procedure)
774 ;; We need /run/user, /run/systemd, etc.
775 (service-extension file-system-service-type
776 (const %elogind-file-systems))))
777 (default-value (elogind-configuration))))
779 (define* (elogind-service #:key (config (elogind-configuration)))
780 "Return a service that runs the @command{elogind} login and seat management
781 service. The @command{elogind} service integrates with PAM to allow other
782 system components to know the set of logged-in users as well as their session
783 types (graphical, console, remote, etc.). It can also clean up after users
785 (service elogind-service-type config))
789 ;;; AccountsService service.
792 (define %accountsservice-activation
794 (use-modules (guix build utils))
795 (mkdir-p "/var/lib/AccountsService")))
797 (define accountsservice-service-type
798 (service-type (name 'accountsservice)
800 (list (service-extension activation-service-type
801 (const %accountsservice-activation))
802 (service-extension dbus-root-service-type list)
803 (service-extension polkit-service-type list)))))
805 (define* (accountsservice-service #:key (accountsservice accountsservice))
806 "Return a service that runs AccountsService, a system service that
807 can list available accounts, change their passwords, and so on.
808 AccountsService integrates with PolicyKit to enable unprivileged users to
809 acquire the capability to modify their system configuration.
810 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
811 accountsservice web site} for more information."
812 (service accountsservice-service-type accountsservice))
816 ;;; cups-pk-helper service.
819 (define cups-pk-helper-service-type
821 (name 'cups-pk-helper)
823 "PolicyKit helper to configure CUPS with fine-grained privileges.")
825 (list (service-extension dbus-root-service-type list)
826 (service-extension polkit-service-type list)))
827 (default-value cups-pk-helper)))
831 ;;; GNOME desktop service.
834 (define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration
835 make-gnome-desktop-configuration
836 gnome-desktop-configuration
837 (gnome-package gnome-package (default gnome)))
839 (define (gnome-polkit-settings config)
840 "Return the list of GNOME dependencies that provide polkit actions and
842 (let ((gnome (gnome-package config)))
844 ((package-direct-input-selector name) gnome))
845 '("gnome-settings-daemon"
846 "gnome-control-center"
847 "gnome-system-monitor"
850 (define gnome-desktop-service-type
852 (name 'gnome-desktop)
854 (list (service-extension polkit-service-type
855 gnome-polkit-settings)
856 (service-extension profile-service-type
859 (default-value (gnome-desktop-configuration))
860 (description "Run the GNOME desktop environment.")))
862 (define-deprecated (gnome-desktop-service #:key (config
863 (gnome-desktop-configuration)))
864 gnome-desktop-service-type
865 "Return a service that adds the @code{gnome} package to the system profile,
866 and extends polkit with the actions from @code{gnome-settings-daemon}."
867 (service gnome-desktop-service-type config))
869 ;; MATE Desktop service.
870 ;; TODO: Add mate-screensaver.
872 (define-record-type* <mate-desktop-configuration> mate-desktop-configuration
873 make-mate-desktop-configuration
874 mate-desktop-configuration
875 (mate-package mate-package (default mate)))
877 (define mate-desktop-service-type
881 (list (service-extension polkit-service-type
883 (package-direct-input-selector
884 "mate-settings-daemon")
886 (service-extension profile-service-type
889 (default-value (mate-desktop-configuration))
890 (description "Run the MATE desktop environment.")))
892 (define-deprecated (mate-desktop-service #:key
894 (mate-desktop-configuration)))
895 mate-desktop-service-type
896 "Return a service that adds the @code{mate} package to the system profile,
897 and extends polkit with the actions from @code{mate-settings-daemon}."
898 (service mate-desktop-service-type config))
902 ;;; XFCE desktop service.
905 (define-record-type* <xfce-desktop-configuration> xfce-desktop-configuration
906 make-xfce-desktop-configuration
907 xfce-desktop-configuration
908 (xfce xfce-package (default xfce)))
910 (define xfce-desktop-service-type
914 (list (service-extension polkit-service-type
916 (package-direct-input-selector
919 (service-extension profile-service-type
920 (compose list xfce-package))))
921 (default-value (xfce-desktop-configuration))
922 (description "Run the Xfce desktop environment.")))
924 (define-deprecated (xfce-desktop-service #:key (config
925 (xfce-desktop-configuration)))
926 xfce-desktop-service-type
927 "Return a service that adds the @code{xfce} package to the system profile,
928 and extends polkit with the ability for @code{thunar} to manipulate the file
929 system as root from within a user session, after the user has authenticated
930 with the administrator's password."
931 (service xfce-desktop-service-type config))
935 ;;; X11 socket directory service
938 (define x11-socket-directory-service
939 ;; Return a service that creates /tmp/.X11-unix. When using X11, libxcb
940 ;; takes care of creating that directory. However, when using XWayland, we
941 ;; need to create beforehand. Thus, create it unconditionally here.
942 (simple-service 'x11-socket-directory
943 activation-service-type
944 (with-imported-modules '((guix build utils))
946 (use-modules (guix build utils))
947 (let ((directory "/tmp/.X11-unix"))
949 (chmod directory #o777))))))
952 ;;; Enlightenment desktop service.
955 (define-record-type* <enlightenment-desktop-configuration>
956 enlightenment-desktop-configuration make-enlightenment-desktop-configuration
957 enlightenment-desktop-configuration?
959 (enlightenment enlightenment-package
960 (default enlightenment)))
962 (define (enlightenment-setuid-programs enlightenment-desktop-configuration)
963 (match-record enlightenment-desktop-configuration
964 <enlightenment-desktop-configuration>
966 (list (file-append enlightenment
967 "/lib/enlightenment/utils/enlightenment_sys")
968 (file-append enlightenment
969 "/lib/enlightenment/utils/enlightenment_backlight")
970 ;; TODO: Move this binary to a screen-locker service.
971 (file-append enlightenment
972 "/lib/enlightenment/utils/enlightenment_ckpasswd")
973 (file-append enlightenment
975 "/lib/enlightenment/modules/cpufreq/"
976 (match (string-tokenize (%current-system)
977 (char-set-complement (char-set #\-)))
978 ((arch "linux") (string-append "linux-gnu-" arch))
979 ((arch "gnu") (string-append "gnu-" arch)))
981 (version-major+minor (package-version enlightenment))
984 (define enlightenment-desktop-service-type
986 (name 'enlightenment-desktop)
988 (list (service-extension dbus-root-service-type
990 (package-direct-input-selector
992 enlightenment-package))
993 (service-extension setuid-program-service-type
994 enlightenment-setuid-programs)
995 (service-extension profile-service-type
997 enlightenment-package))))
998 (default-value (enlightenment-desktop-configuration))
1000 "Return a service that adds the @code{enlightenment} package to the system
1001 profile, and extends dbus with the ability for @code{efl} to generate
1002 thumbnails and makes setuid the programs which enlightenment needs to function
1007 ;;; inputattach-service-type
1010 (define-record-type* <inputattach-configuration>
1011 inputattach-configuration
1012 make-inputattach-configuration
1013 inputattach-configuration?
1014 (device-type inputattach-configuration-device-type
1016 (device inputattach-configuration-device
1017 (default "/dev/ttyS0"))
1018 (log-file inputattach-configuration-log-file
1021 (define inputattach-shepherd-service
1023 (($ <inputattach-configuration> type device log-file)
1024 (list (shepherd-service
1025 (provision '(inputattach))
1026 (requirement '(udev))
1027 (documentation "inputattach daemon")
1028 (start #~(make-forkexec-constructor
1029 (list (string-append #$inputattach
1031 (string-append "--" #$type)
1033 #:log-file #$log-file))
1034 (stop #~(make-kill-destructor)))))))
1036 (define inputattach-service-type
1040 (list (service-extension shepherd-root-service-type
1041 inputattach-shepherd-service)))
1042 (default-value (inputattach-configuration))
1043 (description "Return a service that runs inputattach on a device and
1044 dispatches events from it.")))
1048 ;;; The default set of desktop services.
1051 (define %desktop-services
1052 ;; List of services typically useful for a "desktop" use case.
1053 (cons* (service gdm-service-type)
1055 ;; Screen lockers are a pretty useful thing and these are small.
1056 (screen-locker-service slock)
1057 (screen-locker-service xlockmore "xlock")
1059 ;; Add udev rules for MTP devices so that non-root users can access
1061 (simple-service 'mtp udev-service-type (list libmtp))
1063 ;; NetworkManager and its applet.
1064 (service network-manager-service-type)
1065 (service wpa-supplicant-service-type) ;needed by NetworkManager
1066 (simple-service 'network-manager-applet
1067 profile-service-type
1068 (list network-manager-applet))
1069 (service modem-manager-service-type)
1071 ;; The D-Bus clique.
1072 (service avahi-service-type)
1074 (service upower-service-type)
1075 (accountsservice-service)
1076 (service cups-pk-helper-service-type)
1079 (service polkit-service-type)
1083 (service ntp-service-type)
1085 x11-socket-directory-service
1087 (service alsa-service-type)
1091 ;;; desktop.scm ends here