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>
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 suckless)
52 #:use-module (gnu packages linux)
53 #:use-module (gnu packages libusb)
54 #:use-module (gnu packages mate)
55 #:use-module (gnu packages enlightenment)
56 #:use-module (guix deprecation)
57 #:use-module (guix records)
58 #:use-module (guix packages)
59 #:use-module (guix store)
60 #:use-module (guix utils)
61 #:use-module (guix gexp)
62 #:use-module (srfi srfi-1)
63 #:use-module (ice-9 match)
64 #:export (<upower-configuration>
67 upower-configuration-upower
68 upower-configuration-watts-up-pro?
69 upower-configuration-poll-batteries?
70 upower-configuration-ignore-lid?
71 upower-configuration-use-percentage-for-policy?
72 upower-configuration-percentage-low
73 upower-configuration-percentage-critical
74 upower-configuration-percentage-action
75 upower-configuration-time-low
76 upower-configuration-time-critical
77 upower-configuration-time-action
78 upower-configuration-critical-power-action
93 geoclue-configuration?
94 %standard-geoclue-applications
98 bluetooth-service-type
99 bluetooth-configuration
100 bluetooth-configuration?
103 elogind-configuration
104 elogind-configuration?
108 accountsservice-service-type
109 accountsservice-service
111 cups-pk-helper-service-type
113 gnome-desktop-configuration
114 gnome-desktop-configuration?
115 gnome-desktop-service
116 gnome-desktop-service-type
118 mate-desktop-configuration
119 mate-desktop-configuration?
121 mate-desktop-service-type
123 xfce-desktop-configuration
124 xfce-desktop-configuration?
126 xfce-desktop-service-type
128 x11-socket-directory-service
130 enlightenment-desktop-configuration
131 enlightenment-desktop-configuration?
132 enlightenment-desktop-service-type
134 inputattach-configuration
135 inputattach-configuration?
136 inputattach-service-type
142 ;;; This module contains service definitions for a "desktop" environment.
152 (if value "true\n" "false\n"))
154 (define (package-direct-input-selector input)
156 (match (assoc-ref (package-direct-inputs package) input)
157 ((package . _) package))))
162 ;;; Upower D-Bus service.
165 (define-record-type* <upower-configuration>
166 upower-configuration make-upower-configuration
167 upower-configuration?
168 (upower upower-configuration-upower
170 (watts-up-pro? upower-configuration-watts-up-pro?
172 (poll-batteries? upower-configuration-poll-batteries?
174 (ignore-lid? upower-configuration-ignore-lid?
176 (use-percentage-for-policy? upower-configuration-use-percentage-for-policy?
178 (percentage-low upower-configuration-percentage-low
180 (percentage-critical upower-configuration-percentage-critical
182 (percentage-action upower-configuration-percentage-action
184 (time-low upower-configuration-time-low
186 (time-critical upower-configuration-time-critical
188 (time-action upower-configuration-time-action
190 (critical-power-action upower-configuration-critical-power-action
191 (default 'hybrid-sleep)))
193 (define* upower-configuration-file
194 ;; Return an upower-daemon configuration file.
196 (($ <upower-configuration> upower
197 watts-up-pro? poll-batteries? ignore-lid? use-percentage-for-policy?
198 percentage-low percentage-critical percentage-action time-low
199 time-critical time-action critical-power-action)
200 (plain-file "UPower.conf"
203 "EnableWattsUpPro=" (bool watts-up-pro?)
204 "NoPollBatteries=" (bool (not poll-batteries?))
205 "IgnoreLid=" (bool ignore-lid?)
206 "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
207 "PercentageLow=" (number->string percentage-low) "\n"
208 "PercentageCritical=" (number->string percentage-critical) "\n"
209 "PercentageAction=" (number->string percentage-action) "\n"
210 "TimeLow=" (number->string time-low) "\n"
211 "TimeCritical=" (number->string time-critical) "\n"
212 "TimeAction=" (number->string time-action) "\n"
213 "CriticalPowerAction=" (match critical-power-action
214 ('hybrid-sleep "HybridSleep")
215 ('hibernate "Hibernate")
216 ('power-off "PowerOff"))
219 (define %upower-activation
221 (use-modules (guix build utils))
222 (mkdir-p "/var/lib/upower")))
224 (define (upower-dbus-service config)
225 (list (wrapped-dbus-service (upower-configuration-upower config)
227 `(("UPOWER_CONF_FILE_NAME"
228 ,(upower-configuration-file config))))))
230 (define (upower-shepherd-service config)
231 "Return a shepherd service for UPower with CONFIG."
232 (let ((upower (upower-configuration-upower config))
233 (config (upower-configuration-file config)))
234 (list (shepherd-service
235 (documentation "Run the UPower power and battery monitor.")
236 (provision '(upower-daemon))
237 (requirement '(dbus-system udev))
239 (start #~(make-forkexec-constructor
240 (list (string-append #$upower "/libexec/upowerd"))
241 #:environment-variables
242 (list (string-append "UPOWER_CONF_FILE_NAME="
244 (stop #~(make-kill-destructor))))))
246 (define upower-service-type
247 (let ((upower-package (compose list upower-configuration-upower)))
248 (service-type (name 'upower)
250 "Run @command{upowerd}}, a system-wide monitor for power
251 consumption and battery levels, with the given configuration settings. It
252 implements the @code{org.freedesktop.UPower} D-Bus interface, and is notably
255 (list (service-extension dbus-root-service-type
257 (service-extension shepherd-root-service-type
258 upower-shepherd-service)
259 (service-extension activation-service-type
260 (const %upower-activation))
261 (service-extension udev-service-type
264 ;; Make the 'upower' command visible.
265 (service-extension profile-service-type
267 (default-value (upower-configuration)))))
269 (define-deprecated (upower-service #:key (upower upower)
273 (use-percentage-for-policy? #f)
275 (percentage-critical 3)
276 (percentage-action 2)
280 (critical-power-action 'hybrid-sleep))
282 "Return a service that runs @uref{http://upower.freedesktop.org/,
283 @command{upowerd}}, a system-wide monitor for power consumption and battery
284 levels, with the given configuration settings. It implements the
285 @code{org.freedesktop.UPower} D-Bus interface, and is notably used by GNOME."
286 (let ((config (upower-configuration
287 (watts-up-pro? watts-up-pro?)
288 (poll-batteries? poll-batteries?)
289 (ignore-lid? ignore-lid?)
290 (use-percentage-for-policy? use-percentage-for-policy?)
291 (percentage-low percentage-low)
292 (percentage-critical percentage-critical)
293 (percentage-action percentage-action)
295 (time-critical time-critical)
296 (time-action time-action)
297 (critical-power-action critical-power-action))))
298 (service upower-service-type config)))
302 ;;; GeoClue D-Bus service.
306 (define-record-type* <geoclue-configuration>
307 geoclue-configuration make-geoclue-configuration
308 geoclue-configuration?
309 (geoclue geoclue-configuration-geoclue
311 (whitelist geoclue-configuration-whitelist)
312 (wifi-geolocation-url geoclue-configuration-wifi-geolocation-url)
313 (submit-data? geoclue-configuration-submit-data?)
314 (wifi-submission-url geoclue-configuration-wifi-submission-url)
315 (submission-nick geoclue-configuration-submission-nick)
316 (applications geoclue-configuration-applications))
318 (define* (geoclue-application name #:key (allowed? #t) system? (users '()))
319 "Configure default GeoClue access permissions for an application. NAME is
320 the Desktop ID of the application, without the .desktop part. If ALLOWED? is
321 true, the application will have access to location information by default.
322 The boolean SYSTEM? value indicates that an application is a system component
323 or not. Finally USERS is a list of UIDs of all users for which this
324 application is allowed location info access. An empty users list means all
328 "allowed=" (bool allowed?)
329 "system=" (bool system?)
330 "users=" (string-join users ";") "\n"))
332 (define %standard-geoclue-applications
333 (list (geoclue-application "gnome-datetime-panel" #:system? #t)
334 (geoclue-application "epiphany" #:system? #f)
335 (geoclue-application "firefox" #:system? #f)))
337 (define* (geoclue-configuration-file config)
338 "Return a geoclue configuration file."
339 (plain-file "geoclue.conf"
343 (string-join (geoclue-configuration-whitelist config)
346 "url=" (geoclue-configuration-wifi-geolocation-url config) "\n"
347 "submit-data=" (bool (geoclue-configuration-submit-data? config))
349 (geoclue-configuration-wifi-submission-url config) "\n"
351 (geoclue-configuration-submission-nick config)
353 (string-join (geoclue-configuration-applications config)
356 (define (geoclue-dbus-service config)
357 (list (wrapped-dbus-service (geoclue-configuration-geoclue config)
359 `(("GEOCLUE_CONFIG_FILE"
360 ,(geoclue-configuration-file config))))))
362 (define %geoclue-accounts
363 (list (user-group (name "geoclue") (system? #t))
368 (comment "GeoClue daemon user")
369 (home-directory "/var/empty")
370 (shell "/run/current-system/profile/sbin/nologin"))))
372 (define geoclue-service-type
373 (service-type (name 'geoclue)
375 (list (service-extension dbus-root-service-type
376 geoclue-dbus-service)
377 (service-extension account-service-type
378 (const %geoclue-accounts))))))
380 (define* (geoclue-service #:key (geoclue geoclue)
382 (wifi-geolocation-url
383 ;; Mozilla geolocation service:
384 "https://location.services.mozilla.com/v1/geolocate?key=geoclue")
387 "https://location.services.mozilla.com/v1/submit?key=geoclue")
388 (submission-nick "geoclue")
389 (applications %standard-geoclue-applications))
390 "Return a service that runs the @command{geoclue} location service. This
391 service provides a D-Bus interface to allow applications to request access to
392 a user's physical location, and optionally to add information to online
393 location databases. By default, only the GNOME date-time panel and the Icecat
394 and Epiphany web browsers are able to ask for the user's location, and in the
395 case of Icecat and Epiphany, both will ask the user for permission first. See
396 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the geoclue web
397 site} for more information."
398 (service geoclue-service-type
399 (geoclue-configuration
401 (whitelist whitelist)
402 (wifi-geolocation-url wifi-geolocation-url)
403 (submit-data? submit-data?)
404 (wifi-submission-url wifi-submission-url)
405 (submission-nick submission-nick)
406 (applications applications))))
413 (define-record-type* <bluetooth-configuration>
414 bluetooth-configuration make-bluetooth-configuration
415 bluetooth-configuration?
416 (bluez bluetooth-configuration-bluez (default bluez))
417 (auto-enable? bluetooth-configuration-auto-enable? (default #f)))
419 (define (bluetooth-configuration-file config)
420 "Return a configuration file for the systemd bluetooth service, as a string."
423 "AutoEnable=" (bool (bluetooth-configuration-auto-enable?
426 (define (bluetooth-directory config)
427 (computed-file "etc-bluetooth"
431 (call-with-output-file "main.conf"
433 (display #$(bluetooth-configuration-file config)
436 (define (bluetooth-shepherd-service config)
437 "Return a shepherd service for @command{bluetoothd}."
439 (provision '(bluetooth))
440 (requirement '(dbus-system udev))
441 (documentation "Run the bluetoothd daemon.")
442 (start #~(make-forkexec-constructor
443 (string-append #$(bluetooth-configuration-bluez config)
444 "/libexec/bluetooth/bluetoothd")))
445 (stop #~(make-kill-destructor))))
447 (define bluetooth-service-type
451 (list (service-extension dbus-root-service-type
452 (compose list bluetooth-configuration-bluez))
453 (service-extension udev-service-type
454 (compose list bluetooth-configuration-bluez))
455 (service-extension etc-service-type
458 ,(bluetooth-directory config)))))
459 (service-extension shepherd-root-service-type
460 (compose list bluetooth-shepherd-service))))
461 (description "Run the @command{bluetoothd} daemon, which manages all the
462 Bluetooth devices and provides a number of D-Bus interfaces.")))
464 (define* (bluetooth-service #:key (bluez bluez) (auto-enable? #f))
465 "Return a service that runs the @command{bluetoothd} daemon, which manages
466 all the Bluetooth devices and provides a number of D-Bus interfaces. When
467 AUTO-ENABLE? is true, the bluetooth controller is powered automatically at
470 Users need to be in the @code{lp} group to access the D-Bus service.
472 (service bluetooth-service-type
473 (bluetooth-configuration
475 (auto-enable? auto-enable?))))
479 ;;; Colord D-Bus service.
482 (define %colord-activation
484 (use-modules (guix build utils))
485 (mkdir-p "/var/lib/colord")
486 (let ((user (getpwnam "colord")))
487 (chown "/var/lib/colord"
488 (passwd:uid user) (passwd:gid user)))))
490 (define %colord-accounts
491 (list (user-group (name "colord") (system? #t))
496 (comment "colord daemon user")
497 (home-directory "/var/empty")
498 (shell (file-append shadow "/sbin/nologin")))))
500 (define colord-service-type
501 (service-type (name 'colord)
503 (list (service-extension account-service-type
504 (const %colord-accounts))
505 (service-extension activation-service-type
506 (const %colord-activation))
508 ;; Colord is a D-Bus service that dbus-daemon can
510 (service-extension dbus-root-service-type list)
512 ;; Colord provides "color device" rules for udev.
513 (service-extension udev-service-type list)
515 ;; It provides polkit "actions".
516 (service-extension polkit-service-type list)))
518 "Run @command{colord}, a system service with a D-Bus
519 interface to manage the color profiles of input and output devices such as
520 screens and scanners.")))
522 (define* (colord-service #:key (colord colord))
523 "Return a service that runs @command{colord}, a system service with a D-Bus
524 interface to manage the color profiles of input and output devices such as
525 screens and scanners. It is notably used by the GNOME Color Manager graphical
526 tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
527 site} for more information."
528 (service colord-service-type colord))
535 (define-record-type* <udisks-configuration>
536 udisks-configuration make-udisks-configuration
537 udisks-configuration?
538 (udisks udisks-configuration-udisks
541 (define %udisks-activation
542 (with-imported-modules '((guix build utils))
544 (use-modules (guix build utils))
546 (let ((run-dir "/var/run/udisks2"))
548 (chmod run-dir #o700)))))
550 (define udisks-service-type
551 (let ((udisks-package (lambda (config)
552 (list (udisks-configuration-udisks config)))))
553 (service-type (name 'udisks)
555 (list (service-extension polkit-service-type
557 (service-extension dbus-root-service-type
559 (service-extension udev-service-type
561 (service-extension activation-service-type
562 (const %udisks-activation))
564 ;; Profile 'udisksctl' & co. in the system profile.
565 (service-extension profile-service-type
568 (define* (udisks-service #:key (udisks udisks))
569 "Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
570 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
571 notifications and ways to mount/unmount disks. Programs that talk to UDisks
572 include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
573 (service udisks-service-type
574 (udisks-configuration (udisks udisks))))
578 ;;; Elogind login and seat management service.
581 (define-record-type* <elogind-configuration> elogind-configuration
582 make-elogind-configuration
583 elogind-configuration?
584 (elogind elogind-package
586 (kill-user-processes? elogind-kill-user-processes?
588 (kill-only-users elogind-kill-only-users
590 (kill-exclude-users elogind-kill-exclude-users
592 (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds
594 (handle-power-key elogind-handle-power-key
596 (handle-suspend-key elogind-handle-suspend-key
598 (handle-hibernate-key elogind-handle-hibernate-key
599 ;; (default 'hibernate)
600 ;; XXX Ignore it for now, since we don't
601 ;; yet handle resume-from-hibernation in
604 (handle-lid-switch elogind-handle-lid-switch
606 (handle-lid-switch-docked elogind-handle-lid-switch-docked
608 (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited?
610 (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited?
612 (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited?
614 (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited?
616 (holdoff-timeout-seconds elogind-holdoff-timeout-seconds
618 (idle-action elogind-idle-action
620 (idle-action-seconds elogind-idle-action-seconds
622 (runtime-directory-size-percent elogind-runtime-directory-size-percent
624 (runtime-directory-size elogind-runtime-directory-size
626 (remove-ipc? elogind-remove-ipc?
629 (suspend-state elogind-suspend-state
630 (default '("mem" "standby" "freeze")))
631 (suspend-mode elogind-suspend-mode
633 (hibernate-state elogind-hibernate-state
635 (hibernate-mode elogind-hibernate-mode
636 (default '("platform" "shutdown")))
637 (hybrid-sleep-state elogind-hybrid-sleep-state
639 (hybrid-sleep-mode elogind-hybrid-sleep-mode
641 '("suspend" "platform" "shutdown"))))
643 (define (elogind-configuration-file config)
648 (_ (error "expected #t or #f, instead got:" x))))
649 (define char-set:user-name
650 (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-"))
651 (define (valid-list? l pred)
652 (and-map (lambda (x) (string-every pred x)) l))
653 (define (user-name-list users)
654 (unless (valid-list? users char-set:user-name)
655 (error "invalid user list" users))
656 (string-join users " "))
657 (define (enum val allowed)
658 (unless (memq val allowed)
659 (error "invalid value" val allowed))
660 (symbol->string val))
661 (define (non-negative-integer x)
662 (unless (exact-integer? x) (error "not an integer" x))
663 (when (negative? x) (error "negative number not allowed" x))
665 (define handle-actions
666 '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
667 (define (handle-action x)
668 (enum x handle-actions))
669 (define (sleep-list tokens)
670 (unless (valid-list? tokens char-set:user-name)
671 (error "invalid sleep list" tokens))
672 (string-join tokens " "))
673 (define-syntax ini-file-clause
675 ((_ config (prop (parser getter)))
676 (string-append prop "=" (parser (getter config)) "\n"))
678 (string-append str "\n"))))
679 (define-syntax-rule (ini-file config file clause ...)
680 (plain-file file (string-append (ini-file-clause config clause) ...)))
684 ("KillUserProcesses" (yesno elogind-kill-user-processes?))
685 ("KillOnlyUsers" (user-name-list elogind-kill-only-users))
686 ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users))
687 ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds))
688 ("HandlePowerKey" (handle-action elogind-handle-power-key))
689 ("HandleSuspendKey" (handle-action elogind-handle-suspend-key))
690 ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key))
691 ("HandleLidSwitch" (handle-action elogind-handle-lid-switch))
692 ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked))
693 ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?))
694 ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?))
695 ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?))
696 ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?))
697 ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds))
698 ("IdleAction" (handle-action elogind-idle-action))
699 ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds))
700 ("RuntimeDirectorySize"
703 (match (elogind-runtime-directory-size-percent config)
704 (#f (non-negative-integer (elogind-runtime-directory-size config)))
705 (percent (string-append (non-negative-integer percent) "%"))))))
706 ("RemoveIPC" (yesno elogind-remove-ipc?))
708 ("SuspendState" (sleep-list elogind-suspend-state))
709 ("SuspendMode" (sleep-list elogind-suspend-mode))
710 ("HibernateState" (sleep-list elogind-hibernate-state))
711 ("HibernateMode" (sleep-list elogind-hibernate-mode))
712 ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state))
713 ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
715 (define (elogind-dbus-service config)
716 (list (wrapped-dbus-service (elogind-package config)
717 "libexec/elogind/elogind"
718 `(("ELOGIND_CONF_FILE"
719 ,(elogind-configuration-file config))))))
721 (define (pam-extension-procedure config)
722 "Return an extension for PAM-ROOT-SERVICE-TYPE that ensures that all the PAM
723 services use 'pam_elogind.so', a module that allows elogind to keep track of
724 logged-in users (run 'loginctl' to see elogind's world view of users and
729 (module (file-append (elogind-package config)
730 "/lib/security/pam_elogind.so"))))
735 (session (cons pam-elogind (pam-service-session pam)))))))
737 (define (elogind-shepherd-service config)
738 "Return a Shepherd service to start elogind according to @var{config}."
739 (list (shepherd-service
740 (requirement '(dbus-system))
741 (provision '(elogind))
742 (start #~(make-forkexec-constructor
743 (list #$(file-append (elogind-package config)
744 "/libexec/elogind/elogind"))
745 #:environment-variables
746 (list (string-append "ELOGIND_CONF_FILE="
747 #$(elogind-configuration-file
749 (stop #~(make-kill-destructor)))))
751 (define elogind-service-type
752 (service-type (name 'elogind)
754 (list (service-extension dbus-root-service-type
755 elogind-dbus-service)
756 (service-extension udev-service-type
757 (compose list elogind-package))
758 (service-extension polkit-service-type
759 (compose list elogind-package))
761 ;; Start elogind from the Shepherd rather than waiting
762 ;; for bus activation. This ensures that it can handle
763 ;; events like lid close, etc.
764 (service-extension shepherd-root-service-type
765 elogind-shepherd-service)
767 ;; Provide the 'loginctl' command.
768 (service-extension profile-service-type
769 (compose list elogind-package))
771 ;; Extend PAM with pam_elogind.so.
772 (service-extension pam-root-service-type
773 pam-extension-procedure)
775 ;; We need /run/user, /run/systemd, etc.
776 (service-extension file-system-service-type
777 (const %elogind-file-systems))))
778 (default-value (elogind-configuration))))
780 (define* (elogind-service #:key (config (elogind-configuration)))
781 "Return a service that runs the @command{elogind} login and seat management
782 service. The @command{elogind} service integrates with PAM to allow other
783 system components to know the set of logged-in users as well as their session
784 types (graphical, console, remote, etc.). It can also clean up after users
786 (service elogind-service-type config))
790 ;;; AccountsService service.
793 (define %accountsservice-activation
795 (use-modules (guix build utils))
796 (mkdir-p "/var/lib/AccountsService")))
798 (define accountsservice-service-type
799 (service-type (name 'accountsservice)
801 (list (service-extension activation-service-type
802 (const %accountsservice-activation))
803 (service-extension dbus-root-service-type list)
804 (service-extension polkit-service-type list)))))
806 (define* (accountsservice-service #:key (accountsservice accountsservice))
807 "Return a service that runs AccountsService, a system service that
808 can list available accounts, change their passwords, and so on.
809 AccountsService integrates with PolicyKit to enable unprivileged users to
810 acquire the capability to modify their system configuration.
811 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
812 accountsservice web site} for more information."
813 (service accountsservice-service-type accountsservice))
817 ;;; cups-pk-helper service.
820 (define cups-pk-helper-service-type
822 (name 'cups-pk-helper)
824 "PolicyKit helper to configure CUPS with fine-grained privileges.")
826 (list (service-extension dbus-root-service-type list)
827 (service-extension polkit-service-type list)))
828 (default-value cups-pk-helper)))
832 ;;; GNOME desktop service.
835 (define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration
836 make-gnome-desktop-configuration
837 gnome-desktop-configuration?
838 (gnome-package gnome-package (default gnome)))
840 (define (gnome-polkit-settings config)
841 "Return the list of GNOME dependencies that provide polkit actions and
843 (let ((gnome (gnome-package config)))
845 ((package-direct-input-selector name) gnome))
846 '("gnome-settings-daemon"
847 "gnome-control-center"
848 "gnome-system-monitor"
851 (define gnome-desktop-service-type
853 (name 'gnome-desktop)
855 (list (service-extension polkit-service-type
856 gnome-polkit-settings)
857 (service-extension profile-service-type
860 (default-value (gnome-desktop-configuration))
861 (description "Run the GNOME desktop environment.")))
863 (define-deprecated (gnome-desktop-service #:key (config
864 (gnome-desktop-configuration)))
865 gnome-desktop-service-type
866 "Return a service that adds the @code{gnome} package to the system profile,
867 and extends polkit with the actions from @code{gnome-settings-daemon}."
868 (service gnome-desktop-service-type config))
870 ;; MATE Desktop service.
871 ;; TODO: Add mate-screensaver.
873 (define-record-type* <mate-desktop-configuration> mate-desktop-configuration
874 make-mate-desktop-configuration
875 mate-desktop-configuration?
876 (mate-package mate-package (default mate)))
878 (define mate-desktop-service-type
882 (list (service-extension polkit-service-type
884 (package-direct-input-selector
885 "mate-settings-daemon")
887 (service-extension profile-service-type
890 (default-value (mate-desktop-configuration))
891 (description "Run the MATE desktop environment.")))
893 (define-deprecated (mate-desktop-service #:key
895 (mate-desktop-configuration)))
896 mate-desktop-service-type
897 "Return a service that adds the @code{mate} package to the system profile,
898 and extends polkit with the actions from @code{mate-settings-daemon}."
899 (service mate-desktop-service-type config))
903 ;;; XFCE desktop service.
906 (define-record-type* <xfce-desktop-configuration> xfce-desktop-configuration
907 make-xfce-desktop-configuration
908 xfce-desktop-configuration?
909 (xfce xfce-package (default xfce)))
911 (define (xfce-polkit-settings config)
912 "Return the list of XFCE dependencies that provide polkit actions and
914 (let ((xfce (xfce-package config)))
916 ((package-direct-input-selector name) xfce))
918 "xfce4-power-manager"))))
920 (define xfce-desktop-service-type
924 (list (service-extension polkit-service-type
925 xfce-polkit-settings)
926 (service-extension profile-service-type
927 (compose list xfce-package))))
928 (default-value (xfce-desktop-configuration))
929 (description "Run the Xfce desktop environment.")))
931 (define-deprecated (xfce-desktop-service #:key (config
932 (xfce-desktop-configuration)))
933 xfce-desktop-service-type
934 "Return a service that adds the @code{xfce} package to the system profile,
935 and extends polkit with the ability for @code{thunar} to manipulate the file
936 system as root from within a user session, after the user has authenticated
937 with the administrator's password."
938 (service xfce-desktop-service-type config))
942 ;;; X11 socket directory service
945 (define x11-socket-directory-service
946 ;; Return a service that creates /tmp/.X11-unix. When using X11, libxcb
947 ;; takes care of creating that directory. However, when using XWayland, we
948 ;; need to create beforehand. Thus, create it unconditionally here.
949 (simple-service 'x11-socket-directory
950 activation-service-type
951 (with-imported-modules '((guix build utils))
953 (use-modules (guix build utils))
954 (let ((directory "/tmp/.X11-unix"))
956 (chmod directory #o777))))))
959 ;;; Enlightenment desktop service.
962 (define-record-type* <enlightenment-desktop-configuration>
963 enlightenment-desktop-configuration make-enlightenment-desktop-configuration
964 enlightenment-desktop-configuration?
966 (enlightenment enlightenment-package
967 (default enlightenment)))
969 (define (enlightenment-setuid-programs enlightenment-desktop-configuration)
970 (match-record enlightenment-desktop-configuration
971 <enlightenment-desktop-configuration>
973 (let ((module-arch (match (string-tokenize (%current-system)
974 (char-set-complement (char-set #\-)))
975 ((arch "linux") (string-append "linux-gnu-" arch))
976 ((arch "gnu") (string-append "gnu-" arch)))))
977 (list (file-append enlightenment
978 "/lib/enlightenment/utils/enlightenment_sys")
979 (file-append enlightenment
980 "/lib/enlightenment/utils/enlightenment_backlight")
981 ;; TODO: Move this binary to a screen-locker service.
982 (file-append enlightenment
983 "/lib/enlightenment/utils/enlightenment_ckpasswd")
984 (file-append enlightenment
986 "/lib/enlightenment/modules/cpufreq/"
988 (package-version enlightenment)
990 (file-append enlightenment
992 "/lib/enlightenment/modules/sysinfo/"
994 (package-version enlightenment)
995 "/cpuclock_sysfs"))))))
997 (define enlightenment-desktop-service-type
999 (name 'enlightenment-desktop)
1001 (list (service-extension dbus-root-service-type
1003 (package-direct-input-selector
1005 enlightenment-package))
1006 (service-extension setuid-program-service-type
1007 enlightenment-setuid-programs)
1008 (service-extension profile-service-type
1010 enlightenment-package))))
1011 (default-value (enlightenment-desktop-configuration))
1013 "Return a service that adds the @code{enlightenment} package to the system
1014 profile, and extends dbus with the ability for @code{efl} to generate
1015 thumbnails and makes setuid the programs which enlightenment needs to function
1020 ;;; inputattach-service-type
1023 (define-record-type* <inputattach-configuration>
1024 inputattach-configuration
1025 make-inputattach-configuration
1026 inputattach-configuration?
1027 (device-type inputattach-configuration-device-type
1029 (device inputattach-configuration-device
1030 (default "/dev/ttyS0"))
1031 (baud-rate inputattach-configuration-baud-rate
1033 (log-file inputattach-configuration-log-file
1036 (define inputattach-shepherd-service
1038 (($ <inputattach-configuration> type device baud-rate log-file)
1039 (let ((args (append (if baud-rate
1040 (list "--baud-rate" (number->string baud-rate))
1042 (list (string-append "--" type)
1044 (list (shepherd-service
1045 (provision '(inputattach))
1046 (requirement '(udev))
1047 (documentation "inputattach daemon")
1048 (start #~(make-forkexec-constructor
1049 (cons (string-append #$inputattach
1052 #:log-file #$log-file))
1053 (stop #~(make-kill-destructor))))))))
1055 (define inputattach-service-type
1059 (list (service-extension shepherd-root-service-type
1060 inputattach-shepherd-service)))
1061 (default-value (inputattach-configuration))
1062 (description "Return a service that runs inputattach on a device and
1063 dispatches events from it.")))
1067 ;;; The default set of desktop services.
1070 (define %desktop-services
1071 ;; List of services typically useful for a "desktop" use case.
1072 (cons* (service gdm-service-type)
1074 ;; Screen lockers are a pretty useful thing and these are small.
1075 (screen-locker-service slock)
1076 (screen-locker-service xlockmore "xlock")
1078 ;; Add udev rules for MTP devices so that non-root users can access
1080 (simple-service 'mtp udev-service-type (list libmtp))
1082 ;; NetworkManager and its applet.
1083 (service network-manager-service-type)
1084 (service wpa-supplicant-service-type) ;needed by NetworkManager
1085 (simple-service 'network-manager-applet
1086 profile-service-type
1087 (list network-manager-applet))
1088 (service modem-manager-service-type)
1089 (service usb-modeswitch-service-type)
1091 ;; The D-Bus clique.
1092 (service avahi-service-type)
1094 (service upower-service-type)
1095 (accountsservice-service)
1096 (service cups-pk-helper-service-type)
1099 (service polkit-service-type)
1103 (service ntp-service-type)
1105 x11-socket-directory-service
1107 (service alsa-service-type)
1111 ;;; desktop.scm ends here