gnu: accountsservice: Properly reference shadow.
[jackhill/guix/guix.git] / gnu / services / desktop.scm
CommitLineData
fe1a39d3 1;;; GNU Guix --- Functional package management for GNU
94a88117 2;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
fe1a39d3 3;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
4307c476 4;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
922e21f4 5;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
fe1a39d3
LC
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu services desktop)
23 #:use-module (gnu services)
0190c1c0 24 #:use-module (gnu services shepherd)
4467be21 25 #:use-module (gnu services base)
0adfe95a 26 #:use-module (gnu services dbus)
4467be21
LC
27 #:use-module (gnu services avahi)
28 #:use-module (gnu services xorg)
29 #:use-module (gnu services networking)
38c2b503
LC
30 #:use-module ((gnu system file-systems)
31 #:select (%elogind-file-systems))
fe1a39d3 32 #:use-module (gnu system shadow)
6e828634 33 #:use-module (gnu system pam)
fe1a39d3
LC
34 #:use-module (gnu packages glib)
35 #:use-module (gnu packages admin)
04463bb0 36 #:use-module (gnu packages freedesktop)
fe1a39d3 37 #:use-module (gnu packages gnome)
7a2413e4 38 #:use-module (gnu packages xfce)
4467be21 39 #:use-module (gnu packages avahi)
6726282b
LC
40 #:use-module (gnu packages xdisorg)
41 #:use-module (gnu packages suckless)
922e21f4 42 #:use-module (gnu packages linux)
3547a5ef 43 #:use-module (gnu packages libusb)
04463bb0 44 #:use-module (guix records)
0adfe95a 45 #:use-module (guix packages)
fe1a39d3
LC
46 #:use-module (guix store)
47 #:use-module (guix gexp)
0adfe95a 48 #:use-module (srfi srfi-1)
fe1a39d3 49 #:use-module (ice-9 match)
24e96431
50 #:export (upower-configuration
51 upower-configuration?
52 upower-service
53 upower-service-type
54
55 udisks-configuration
56 udisks-configuration?
2b9e0a94 57 udisks-service
24e96431
58 udisks-service-type
59
4467be21 60 colord-service
24e96431 61
cee32ee4 62 geoclue-application
24e96431
63 geoclue-configuration
64 geoclue-configuration?
cee32ee4
AW
65 %standard-geoclue-applications
66 geoclue-service
24e96431
67 geoclue-service-type
68
922e21f4 69 bluetooth-service
24e96431 70
04463bb0 71 elogind-configuration
24e96431 72 elogind-configuration?
04463bb0 73 elogind-service
24e96431
74 elogind-service-type
75
76 gnome-desktop-configuration
77 gnome-desktop-configuration?
7a2413e4 78 gnome-desktop-service
24e96431
79 gnome-desktop-service-type
80
81 xfce-desktop-configuration
82 xfce-desktop-configuration?
7a2413e4 83 xfce-desktop-service
24e96431
84 xfce-desktop-service-type
85
4467be21 86 %desktop-services))
fe1a39d3
LC
87
88;;; Commentary:
89;;;
90;;; This module contains service definitions for a "desktop" environment.
91;;;
92;;; Code:
93
94\f
cee32ee4
AW
95;;;
96;;; Helpers.
97;;;
98
99(define (bool value)
100 (if value "true\n" "false\n"))
101
7a2413e4
AW
102(define (package-direct-input-selector input)
103 (lambda (package)
104 (match (assoc-ref (package-direct-inputs package) input)
105 ((package . _) package))))
106
fe1a39d3 107
0adfe95a
LC
108(define (wrapped-dbus-service service program variable value)
109 "Return a wrapper for @var{service}, a package containing a D-Bus service,
110where @var{program} is wrapped such that environment variable @var{variable}
111is set to @var{value} when the bus daemon launches it."
112 (define wrapper
113 (program-file (string-append (package-name service) "-program-wrapper")
114 #~(begin
115 (setenv #$variable #$value)
116 (apply execl (string-append #$service "/" #$program)
117 (string-append #$service "/" #$program)
118 (cdr (command-line))))))
119
4ee96a79
LC
120 (define build
121 (with-imported-modules '((guix build utils))
122 #~(begin
123 (use-modules (guix build utils))
124
125 (define service-directory
126 "/share/dbus-1/system-services")
127
128 (mkdir-p (dirname (string-append #$output
129 service-directory)))
130 (copy-recursively (string-append #$service
131 service-directory)
132 (string-append #$output
133 service-directory))
134 (symlink (string-append #$service "/etc") ;for etc/dbus-1
135 (string-append #$output "/etc"))
136
137 (for-each (lambda (file)
138 (substitute* file
139 (("Exec[[:blank:]]*=[[:blank:]]*([[:graph:]]+)(.*)$"
140 _ original-program arguments)
141 (string-append "Exec=" #$wrapper arguments
142 "\n"))))
143 (find-files #$output "\\.service$")))))
144
0adfe95a 145 (computed-file (string-append (package-name service) "-wrapper")
4ee96a79 146 build))
fe1a39d3
LC
147
148\f
149;;;
150;;; Upower D-Bus service.
151;;;
152
0adfe95a
LC
153;; TODO: Export.
154(define-record-type* <upower-configuration>
155 upower-configuration make-upower-configuration
156 upower-configuration?
157 (upower upower-configuration-upower
158 (default upower))
159 (watts-up-pro? upower-configuration-watts-up-pro?)
160 (poll-batteries? upower-configuration-poll-batteries?)
161 (ignore-lid? upower-configuration-ignore-lid?)
162 (use-percentage-for-policy? upower-configuration-use-percentage-for-policy?)
163 (percentage-low upower-configuration-percentage-low)
164 (percentage-critical upower-configuration-percentage-critical)
165 (percentage-action upower-configuration-percentage-action)
166 (time-low upower-configuration-time-low)
167 (time-critical upower-configuration-time-critical)
168 (time-action upower-configuration-time-action)
169 (critical-power-action upower-configuration-critical-power-action))
170
171(define* upower-configuration-file
172 ;; Return an upower-daemon configuration file.
173 (match-lambda
174 (($ <upower-configuration> upower
175 watts-up-pro? poll-batteries? ignore-lid? use-percentage-for-policy?
176 percentage-low percentage-critical percentage-action time-low
177 time-critical time-action critical-power-action)
178 (plain-file "UPower.conf"
179 (string-append
180 "[UPower]\n"
181 "EnableWattsUpPro=" (bool watts-up-pro?)
182 "NoPollBatteries=" (bool (not poll-batteries?))
183 "IgnoreLid=" (bool ignore-lid?)
184 "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
185 "PercentageLow=" (number->string percentage-low) "\n"
186 "PercentageCritical=" (number->string percentage-critical) "\n"
187 "PercentageAction=" (number->string percentage-action) "\n"
188 "TimeLow=" (number->string time-low) "\n"
189 "TimeCritical=" (number->string time-critical) "\n"
190 "TimeAction=" (number->string time-action) "\n"
191 "CriticalPowerAction=" (match critical-power-action
192 ('hybrid-sleep "HybridSleep")
193 ('hibernate "Hibernate")
194 ('power-off "PowerOff"))
195 "\n")))))
196
0adfe95a
LC
197(define %upower-activation
198 #~(begin
199 (use-modules (guix build utils))
2da4f2dd 200 (mkdir-p "/var/lib/upower")))
0adfe95a
LC
201
202(define (upower-dbus-service config)
203 (list (wrapped-dbus-service (upower-configuration-upower config)
204 "libexec/upowerd"
205 "UPOWER_CONF_FILE_NAME"
206 (upower-configuration-file config))))
207
d4053c71
AK
208(define (upower-shepherd-service config)
209 "Return a shepherd service for UPower with CONFIG."
0adfe95a
LC
210 (let ((upower (upower-configuration-upower config))
211 (config (upower-configuration-file config)))
d4053c71 212 (list (shepherd-service
0adfe95a
LC
213 (documentation "Run the UPower power and battery monitor.")
214 (provision '(upower-daemon))
215 (requirement '(dbus-system udev))
216
217 (start #~(make-forkexec-constructor
218 (list (string-append #$upower "/libexec/upowerd"))
219 #:environment-variables
220 (list (string-append "UPOWER_CONF_FILE_NAME="
221 #$config))))
222 (stop #~(make-kill-destructor))))))
223
224(define upower-service-type
edc891fa
LC
225 (let ((upower-package (compose list upower-configuration-upower)))
226 (service-type (name 'upower)
227 (extensions
228 (list (service-extension dbus-root-service-type
229 upower-dbus-service)
230 (service-extension shepherd-root-service-type
231 upower-shepherd-service)
232 (service-extension activation-service-type
233 (const %upower-activation))
234 (service-extension udev-service-type
235 upower-package)
236
237 ;; Make the 'upower' command visible.
238 (service-extension profile-service-type
239 upower-package))))))
fe1a39d3
LC
240
241(define* (upower-service #:key (upower upower)
242 (watts-up-pro? #f)
243 (poll-batteries? #t)
244 (ignore-lid? #f)
245 (use-percentage-for-policy? #f)
246 (percentage-low 10)
247 (percentage-critical 3)
248 (percentage-action 2)
249 (time-low 1200)
250 (time-critical 300)
251 (time-action 120)
252 (critical-power-action 'hybrid-sleep))
253 "Return a service that runs @uref{http://upower.freedesktop.org/,
254@command{upowerd}}, a system-wide monitor for power consumption and battery
255levels, with the given configuration settings. It implements the
256@code{org.freedesktop.UPower} D-Bus interface, and is notably used by GNOME."
0adfe95a
LC
257 (let ((config (upower-configuration
258 (watts-up-pro? watts-up-pro?)
259 (poll-batteries? poll-batteries?)
260 (ignore-lid? ignore-lid?)
261 (use-percentage-for-policy? use-percentage-for-policy?)
262 (percentage-low percentage-low)
263 (percentage-critical percentage-critical)
264 (percentage-action percentage-action)
265 (time-low time-low)
266 (time-critical time-critical)
267 (time-action time-action)
268 (critical-power-action critical-power-action))))
269 (service upower-service-type config)))
fe1a39d3
LC
270
271\f
cee32ee4
AW
272;;;
273;;; GeoClue D-Bus service.
274;;;
275
0adfe95a
LC
276;; TODO: Export.
277(define-record-type* <geoclue-configuration>
278 geoclue-configuration make-geoclue-configuration
279 geoclue-configuration?
280 (geoclue geoclue-configuration-geoclue
281 (default geoclue))
282 (whitelist geoclue-configuration-whitelist)
283 (wifi-geolocation-url geoclue-configuration-wifi-geolocation-url)
284 (submit-data? geoclue-configuration-submit-data?)
285 (wifi-submission-url geoclue-configuration-wifi-submission-url)
286 (submission-nick geoclue-configuration-submission-nick)
287 (applications geoclue-configuration-applications))
288
cee32ee4
AW
289(define* (geoclue-application name #:key (allowed? #t) system? (users '()))
290 "Configure default GeoClue access permissions for an application. NAME is
291the Desktop ID of the application, without the .desktop part. If ALLOWED? is
292true, the application will have access to location information by default.
293The boolean SYSTEM? value indicates that an application is a system component
294or not. Finally USERS is a list of UIDs of all users for which this
295application is allowed location info access. An empty users list means all
296users are allowed."
297 (string-append
298 "[" name "]\n"
299 "allowed=" (bool allowed?)
300 "system=" (bool system?)
301 "users=" (string-join users ";") "\n"))
302
303(define %standard-geoclue-applications
304 (list (geoclue-application "gnome-datetime-panel" #:system? #t)
305 (geoclue-application "epiphany" #:system? #f)
306 (geoclue-application "firefox" #:system? #f)))
307
0adfe95a 308(define* (geoclue-configuration-file config)
cee32ee4 309 "Return a geoclue configuration file."
be1c2c54
LC
310 (plain-file "geoclue.conf"
311 (string-append
312 "[agent]\n"
0adfe95a
LC
313 "whitelist="
314 (string-join (geoclue-configuration-whitelist config)
315 ";") "\n"
be1c2c54 316 "[wifi]\n"
0adfe95a
LC
317 "url=" (geoclue-configuration-wifi-geolocation-url config) "\n"
318 "submit-data=" (bool (geoclue-configuration-submit-data? config))
319 "submission-url="
320 (geoclue-configuration-wifi-submission-url config) "\n"
321 "submission-nick="
322 (geoclue-configuration-submission-nick config)
323 "\n"
324 (string-join (geoclue-configuration-applications config)
325 "\n"))))
326
327(define (geoclue-dbus-service config)
328 (list (wrapped-dbus-service (geoclue-configuration-geoclue config)
329 "libexec/geoclue"
330 "GEOCLUE_CONFIG_FILE"
331 (geoclue-configuration-file config))))
332
0adfe95a
LC
333(define %geoclue-accounts
334 (list (user-group (name "geoclue") (system? #t))
335 (user-account
336 (name "geoclue")
337 (group "geoclue")
338 (system? #t)
339 (comment "GeoClue daemon user")
340 (home-directory "/var/empty")
341 (shell "/run/current-system/profile/sbin/nologin"))))
342
343(define geoclue-service-type
344 (service-type (name 'geoclue)
345 (extensions
346 (list (service-extension dbus-root-service-type
347 geoclue-dbus-service)
0adfe95a
LC
348 (service-extension account-service-type
349 (const %geoclue-accounts))))))
cee32ee4
AW
350
351(define* (geoclue-service #:key (geoclue geoclue)
352 (whitelist '())
353 (wifi-geolocation-url
354 ;; Mozilla geolocation service:
355 "https://location.services.mozilla.com/v1/geolocate?key=geoclue")
356 (submit-data? #f)
357 (wifi-submission-url
358 "https://location.services.mozilla.com/v1/submit?key=geoclue")
359 (submission-nick "geoclue")
360 (applications %standard-geoclue-applications))
361 "Return a service that runs the @command{geoclue} location service. This
362service provides a D-Bus interface to allow applications to request access to
363a user's physical location, and optionally to add information to online
364location databases. By default, only the GNOME date-time panel and the Icecat
365and Epiphany web browsers are able to ask for the user's location, and in the
366case of Icecat and Epiphany, both will ask the user for permission first. See
367@uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the geoclue web
368site} for more information."
0adfe95a
LC
369 (service geoclue-service-type
370 (geoclue-configuration
371 (geoclue geoclue)
372 (whitelist whitelist)
373 (wifi-geolocation-url wifi-geolocation-url)
374 (submit-data? submit-data?)
375 (wifi-submission-url wifi-submission-url)
376 (submission-nick submission-nick)
377 (applications applications))))
cee32ee4
AW
378
379\f
922e21f4
SB
380;;;
381;;; Bluetooth.
382;;;
383
384(define (bluetooth-shepherd-service bluez)
385 "Return a shepherd service for @command{bluetoothd}."
386 (shepherd-service
387 (provision '(bluetooth))
388 (requirement '(dbus-system udev))
389 (documentation "Run the bluetoothd daemon.")
390 (start #~(make-forkexec-constructor
391 (string-append #$bluez "/libexec/bluetooth/bluetoothd")))
392 (stop #~(make-kill-destructor))))
393
394(define bluetooth-service-type
395 (service-type
396 (name 'bluetooth)
397 (extensions
398 (list (service-extension dbus-root-service-type list)
399 (service-extension udev-service-type list)
400 (service-extension shepherd-root-service-type
401 (compose list bluetooth-shepherd-service))))))
402
403(define* (bluetooth-service #:key (bluez bluez))
404 "Return a service that runs the @command{bluetoothd} daemon, which manages
405all the Bluetooth devices and provides a number of D-Bus interfaces.
406
407Users need to be in the @code{lp} group to access the D-Bus service.
408"
409 (service bluetooth-service-type bluez))
410
411\f
222e3319
LC
412;;;
413;;; Colord D-Bus service.
414;;;
415
416(define %colord-activation
417 #~(begin
418 (use-modules (guix build utils))
419 (mkdir-p "/var/lib/colord")
420 (let ((user (getpwnam "colord")))
421 (chown "/var/lib/colord"
422 (passwd:uid user) (passwd:gid user)))))
423
424(define %colord-accounts
425 (list (user-group (name "colord") (system? #t))
426 (user-account
427 (name "colord")
428 (group "colord")
429 (system? #t)
430 (comment "colord daemon user")
431 (home-directory "/var/empty")
9e41130b 432 (shell (file-append shadow "/sbin/nologin")))))
222e3319
LC
433
434(define colord-service-type
435 (service-type (name 'colord)
436 (extensions
437 (list (service-extension account-service-type
438 (const %colord-accounts))
439 (service-extension activation-service-type
440 (const %colord-activation))
441
442 ;; Colord is a D-Bus service that dbus-daemon can
443 ;; activate.
444 (service-extension dbus-root-service-type list)
445
446 ;; Colord provides "color device" rules for udev.
447 (service-extension udev-service-type list)
448
449 ;; It provides polkit "actions".
450 (service-extension polkit-service-type list)))))
451
452(define* (colord-service #:key (colord colord))
453 "Return a service that runs @command{colord}, a system service with a D-Bus
454interface to manage the color profiles of input and output devices such as
455screens and scanners. It is notably used by the GNOME Color Manager graphical
456tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
457site} for more information."
458 (service colord-service-type colord))
0071c789
AW
459
460\f
2b9e0a94
LC
461;;;
462;;; UDisks.
463;;;
464
465(define-record-type* <udisks-configuration>
466 udisks-configuration make-udisks-configuration
467 udisks-configuration?
468 (udisks udisks-configuration-udisks
469 (default udisks)))
470
471(define udisks-service-type
472 (let ((udisks-package (lambda (config)
473 (list (udisks-configuration-udisks config)))))
474 (service-type (name 'udisks)
475 (extensions
476 (list (service-extension polkit-service-type
477 udisks-package)
478 (service-extension dbus-root-service-type
479 udisks-package)
480 (service-extension udev-service-type
beca0807
LC
481 udisks-package)
482
483 ;; Profile 'udisksctl' & co. in the system profile.
484 (service-extension profile-service-type
2b9e0a94
LC
485 udisks-package))))))
486
487(define* (udisks-service #:key (udisks udisks))
488 "Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
489UDisks}, a @dfn{disk management} daemon that provides user interfaces with
490notifications and ways to mount/unmount disks. Programs that talk to UDisks
491include the @command{udisksctl} command, part of UDisks, and GNOME Disks."
492 (service udisks-service-type
493 (udisks-configuration (udisks udisks))))
494
495\f
04463bb0
AW
496;;;
497;;; Elogind login and seat management service.
498;;;
499
500(define-record-type* <elogind-configuration> elogind-configuration
501 make-elogind-configuration
502 elogind-configuration
0adfe95a
LC
503 (elogind elogind-package
504 (default elogind))
04463bb0
AW
505 (kill-user-processes? elogind-kill-user-processes?
506 (default #f))
507 (kill-only-users elogind-kill-only-users
508 (default '()))
509 (kill-exclude-users elogind-kill-exclude-users
510 (default '("root")))
511 (inhibit-delay-max-seconds elogind-inhibit-delay-max-seconds
512 (default 5))
513 (handle-power-key elogind-handle-power-key
514 (default 'poweroff))
515 (handle-suspend-key elogind-handle-suspend-key
516 (default 'suspend))
517 (handle-hibernate-key elogind-handle-hibernate-key
574d9db2
MW
518 ;; (default 'hibernate)
519 ;; XXX Ignore it for now, since we don't
520 ;; yet handle resume-from-hibernation in
521 ;; our initrd.
522 (default 'ignore))
04463bb0
AW
523 (handle-lid-switch elogind-handle-lid-switch
524 (default 'suspend))
525 (handle-lid-switch-docked elogind-handle-lid-switch-docked
526 (default 'ignore))
527 (power-key-ignore-inhibited? elogind-power-key-ignore-inhibited?
528 (default #f))
529 (suspend-key-ignore-inhibited? elogind-suspend-key-ignore-inhibited?
530 (default #f))
531 (hibernate-key-ignore-inhibited? elogind-hibernate-key-ignore-inhibited?
532 (default #f))
533 (lid-switch-ignore-inhibited? elogind-lid-switch-ignore-inhibited?
534 (default #t))
535 (holdoff-timeout-seconds elogind-holdoff-timeout-seconds
536 (default 30))
537 (idle-action elogind-idle-action
538 (default 'ignore))
539 (idle-action-seconds elogind-idle-action-seconds
540 (default (* 30 60)))
541 (runtime-directory-size-percent elogind-runtime-directory-size-percent
542 (default 10))
543 (runtime-directory-size elogind-runtime-directory-size
544 (default #f))
545 (remove-ipc? elogind-remove-ipc?
546 (default #t))
547
548 (suspend-state elogind-suspend-state
549 (default '("mem" "standby" "freeze")))
550 (suspend-mode elogind-suspend-mode
551 (default '()))
552 (hibernate-state elogind-hibernate-state
553 (default '("disk")))
554 (hibernate-mode elogind-hibernate-mode
555 (default '("platform" "shutdown")))
556 (hybrid-sleep-state elogind-hybrid-sleep-state
557 (default '("disk")))
558 (hybrid-sleep-mode elogind-hybrid-sleep-mode
559 (default
560 '("suspend" "platform" "shutdown"))))
561
562(define (elogind-configuration-file config)
563 (define (yesno x)
564 (match x
565 (#t "yes")
566 (#f "no")
567 (_ (error "expected #t or #f, instead got:" x))))
568 (define char-set:user-name
569 (string->char-set "abcdefghijklmnopqrstuvwxyz0123456789_-"))
570 (define (valid-list? l pred)
571 (and-map (lambda (x) (string-every pred x)) l))
572 (define (user-name-list users)
573 (unless (valid-list? users char-set:user-name)
574 (error "invalid user list" users))
575 (string-join users " "))
576 (define (enum val allowed)
577 (unless (memq val allowed)
578 (error "invalid value" val allowed))
579 (symbol->string val))
580 (define (non-negative-integer x)
581 (unless (exact-integer? x) (error "not an integer" x))
582 (when (negative? x) (error "negative number not allowed" x))
583 (number->string x))
584 (define handle-actions
585 '(ignore poweroff reboot halt kexec suspend hibernate hybrid-sleep lock))
586 (define (handle-action x)
587 (enum x handle-actions))
588 (define (sleep-list tokens)
589 (unless (valid-list? tokens char-set:user-name)
590 (error "invalid sleep list" tokens))
591 (string-join tokens " "))
592 (define-syntax ini-file-clause
593 (syntax-rules ()
594 ((_ config (prop (parser getter)))
595 (string-append prop "=" (parser (getter config)) "\n"))
596 ((_ config str)
597 (string-append str "\n"))))
598 (define-syntax-rule (ini-file config file clause ...)
be1c2c54 599 (plain-file file (string-append (ini-file-clause config clause) ...)))
04463bb0
AW
600 (ini-file
601 config "logind.conf"
602 "[Login]"
603 ("KillUserProcesses" (yesno elogind-kill-user-processes?))
604 ("KillOnlyUsers" (user-name-list elogind-kill-only-users))
605 ("KillExcludeUsers" (user-name-list elogind-kill-exclude-users))
606 ("InhibitDelayMaxSecs" (non-negative-integer elogind-inhibit-delay-max-seconds))
607 ("HandlePowerKey" (handle-action elogind-handle-power-key))
608 ("HandleSuspendKey" (handle-action elogind-handle-suspend-key))
609 ("HandleHibernateKey" (handle-action elogind-handle-hibernate-key))
610 ("HandleLidSwitch" (handle-action elogind-handle-lid-switch))
611 ("HandleLidSwitchDocked" (handle-action elogind-handle-lid-switch-docked))
612 ("PowerKeyIgnoreInhibited" (yesno elogind-power-key-ignore-inhibited?))
613 ("SuspendKeyIgnoreInhibited" (yesno elogind-suspend-key-ignore-inhibited?))
614 ("HibernateKeyIgnoreInhibited" (yesno elogind-hibernate-key-ignore-inhibited?))
615 ("LidSwitchIgnoreInhibited" (yesno elogind-lid-switch-ignore-inhibited?))
616 ("HoldoffTimeoutSecs" (non-negative-integer elogind-holdoff-timeout-seconds))
617 ("IdleAction" (handle-action elogind-idle-action))
618 ("IdleActionSeconds" (non-negative-integer elogind-idle-action-seconds))
619 ("RuntimeDirectorySize"
620 (identity
621 (lambda (config)
622 (match (elogind-runtime-directory-size-percent config)
623 (#f (non-negative-integer (elogind-runtime-directory-size config)))
624 (percent (string-append (non-negative-integer percent) "%"))))))
625 ("RemoveIpc" (yesno elogind-remove-ipc?))
626 "[Sleep]"
627 ("SuspendState" (sleep-list elogind-suspend-state))
628 ("SuspendMode" (sleep-list elogind-suspend-mode))
629 ("HibernateState" (sleep-list elogind-hibernate-state))
630 ("HibernateMode" (sleep-list elogind-hibernate-mode))
631 ("HybridSleepState" (sleep-list elogind-hybrid-sleep-state))
632 ("HybridSleepMode" (sleep-list elogind-hybrid-sleep-mode))))
633
956ad60c
LC
634(define (elogind-dbus-service config)
635 (list (wrapped-dbus-service (elogind-package config)
636 "libexec/elogind/elogind"
637 "ELOGIND_CONF_FILE"
638 (elogind-configuration-file config))))
0adfe95a 639
e7ad0d58
LC
640(define (pam-extension-procedure config)
641 "Return an extension for PAM-ROOT-SERVICE-TYPE that ensures that all the PAM
642services use 'pam_elogind.so', a module that allows elogind to keep track of
643logged-in users (run 'loginctl' to see elogind's world view of users and
644seats.)"
645 (define pam-elogind
646 (pam-entry
647 (control "required")
9e41130b
LC
648 (module (file-append (elogind-package config)
649 "/lib/security/pam_elogind.so"))))
e7ad0d58
LC
650
651 (list (lambda (pam)
652 (pam-service
653 (inherit pam)
654 (session (cons pam-elogind (pam-service-session pam)))))))
655
94a88117
LC
656(define (elogind-shepherd-service config)
657 "Return a Shepherd service to start elogind according to @var{config}."
658 (list (shepherd-service
659 (requirement '(dbus-system))
660 (provision '(elogind))
661 (start #~(make-forkexec-constructor
662 (list #$(file-append (elogind-package config)
663 "/libexec/elogind/elogind"))
664 #:environment-variables
665 (list (string-append "ELOGIND_CONF_FILE="
666 #$(elogind-configuration-file
667 config)))))
668 (stop #~(make-kill-destructor)))))
669
0adfe95a
LC
670(define elogind-service-type
671 (service-type (name 'elogind)
672 (extensions
956ad60c
LC
673 (list (service-extension dbus-root-service-type
674 elogind-dbus-service)
0adfe95a
LC
675 (service-extension udev-service-type
676 (compose list elogind-package))
222e3319
LC
677 (service-extension polkit-service-type
678 (compose list elogind-package))
05c5b165 679
94a88117
LC
680 ;; Start elogind from the Shepherd rather than waiting
681 ;; for bus activation. This ensures that it can handle
682 ;; events like lid close, etc.
683 (service-extension shepherd-root-service-type
684 elogind-shepherd-service)
685
05c5b165
LC
686 ;; Provide the 'loginctl' command.
687 (service-extension profile-service-type
688 (compose list elogind-package))
689
e7ad0d58
LC
690 ;; Extend PAM with pam_elogind.so.
691 (service-extension pam-root-service-type
38c2b503
LC
692 pam-extension-procedure)
693
694 ;; We need /run/user, /run/systemd, etc.
695 (service-extension file-system-service-type
696 (const %elogind-file-systems))))))
0adfe95a
LC
697
698(define* (elogind-service #:key (config (elogind-configuration)))
04463bb0
AW
699 "Return a service that runs the @command{elogind} login and seat management
700service. The @command{elogind} service integrates with PAM to allow other
701system components to know the set of logged-in users as well as their session
702types (graphical, console, remote, etc.). It can also clean up after users
703when they log out."
0adfe95a 704 (service elogind-service-type config))
04463bb0
AW
705
706\f
7a2413e4
AW
707;;;
708;;; GNOME desktop service.
709;;;
710
711(define-record-type* <gnome-desktop-configuration> gnome-desktop-configuration
712 make-gnome-desktop-configuration
713 gnome-desktop-configuration
714 (gnome-package gnome-package (default gnome)))
715
716(define gnome-desktop-service-type
717 (service-type
718 (name 'gnome-desktop)
719 (extensions
720 (list (service-extension polkit-service-type
721 (compose list
722 (package-direct-input-selector
723 "gnome-settings-daemon")
724 gnome-package))
725 (service-extension profile-service-type
726 (compose list
727 gnome-package))))))
728
729(define* (gnome-desktop-service #:key (config (gnome-desktop-configuration)))
730 "Return a service that adds the @code{gnome} package to the system profile,
731and extends polkit with the actions from @code{gnome-settings-daemon}."
732 (service gnome-desktop-service-type config))
733
734\f
735;;;
736;;; XFCE desktop service.
737;;;
738
739(define-record-type* <xfce-desktop-configuration> xfce-desktop-configuration
740 make-xfce-desktop-configuration
741 xfce-desktop-configuration
742 (xfce xfce-package (default xfce)))
743
744(define xfce-desktop-service-type
745 (service-type
746 (name 'xfce-desktop)
747 (extensions
748 (list (service-extension polkit-service-type
749 (compose list
750 (package-direct-input-selector
751 "thunar")
752 xfce-package))
753 (service-extension profile-service-type
754 (compose list
755 xfce-package))))))
756
757(define* (xfce-desktop-service #:key (config (xfce-desktop-configuration)))
758 "Return a service that adds the @code{xfce} package to the system profile,
705b9714 759and extends polkit with the ability for @code{thunar} to manipulate the file
7a2413e4
AW
760system as root from within a user session, after the user has authenticated
761with the administrator's password."
762 (service xfce-desktop-service-type config))
763
764\f
cee32ee4
AW
765;;;
766;;; The default set of desktop services.
767;;;
0adfe95a 768
4467be21
LC
769(define %desktop-services
770 ;; List of services typically useful for a "desktop" use case.
771 (cons* (slim-service)
772
6726282b
LC
773 ;; Screen lockers are a pretty useful thing and these are small.
774 (screen-locker-service slock)
775 (screen-locker-service xlockmore "xlock")
776
3547a5ef
LC
777 ;; Add udev rules for MTP devices so that non-root users can access
778 ;; them.
779 (simple-service 'mtp udev-service-type (list libmtp))
780
0adfe95a 781 ;; The D-Bus clique.
4467be21
LC
782 (avahi-service)
783 (wicd-service)
2b9e0a94 784 (udisks-service)
4467be21
LC
785 (upower-service)
786 (colord-service)
cee32ee4 787 (geoclue-service)
0071c789 788 (polkit-service)
04463bb0 789 (elogind-service)
0adfe95a 790 (dbus-service)
4467be21
LC
791
792 (ntp-service)
4467be21 793
0adfe95a 794 %base-services))
4467be21 795
fe1a39d3 796;;; desktop.scm ends here