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 Nils Gillmann <ng0@n0.is>
8 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu services desktop)
27 #:use-module (gnu services)
28 #:use-module (gnu services shepherd)
29 #:use-module (gnu services base)
30 #:use-module (gnu services dbus)
31 #:use-module (gnu services avahi)
32 #:use-module (gnu services xorg)
33 #:use-module (gnu services networking)
34 #:use-module (gnu services sound)
35 #:use-module ((gnu system file-systems)
36 #:select (%elogind-file-systems))
37 #:use-module (gnu system)
38 #:use-module (gnu system shadow)
39 #:use-module (gnu system pam)
40 #:use-module (gnu packages glib)
41 #:use-module (gnu packages admin)
42 #:use-module (gnu packages freedesktop)
43 #:use-module (gnu packages gnome)
44 #:use-module (gnu packages xfce)
45 #:use-module (gnu packages avahi)
46 #:use-module (gnu packages xdisorg)
47 #:use-module (gnu packages suckless)
48 #:use-module (gnu packages linux)
49 #:use-module (gnu packages libusb)
50 #:use-module (gnu packages mate)
51 #:use-module (gnu packages enlightenment)
52 #:use-module (guix records)
53 #:use-module (guix packages)
54 #:use-module (guix store)
55 #:use-module (guix utils)
56 #:use-module (guix gexp)
57 #:use-module (srfi srfi-1)
58 #:use-module (ice-9 match)
59 #:export (upower-configuration
73 geoclue-configuration?
74 %standard-geoclue-applications
81 elogind-configuration?
85 accountsservice-service-type
86 accountsservice-service
88 gnome-desktop-configuration
89 gnome-desktop-configuration?
91 gnome-desktop-service-type
93 mate-desktop-configuration
94 mate-desktop-configuration?
96 mate-desktop-service-type
98 xfce-desktop-configuration
99 xfce-desktop-configuration?
101 xfce-desktop-service-type
103 x11-socket-directory-service
105 enlightenment-desktop-configuration
106 enlightenment-desktop-configuration?
107 enlightenment-desktop-service-type
113 ;;; This module contains service definitions for a "desktop" environment.
123 (if value "true\n" "false\n"))
125 (define (package-direct-input-selector input)
127 (match (assoc-ref (package-direct-inputs package) input)
128 ((package . _) package))))
131 (define (wrapped-dbus-service service program variable value)
132 "Return a wrapper for @var{service}, a package containing a D-Bus service,
133 where @var{program} is wrapped such that environment variable @var{variable}
134 is set to @var{value} when the bus daemon launches it."
136 (program-file (string-append (package-name service) "-program-wrapper")
138 (setenv #$variable #$value)
139 (apply execl (string-append #$service "/" #$program)
140 (string-append #$service "/" #$program)
141 (cdr (command-line))))))
144 (with-imported-modules '((guix build utils))
146 (use-modules (guix build utils))
148 (define service-directory
149 "/share/dbus-1/system-services")
151 (mkdir-p (dirname (string-append #$output
153 (copy-recursively (string-append #$service
155 (string-append #$output
157 (symlink (string-append #$service "/etc") ;for etc/dbus-1
158 (string-append #$output "/etc"))
160 (for-each (lambda (file)
162 (("Exec[[:blank:]]*=[[:blank:]]*([[:graph:]]+)(.*)$"
163 _ original-program arguments)
164 (string-append "Exec=" #$wrapper arguments
166 (find-files #$output "\\.service$")))))
168 (computed-file (string-append (package-name service) "-wrapper")
173 ;;; Upower D-Bus service.
177 (define-record-type* <upower-configuration>
178 upower-configuration make-upower-configuration
179 upower-configuration?
180 (upower upower-configuration-upower
182 (watts-up-pro? upower-configuration-watts-up-pro?)
183 (poll-batteries? upower-configuration-poll-batteries?)
184 (ignore-lid? upower-configuration-ignore-lid?)
185 (use-percentage-for-policy? upower-configuration-use-percentage-for-policy?)
186 (percentage-low upower-configuration-percentage-low)
187 (percentage-critical upower-configuration-percentage-critical)
188 (percentage-action upower-configuration-percentage-action)
189 (time-low upower-configuration-time-low)
190 (time-critical upower-configuration-time-critical)
191 (time-action upower-configuration-time-action)
192 (critical-power-action upower-configuration-critical-power-action))
194 (define* upower-configuration-file
195 ;; Return an upower-daemon configuration file.
197 (($ <upower-configuration> upower
198 watts-up-pro? poll-batteries? ignore-lid? use-percentage-for-policy?
199 percentage-low percentage-critical percentage-action time-low
200 time-critical time-action critical-power-action)
201 (plain-file "UPower.conf"
204 "EnableWattsUpPro=" (bool watts-up-pro?)
205 "NoPollBatteries=" (bool (not poll-batteries?))
206 "IgnoreLid=" (bool ignore-lid?)
207 "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
208 "PercentageLow=" (number->string percentage-low) "\n"
209 "PercentageCritical=" (number->string percentage-critical) "\n"
210 "PercentageAction=" (number->string percentage-action) "\n"
211 "TimeLow=" (number->string time-low) "\n"
212 "TimeCritical=" (number->string time-critical) "\n"
213 "TimeAction=" (number->string time-action) "\n"
214 "CriticalPowerAction=" (match critical-power-action
215 ('hybrid-sleep "HybridSleep")
216 ('hibernate "Hibernate")
217 ('power-off "PowerOff"))
220 (define %upower-activation
222 (use-modules (guix build utils))
223 (mkdir-p "/var/lib/upower")))
225 (define (upower-dbus-service config)
226 (list (wrapped-dbus-service (upower-configuration-upower config)
228 "UPOWER_CONF_FILE_NAME"
229 (upower-configuration-file config))))
231 (define (upower-shepherd-service config)
232 "Return a shepherd service for UPower with CONFIG."
233 (let ((upower (upower-configuration-upower config))
234 (config (upower-configuration-file config)))
235 (list (shepherd-service
236 (documentation "Run the UPower power and battery monitor.")
237 (provision '(upower-daemon))
238 (requirement '(dbus-system udev))
240 (start #~(make-forkexec-constructor
241 (list (string-append #$upower "/libexec/upowerd"))
242 #:environment-variables
243 (list (string-append "UPOWER_CONF_FILE_NAME="
245 (stop #~(make-kill-destructor))))))
247 (define upower-service-type
248 (let ((upower-package (compose list upower-configuration-upower)))
249 (service-type (name 'upower)
251 (list (service-extension dbus-root-service-type
253 (service-extension shepherd-root-service-type
254 upower-shepherd-service)
255 (service-extension activation-service-type
256 (const %upower-activation))
257 (service-extension udev-service-type
260 ;; Make the 'upower' command visible.
261 (service-extension profile-service-type
264 (define* (upower-service #:key (upower upower)
268 (use-percentage-for-policy? #f)
270 (percentage-critical 3)
271 (percentage-action 2)
275 (critical-power-action 'hybrid-sleep))
276 "Return a service that runs @uref{http://upower.freedesktop.org/,
277 @command{upowerd}}, a system-wide monitor for power consumption and battery
278 levels, with the given configuration settings. It implements the
279 @code{org.freedesktop.UPower} D-Bus interface, and is notably used by GNOME."
280 (let ((config (upower-configuration
281 (watts-up-pro? watts-up-pro?)
282 (poll-batteries? poll-batteries?)
283 (ignore-lid? ignore-lid?)
284 (use-percentage-for-policy? use-percentage-for-policy?)
285 (percentage-low percentage-low)
286 (percentage-critical percentage-critical)
287 (percentage-action percentage-action)
289 (time-critical time-critical)
290 (time-action time-action)
291 (critical-power-action critical-power-action))))
292 (service upower-service-type config)))
296 ;;; GeoClue D-Bus service.
300 (define-record-type* <geoclue-configuration>
301 geoclue-configuration make-geoclue-configuration
302 geoclue-configuration?
303 (geoclue geoclue-configuration-geoclue
305 (whitelist geoclue-configuration-whitelist)
306 (wifi-geolocation-url geoclue-configuration-wifi-geolocation-url)
307 (submit-data? geoclue-configuration-submit-data?)
308 (wifi-submission-url geoclue-configuration-wifi-submission-url)
309 (submission-nick geoclue-configuration-submission-nick)
310 (applications geoclue-configuration-applications))
312 (define* (geoclue-application name #:key (allowed? #t) system? (users '()))
313 "Configure default GeoClue access permissions for an application. NAME is
314 the Desktop ID of the application, without the .desktop part. If ALLOWED? is
315 true, the application will have access to location information by default.
316 The boolean SYSTEM? value indicates that an application is a system component
317 or not. Finally USERS is a list of UIDs of all users for which this
318 application is allowed location info access. An empty users list means all
322 "allowed=" (bool allowed?)
323 "system=" (bool system?)
324 "users=" (string-join users ";") "\n"))
326 (define %standard-geoclue-applications
327 (list (geoclue-application "gnome-datetime-panel" #:system? #t)
328 (geoclue-application "epiphany" #:system? #f)
329 (geoclue-application "firefox" #:system? #f)))
331 (define* (geoclue-configuration-file config)
332 "Return a geoclue configuration file."
333 (plain-file "geoclue.conf"
337 (string-join (geoclue-configuration-whitelist config)
340 "url=" (geoclue-configuration-wifi-geolocation-url config) "\n"
341 "submit-data=" (bool (geoclue-configuration-submit-data? config))
343 (geoclue-configuration-wifi-submission-url config) "\n"
345 (geoclue-configuration-submission-nick config)
347 (string-join (geoclue-configuration-applications config)
350 (define (geoclue-dbus-service config)
351 (list (wrapped-dbus-service (geoclue-configuration-geoclue config)
353 "GEOCLUE_CONFIG_FILE"
354 (geoclue-configuration-file config))))
356 (define %geoclue-accounts
357 (list (user-group (name "geoclue") (system? #t))
362 (comment "GeoClue daemon user")
363 (home-directory "/var/empty")
364 (shell "/run/current-system/profile/sbin/nologin"))))
366 (define geoclue-service-type
367 (service-type (name 'geoclue)
369 (list (service-extension dbus-root-service-type
370 geoclue-dbus-service)
371 (service-extension account-service-type
372 (const %geoclue-accounts))))))
374 (define* (geoclue-service #:key (geoclue geoclue)
376 (wifi-geolocation-url
377 ;; Mozilla geolocation service:
378 "https://location.services.mozilla.com/v1/geolocate?key=geoclue")
381 "https://location.services.mozilla.com/v1/submit?key=geoclue")
382 (submission-nick "geoclue")
383 (applications %standard-geoclue-applications))
384 "Return a service that runs the @command{geoclue} location service. This
385 service provides a D-Bus interface to allow applications to request access to
386 a user's physical location, and optionally to add information to online
387 location databases. By default, only the GNOME date-time panel and the Icecat
388 and Epiphany web browsers are able to ask for the user's location, and in the
389 case of Icecat and Epiphany, both will ask the user for permission first. See
390 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the geoclue web
391 site} for more information."
392 (service geoclue-service-type
393 (geoclue-configuration
395 (whitelist whitelist)
396 (wifi-geolocation-url wifi-geolocation-url)
397 (submit-data? submit-data?)
398 (wifi-submission-url wifi-submission-url)
399 (submission-nick submission-nick)
400 (applications applications))))
407 (define-record-type* <bluetooth-configuration>
408 bluetooth-configuration make-bluetooth-configuration
409 bluetooth-configuration?
410 (bluez bluetooth-configuration-bluez (default bluez))
411 (auto-enable? bluetooth-configuration-auto-enable? (default #f)))
413 (define (bluetooth-configuration-file config)
414 "Return a configuration file for the systemd bluetooth service, as a string."
417 "AutoEnable=" (bool (bluetooth-configuration-auto-enable?
420 (define (bluetooth-directory config)
421 (computed-file "etc-bluetooth"
425 (call-with-output-file "main.conf"
427 (display #$(bluetooth-configuration-file config)
430 (define (bluetooth-shepherd-service config)
431 "Return a shepherd service for @command{bluetoothd}."
433 (provision '(bluetooth))
434 (requirement '(dbus-system udev))
435 (documentation "Run the bluetoothd daemon.")
436 (start #~(make-forkexec-constructor
437 (string-append #$(bluetooth-configuration-bluez config)
438 "/libexec/bluetooth/bluetoothd")))
439 (stop #~(make-kill-destructor))))
441 (define bluetooth-service-type
445 (list (service-extension dbus-root-service-type
446 (compose list bluetooth-configuration-bluez))
447 (service-extension udev-service-type
448 (compose list bluetooth-configuration-bluez))
449 (service-extension etc-service-type
452 ,(bluetooth-directory config)))))
453 (service-extension shepherd-root-service-type
454 (compose list bluetooth-shepherd-service))))))
456 (define* (bluetooth-service #:key (bluez bluez) (auto-enable? #f))
457 "Return a service that runs the @command{bluetoothd} daemon, which manages
458 all the Bluetooth devices and provides a number of D-Bus interfaces. When
459 AUTO-ENABLE? is true, the bluetooth controller is powered automatically at
462 Users need to be in the @code{lp} group to access the D-Bus service.
464 (service bluetooth-service-type
465 (bluetooth-configuration
467 (auto-enable? auto-enable?))))
471 ;;; Colord D-Bus service.
474 (define %colord-activation
476 (use-modules (guix build utils))
477 (mkdir-p "/var/lib/colord")
478 (let ((user (getpwnam "colord")))
479 (chown "/var/lib/colord"
480 (passwd:uid user) (passwd:gid user)))))
482 (define %colord-accounts
483 (list (user-group (name "colord") (system? #t))
488 (comment "colord daemon user")
489 (home-directory "/var/empty")
490 (shell (file-append shadow "/sbin/nologin")))))
492 (define colord-service-type
493 (service-type (name 'colord)
495 (list (service-extension account-service-type
496 (const %colord-accounts))
497 (service-extension activation-service-type
498 (const %colord-activation))
500 ;; Colord is a D-Bus service that dbus-daemon can
502 (service-extension dbus-root-service-type list)
504 ;; Colord provides "color device" rules for udev.
505 (service-extension udev-service-type list)
507 ;; It provides polkit "actions".
508 (service-extension polkit-service-type list)))))
510 (define* (colord-service #:key (colord colord))
511 "Return a service that runs @command{colord}, a system service with a D-Bus
512 interface to manage the color profiles of input and output devices such as
513 screens and scanners. It is notably used by the GNOME Color Manager graphical
514 tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
515 site} for more information."
516 (service colord-service-type colord))
523 (define-record-type* <udisks-configuration>
524 udisks-configuration make-udisks-configuration
525 udisks-configuration?
526 (udisks udisks-configuration-udisks
529 (define %udisks-activation
530 (with-imported-modules '((guix build utils))
532 (use-modules (guix build utils))
534 (let ((run-dir "/var/run/udisks2"))
536 (chmod run-dir #o700)))))
538 (define udisks-service-type
539 (let ((udisks-package (lambda (config)
540 (list (udisks-configuration-udisks config)))))
541 (service-type (name 'udisks)
543 (list (service-extension polkit-service-type
545 (service-extension dbus-root-service-type
547 (service-extension udev-service-type
549 (service-extension activation-service-type
550 (const %udisks-activation))
552 ;; Profile 'udisksctl' & co. in the system profile.
553 (service-extension profile-service-type
556 (define* (udisks-service #:key (udisks udisks))
557 "Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
558 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
559 notifications and ways to mount/unmount disks. Programs that talk to UDisks
560 include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
561 (service udisks-service-type
562 (udisks-configuration (udisks udisks))))
566 ;;; Elogind login and seat management service.
569 (define-record-type* <elogind-configuration> elogind-configuration
570 make-elogind-configuration
571 elogind-configuration
572 (elogind elogind-package
574 (kill-user-processes? elogind-kill-user-processes?
576 (kill-only-users elogind-kill-only-users
578 (kill-exclude-users elogind-kill-exclude-users
580 (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds
582 (handle-power-key elogind-handle-power-key
584 (handle-suspend-key elogind-handle-suspend-key
586 (handle-hibernate-key elogind-handle-hibernate-key
587 ;; (default 'hibernate)
588 ;; XXX Ignore it for now, since we don't
589 ;; yet handle resume-from-hibernation in
592 (handle-lid-switch elogind-handle-lid-switch
594 (handle-lid-switch-docked elogind-handle-lid-switch-docked
596 (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited?
598 (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited?
600 (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited?
602 (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited?
604 (holdoff-timeout-seconds elogind-holdoff-timeout-seconds
606 (idle-action elogind-idle-action
608 (idle-action-seconds elogind-idle-action-seconds
610 (runtime-directory-size-percent elogind-runtime-directory-size-percent
612 (runtime-directory-size elogind-runtime-directory-size
614 (remove-ipc? elogind-remove-ipc?
617 (suspend-state elogind-suspend-state
618 (default '("mem" "standby" "freeze")))
619 (suspend-mode elogind-suspend-mode
621 (hibernate-state elogind-hibernate-state
623 (hibernate-mode elogind-hibernate-mode
624 (default '("platform" "shutdown")))
625 (hybrid-sleep-state elogind-hybrid-sleep-state
627 (hybrid-sleep-mode elogind-hybrid-sleep-mode
629 '("suspend" "platform" "shutdown"))))
631 (define (elogind-configuration-file config)
636 (_ (error "expected #t or #f, instead got:" x))))
637 (define char-set:user-name
638 (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-"))
639 (define (valid-list? l pred)
640 (and-map (lambda (x) (string-every pred x)) l))
641 (define (user-name-list users)
642 (unless (valid-list? users char-set:user-name)
643 (error "invalid user list" users))
644 (string-join users " "))
645 (define (enum val allowed)
646 (unless (memq val allowed)
647 (error "invalid value" val allowed))
648 (symbol->string val))
649 (define (non-negative-integer x)
650 (unless (exact-integer? x) (error "not an integer" x))
651 (when (negative? x) (error "negative number not allowed" x))
653 (define handle-actions
654 '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
655 (define (handle-action x)
656 (enum x handle-actions))
657 (define (sleep-list tokens)
658 (unless (valid-list? tokens char-set:user-name)
659 (error "invalid sleep list" tokens))
660 (string-join tokens " "))
661 (define-syntax ini-file-clause
663 ((_ config (prop (parser getter)))
664 (string-append prop "=" (parser (getter config)) "\n"))
666 (string-append str "\n"))))
667 (define-syntax-rule (ini-file config file clause ...)
668 (plain-file file (string-append (ini-file-clause config clause) ...)))
672 ("KillUserProcesses" (yesno elogind-kill-user-processes?))
673 ("KillOnlyUsers" (user-name-list elogind-kill-only-users))
674 ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users))
675 ("InhibitDelayMaxSec" (non-negative-integer elogind-inhibit-delay-max-seconds))
676 ("HandlePowerKey" (handle-action elogind-handle-power-key))
677 ("HandleSuspendKey" (handle-action elogind-handle-suspend-key))
678 ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key))
679 ("HandleLidSwitch" (handle-action elogind-handle-lid-switch))
680 ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked))
681 ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?))
682 ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?))
683 ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?))
684 ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?))
685 ("HoldoffTimeoutSec" (non-negative-integer elogind-holdoff-timeout-seconds))
686 ("IdleAction" (handle-action elogind-idle-action))
687 ("IdleActionSec" (non-negative-integer elogind-idle-action-seconds))
688 ("RuntimeDirectorySize"
691 (match (elogind-runtime-directory-size-percent config)
692 (#f (non-negative-integer (elogind-runtime-directory-size config)))
693 (percent (string-append (non-negative-integer percent) "%"))))))
694 ("RemoveIPC" (yesno elogind-remove-ipc?))
696 ("SuspendState" (sleep-list elogind-suspend-state))
697 ("SuspendMode" (sleep-list elogind-suspend-mode))
698 ("HibernateState" (sleep-list elogind-hibernate-state))
699 ("HibernateMode" (sleep-list elogind-hibernate-mode))
700 ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state))
701 ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
703 (define (elogind-dbus-service config)
704 (list (wrapped-dbus-service (elogind-package config)
705 "libexec/elogind/elogind"
707 (elogind-configuration-file config))))
709 (define (pam-extension-procedure config)
710 "Return an extension for PAM-ROOT-SERVICE-TYPE that ensures that all the PAM
711 services use 'pam_elogind.so', a module that allows elogind to keep track of
712 logged-in users (run 'loginctl' to see elogind's world view of users and
717 (module (file-append (elogind-package config)
718 "/lib/security/pam_elogind.so"))))
723 (session (cons pam-elogind (pam-service-session pam)))))))
725 (define (elogind-shepherd-service config)
726 "Return a Shepherd service to start elogind according to @var{config}."
727 (list (shepherd-service
728 (requirement '(dbus-system))
729 (provision '(elogind))
730 (start #~(make-forkexec-constructor
731 (list #$(file-append (elogind-package config)
732 "/libexec/elogind/elogind"))
733 #:environment-variables
734 (list (string-append "ELOGIND_CONF_FILE="
735 #$(elogind-configuration-file
737 (stop #~(make-kill-destructor)))))
739 (define elogind-service-type
740 (service-type (name 'elogind)
742 (list (service-extension dbus-root-service-type
743 elogind-dbus-service)
744 (service-extension udev-service-type
745 (compose list elogind-package))
746 (service-extension polkit-service-type
747 (compose list elogind-package))
749 ;; Start elogind from the Shepherd rather than waiting
750 ;; for bus activation. This ensures that it can handle
751 ;; events like lid close, etc.
752 (service-extension shepherd-root-service-type
753 elogind-shepherd-service)
755 ;; Provide the 'loginctl' command.
756 (service-extension profile-service-type
757 (compose list elogind-package))
759 ;; Extend PAM with pam_elogind.so.
760 (service-extension pam-root-service-type
761 pam-extension-procedure)
763 ;; We need /run/user, /run/systemd, etc.
764 (service-extension file-system-service-type
765 (const %elogind-file-systems))))
766 (default-value (elogind-configuration))))
768 (define* (elogind-service #:key (config (elogind-configuration)))
769 "Return a service that runs the @command{elogind} login and seat management
770 service. The @command{elogind} service integrates with PAM to allow other
771 system components to know the set of logged-in users as well as their session
772 types (graphical, console, remote, etc.). It can also clean up after users
774 (service elogind-service-type config))
778 ;;; AccountsService service.
781 (define %accountsservice-activation
783 (use-modules (guix build utils))
784 (mkdir-p "/var/lib/AccountsService")))
786 (define accountsservice-service-type
787 (service-type (name 'accountsservice)
789 (list (service-extension activation-service-type
790 (const %accountsservice-activation))
791 (service-extension dbus-root-service-type list)
792 (service-extension polkit-service-type list)))))
794 (define* (accountsservice-service #:key (accountsservice accountsservice))
795 "Return a service that runs AccountsService, a system service that
796 can list available accounts, change their passwords, and so on.
797 AccountsService integrates with PolicyKit to enable unprivileged users to
798 acquire the capability to modify their system configuration.
799 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
800 accountsservice web site} for more information."
801 (service accountsservice-service-type accountsservice))
805 ;;; GNOME desktop service.
808 (define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration
809 make-gnome-desktop-configuration
810 gnome-desktop-configuration
811 (gnome-package gnome-package (default gnome)))
813 (define (gnome-polkit-settings config)
814 "Return the list of GNOME dependencies that provide polkit actions and
816 (let ((gnome (gnome-package config)))
818 ((package-direct-input-selector name) gnome))
819 '("gnome-settings-daemon"
820 "gnome-control-center"
821 "gnome-system-monitor"
824 (define gnome-desktop-service-type
826 (name 'gnome-desktop)
828 (list (service-extension polkit-service-type
829 gnome-polkit-settings)
830 (service-extension profile-service-type
833 (description "Run the GNOME desktop environment.")))
835 (define* (gnome-desktop-service #:key (config (gnome-desktop-configuration)))
836 "Return a service that adds the @code{gnome} package to the system profile,
837 and extends polkit with the actions from @code{gnome-settings-daemon}."
838 (service gnome-desktop-service-type config))
840 ;; MATE Desktop service.
841 ;; TODO: Add mate-screensaver.
843 (define-record-type* <mate-desktop-configuration> mate-desktop-configuration
844 make-mate-desktop-configuration
845 mate-desktop-configuration
846 (mate-package mate-package (default mate)))
848 (define mate-desktop-service-type
852 (list (service-extension polkit-service-type
854 (package-direct-input-selector
855 "mate-settings-daemon")
857 (service-extension profile-service-type
860 (description "Run the MATE desktop environment.")))
862 (define* (mate-desktop-service #:key (config (mate-desktop-configuration)))
863 "Return a service that adds the @code{mate} package to the system profile,
864 and extends polkit with the actions from @code{mate-settings-daemon}."
865 (service mate-desktop-service-type config))
869 ;;; XFCE desktop service.
872 (define-record-type* <xfce-desktop-configuration> xfce-desktop-configuration
873 make-xfce-desktop-configuration
874 xfce-desktop-configuration
875 (xfce xfce-package (default xfce)))
877 (define xfce-desktop-service-type
881 (list (service-extension polkit-service-type
883 (package-direct-input-selector
886 (service-extension profile-service-type
890 (define* (xfce-desktop-service #:key (config (xfce-desktop-configuration)))
891 "Return a service that adds the @code{xfce} package to the system profile,
892 and extends polkit with the ability for @code{thunar} to manipulate the file
893 system as root from within a user session, after the user has authenticated
894 with the administrator's password."
895 (service xfce-desktop-service-type config))
899 ;;; X11 socket directory service
902 (define x11-socket-directory-service
903 ;; Return a service that creates /tmp/.X11-unix. When using X11, libxcb
904 ;; takes care of creating that directory. However, when using XWayland, we
905 ;; need to create beforehand. Thus, create it unconditionally here.
906 (simple-service 'x11-socket-directory
907 activation-service-type
908 (with-imported-modules '((guix build utils))
910 (use-modules (guix build utils))
911 (let ((directory "/tmp/.X11-unix"))
913 (chmod directory #o777))))))
916 ;;; Enlightenment desktop service.
919 (define-record-type* <enlightenment-desktop-configuration>
920 enlightenment-desktop-configuration make-enlightenment-desktop-configuration
921 enlightenment-desktop-configuration?
923 (enlightenment enlightenment-package
924 (default enlightenment)))
926 (define (enlightenment-setuid-programs enlightenment-desktop-configuration)
927 (match-record enlightenment-desktop-configuration
928 <enlightenment-desktop-configuration>
930 (list (file-append enlightenment
931 "/lib/enlightenment/utils/enlightenment_sys")
932 (file-append enlightenment
933 "/lib/enlightenment/utils/enlightenment_backlight")
934 ;; TODO: Move this binary to a screen-locker service.
935 (file-append enlightenment
936 "/lib/enlightenment/utils/enlightenment_ckpasswd")
937 (file-append enlightenment
939 "/lib/enlightenment/modules/cpufreq/"
940 (match (string-tokenize (%current-system)
941 (char-set-complement (char-set #\-)))
942 ((arch "linux") (string-append "linux-gnu-" arch))
943 ((arch "gnu") (string-append "gnu-" arch)))
945 (version-major+minor (package-version enlightenment))
948 (define enlightenment-desktop-service-type
950 (name 'enlightenment-desktop)
952 (list (service-extension dbus-root-service-type
954 (package-direct-input-selector
956 enlightenment-package))
957 (service-extension setuid-program-service-type
958 enlightenment-setuid-programs)
959 (service-extension profile-service-type
961 enlightenment-package))))
962 (default-value (enlightenment-desktop-configuration))
964 "Return a service that adds the @code{enlightenment} package to the system
965 profile, and extends dbus with the ability for @code{efl} to generate
966 thumbnails and makes setuid the programs which enlightenment needs to function
971 ;;; The default set of desktop services.
974 (define %desktop-services
975 ;; List of services typically useful for a "desktop" use case.
976 (cons* (service slim-service-type)
978 ;; Screen lockers are a pretty useful thing and these are small.
979 (screen-locker-service slock)
980 (screen-locker-service xlockmore "xlock")
982 ;; Add udev rules for MTP devices so that non-root users can access
984 (simple-service 'mtp udev-service-type (list libmtp))
987 (service network-manager-service-type)
988 (service wpa-supplicant-service-type) ;needed by NetworkManager
989 (service avahi-service-type)
992 (accountsservice-service)
995 (service polkit-service-type)
999 (service ntp-service-type)
1001 x11-socket-directory-service
1003 (service alsa-service-type)
1007 ;;; desktop.scm ends here