services: gdm: Allow for custom X session scripts.
[jackhill/guix/guix.git] / gnu / services / xorg.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Andy Wingo <wingo@igalia.com>
3 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
5 ;;; Copyright © 2018, 2019 Timothy Sample <samplet@ngyro.com>
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 xorg)
23 #:use-module (gnu artwork)
24 #:use-module (gnu services)
25 #:use-module (gnu services shepherd)
26 #:use-module (gnu system pam)
27 #:use-module (gnu services dbus)
28 #:use-module ((gnu packages base) #:select (canonical-package))
29 #:use-module (gnu packages guile)
30 #:use-module (gnu packages xorg)
31 #:use-module (gnu packages fonts)
32 #:use-module (gnu packages gl)
33 #:use-module (gnu packages glib)
34 #:use-module (gnu packages display-managers)
35 #:use-module (gnu packages gnustep)
36 #:use-module (gnu packages gnome)
37 #:use-module (gnu packages admin)
38 #:use-module (gnu packages bash)
39 #:use-module (gnu system shadow)
40 #:use-module (guix gexp)
41 #:use-module (guix store)
42 #:use-module (guix packages)
43 #:use-module (guix derivations)
44 #:use-module (guix records)
45 #:use-module (guix deprecation)
46 #:use-module (srfi srfi-1)
47 #:use-module (srfi srfi-9)
48 #:use-module (srfi srfi-26)
49 #:use-module (ice-9 match)
50 #:export (xorg-configuration-file
51 %default-xorg-modules
52 %default-xorg-fonts
53 xorg-wrapper
54 xorg-start-command
55 xinitrc
56
57 %default-slim-theme
58 %default-slim-theme-name
59
60 slim-configuration
61 slim-configuration?
62 slim-configuration-slim
63 slim-configuration-allow-empty-passwords?
64 slim-configuration-auto-login?
65 slim-configuration-default-user
66 slim-configuration-theme
67 slim-configuration-theme-name
68 slim-configuration-xauth
69 slim-configuration-shepherd
70 slim-configuration-auto-login-session
71 slim-configuration-startx
72
73 slim-service-type
74 slim-service
75
76 screen-locker
77 screen-locker?
78 screen-locker-service-type
79 screen-locker-service
80
81 gdm-configuration
82 gdm-service-type
83 gdm-service))
84
85 ;;; Commentary:
86 ;;;
87 ;;; Services that relate to the X Window System.
88 ;;;
89 ;;; Code:
90
91 (define %default-xorg-modules
92 ;; Default list of modules loaded by the server. When multiple drivers
93 ;; match, the first one in the list is loaded.
94 (list xf86-video-vesa
95 xf86-video-fbdev
96 xf86-video-amdgpu
97 xf86-video-ati
98 xf86-video-cirrus
99 xf86-video-intel
100 xf86-video-mach64
101 xf86-video-nouveau
102 xf86-video-nv
103 xf86-video-sis
104
105 ;; Libinput is the new thing and is recommended over evdev/synaptics:
106 ;; <http://who-t.blogspot.fr/2015/01/xf86-input-libinput-compatibility-with.html>.
107 xf86-input-libinput
108
109 xf86-input-evdev
110 xf86-input-keyboard
111 xf86-input-mouse
112 xf86-input-synaptics))
113
114 (define %default-xorg-fonts
115 ;; Default list of fonts available to the X server.
116 (list (file-append font-alias "/share/fonts/X11/75dpi")
117 (file-append font-alias "/share/fonts/X11/100dpi")
118 (file-append font-alias "/share/fonts/X11/misc")
119 (file-append font-alias "/share/fonts/X11/cyrillic")
120 (file-append font-misc-misc ;default fonts for xterm
121 "/share/fonts/X11/misc")
122 (file-append font-adobe75dpi "/share/fonts/X11/75dpi")))
123
124 (define* (xorg-configuration-file #:key
125 (modules %default-xorg-modules)
126 (fonts %default-xorg-fonts)
127 (drivers '()) (resolutions '())
128 (extra-config '()))
129 "Return a configuration file for the Xorg server containing search paths for
130 all the common drivers.
131
132 @var{modules} must be a list of @dfn{module packages} loaded by the Xorg
133 server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
134 @var{fonts} must be a list of font directories to add to the server's
135 @dfn{font path}.
136
137 @var{drivers} must be either the empty list, in which case Xorg chooses a
138 graphics driver automatically, or a list of driver names that will be tried in
139 this order---e.g., @code{(\"modesetting\" \"vesa\")}.
140
141 Likewise, when @var{resolutions} is the empty list, Xorg chooses an
142 appropriate screen resolution; otherwise, it must be a list of
143 resolutions---e.g., @code{((1024 768) (640 480))}.
144
145 Last, @var{extra-config} is a list of strings or objects appended to the
146 configuration file. It is used to pass extra text to be
147 added verbatim to the configuration file."
148 (define all-modules
149 ;; 'xorg-server' provides 'fbdevhw.so' etc.
150 (append modules (list xorg-server)))
151
152 (define build
153 #~(begin
154 (use-modules (ice-9 match)
155 (srfi srfi-1)
156 (srfi srfi-26))
157
158 (call-with-output-file #$output
159 (lambda (port)
160 (define drivers
161 '#$drivers)
162
163 (define (device-section driver)
164 (string-append "
165 Section \"Device\"
166 Identifier \"device-" driver "\"
167 Driver \"" driver "\"
168 EndSection"))
169
170 (define (screen-section driver resolutions)
171 (string-append "
172 Section \"Screen\"
173 Identifier \"screen-" driver "\"
174 Device \"device-" driver "\"
175 SubSection \"Display\"
176 Modes "
177 (string-join (map (match-lambda
178 ((x y)
179 (string-append "\"" (number->string x)
180 "x" (number->string y) "\"")))
181 resolutions)) "
182 EndSubSection
183 EndSection"))
184
185 (define (expand modules)
186 ;; Append to MODULES the relevant /lib/xorg/modules
187 ;; sub-directories.
188 (append-map (lambda (module)
189 (filter-map (lambda (directory)
190 (let ((full (string-append module
191 directory)))
192 (and (file-exists? full)
193 full)))
194 '("/lib/xorg/modules/drivers"
195 "/lib/xorg/modules/input"
196 "/lib/xorg/modules/multimedia"
197 "/lib/xorg/modules/extensions")))
198 modules))
199
200 (display "Section \"Files\"\n" port)
201 (for-each (lambda (font)
202 (format port " FontPath \"~a\"~%" font))
203 '#$fonts)
204 (for-each (lambda (module)
205 (format port
206 " ModulePath \"~a\"~%"
207 module))
208 (append (expand '#$all-modules)
209
210 ;; For fbdevhw.so and so on.
211 (list #$(file-append xorg-server
212 "/lib/xorg/modules"))))
213 (display "EndSection\n" port)
214 (display "
215 Section \"ServerFlags\"
216 Option \"AllowMouseOpenFail\" \"on\"
217 EndSection\n" port)
218
219 (display (string-join (map device-section drivers) "\n")
220 port)
221 (newline port)
222 (display (string-join
223 (map (cut screen-section <> '#$resolutions)
224 drivers)
225 "\n")
226 port)
227 (newline port)
228
229 (for-each (lambda (config)
230 (display config port))
231 '#$extra-config)))))
232
233 (computed-file "xserver.conf" build))
234
235
236 (define (xorg-configuration-directory modules)
237 "Return a directory that contains the @code{.conf} files for X.org that
238 includes the @code{share/X11/xorg.conf.d} directories of each package listed
239 in @var{modules}."
240 (with-imported-modules '((guix build utils))
241 (computed-file "xorg.conf.d"
242 #~(begin
243 (use-modules (guix build utils)
244 (srfi srfi-1))
245
246 (define files
247 (append-map (lambda (module)
248 (find-files (string-append
249 module
250 "/share/X11/xorg.conf.d")
251 "\\.conf$"))
252 (list #$@modules)))
253
254 (mkdir #$output)
255 (for-each (lambda (file)
256 (symlink file
257 (string-append #$output "/"
258 (basename file))))
259 files)
260 #t))))
261
262 (define* (xorg-wrapper #:key
263 (guile (canonical-package guile-2.0))
264 (modules %default-xorg-modules)
265 (configuration-file (xorg-configuration-file
266 #:modules modules))
267 (xorg-server xorg-server))
268 "Return a derivation that builds a @var{guile} script to start the X server
269 from @var{xorg-server}. @var{configuration-file} is the server configuration
270 file or a derivation that builds it; when omitted, the result of
271 @code{xorg-configuration-file} is used. The resulting script should be used
272 in place of @code{/usr/bin/X}."
273 (define exp
274 ;; Write a small wrapper around the X server.
275 #~(begin
276 (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
277 (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
278
279 (let ((X (string-append #$xorg-server "/bin/X")))
280 (apply execl X X
281 "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
282 "-config" #$configuration-file
283 "-configdir" #$(xorg-configuration-directory modules)
284 (cdr (command-line))))))
285
286 (program-file "X-wrapper" exp))
287
288 (define* (xorg-start-command #:key
289 (guile (canonical-package guile-2.0))
290 (modules %default-xorg-modules)
291 (fonts %default-xorg-fonts)
292 (configuration-file
293 (xorg-configuration-file #:modules modules
294 #:fonts fonts))
295 (xorg-server xorg-server))
296 "Return a @code{startx} script in which @var{modules}, a list of X module
297 packages, and @var{fonts}, a list of X font directories, are available. See
298 @code{xorg-wrapper} for more details on the arguments. The result should be
299 used in place of @code{startx}."
300 (define X
301 (xorg-wrapper #:guile guile
302 #:configuration-file configuration-file
303 #:modules modules
304 #:xorg-server xorg-server))
305 (define exp
306 ;; Write a small wrapper around the X server.
307 #~(apply execl #$X #$X ;; Second #$X is for argv[0].
308 "-logverbose" "-verbose" "-nolisten" "tcp" "-terminate"
309 (cdr (command-line))))
310
311 (program-file "startx" exp))
312
313 (define* (xinitrc #:key
314 (guile (canonical-package guile-2.0))
315 fallback-session)
316 "Return a system-wide xinitrc script that starts the specified X session,
317 which should be passed to this script as the first argument. If not, the
318 @var{fallback-session} will be used or, if @var{fallback-session} is false, a
319 desktop session from the system or user profile will be used."
320 (define builder
321 #~(begin
322 (use-modules (ice-9 match)
323 (ice-9 regex)
324 (ice-9 ftw)
325 (ice-9 rdelim)
326 (srfi srfi-1)
327 (srfi srfi-26))
328
329 (define (close-all-fdes)
330 ;; Close all the open file descriptors except 0 to 2.
331 (let loop ((fd 3))
332 (when (< fd 4096) ;FIXME: use sysconf + _SC_OPEN_MAX
333 (false-if-exception (close-fdes fd))
334 (loop (+ 1 fd)))))
335
336 (define (exec-from-login-shell command . args)
337 ;; Run COMMAND from a login shell so that it gets to see the same
338 ;; environment variables that one gets when logging in on a tty, for
339 ;; instance.
340 (let* ((pw (getpw (getuid)))
341 (shell (passwd:shell pw)))
342 ;; Close any open file descriptors. This is all the more
343 ;; important that SLiM itself exec's us directly without closing
344 ;; its own file descriptors!
345 (close-all-fdes)
346
347 ;; The '--login' option is supported at least by Bash and zsh.
348 (execl shell shell "--login" "-c"
349 (string-join (cons command args)))))
350
351 (define system-profile
352 "/run/current-system/profile")
353
354 (define user-profile
355 (and=> (getpw (getuid))
356 (lambda (pw)
357 (string-append (passwd:dir pw) "/.guix-profile"))))
358
359 (define (xsession-command desktop-file)
360 ;; Read from DESKTOP-FILE its X session command and return it as a
361 ;; list.
362 (define exec-regexp
363 (make-regexp "^[[:blank:]]*Exec=(.*)$"))
364
365 (call-with-input-file desktop-file
366 (lambda (port)
367 (let loop ()
368 (match (read-line port)
369 ((? eof-object?) #f)
370 ((= (cut regexp-exec exec-regexp <>) result)
371 (if result
372 (string-tokenize (match:substring result 1))
373 (loop))))))))
374
375 (define (find-session profile)
376 ;; Return an X session command from PROFILE or #f if none was found.
377 (let ((directory (string-append profile "/share/xsessions")))
378 (match (scandir directory
379 (cut string-suffix? ".desktop" <>))
380 ((or () #f)
381 #f)
382 ((sessions ...)
383 (any xsession-command
384 (map (cut string-append directory "/" <>)
385 sessions))))))
386
387 (let* ((home (getenv "HOME"))
388 (xsession-file (string-append home "/.xsession"))
389 (session (match (command-line)
390 ((_)
391 #$(if fallback-session
392 #~(list #$fallback-session)
393 #f))
394 ((_ x ..1)
395 x))))
396 (if (file-exists? xsession-file)
397 ;; Run ~/.xsession when it exists.
398 (apply exec-from-login-shell xsession-file
399 (or session '()))
400 ;; Otherwise, start the specified session or a fallback.
401 (apply exec-from-login-shell
402 (or session
403 (find-session user-profile)
404 (find-session system-profile)))))))
405
406 (program-file "xinitrc" builder))
407
408 \f
409 ;;;
410 ;;; SLiM log-in manager.
411 ;;;
412
413 (define %default-slim-theme
414 ;; Theme based on work by Felipe López.
415 (file-append %artwork-repository "/slim"))
416
417 (define %default-slim-theme-name
418 ;; This must be the name of the sub-directory in %DEFAULT-SLIM-THEME that
419 ;; contains the actual theme files.
420 "0.x")
421
422 (define-record-type* <slim-configuration>
423 slim-configuration make-slim-configuration
424 slim-configuration?
425 (slim slim-configuration-slim
426 (default slim))
427 (allow-empty-passwords? slim-configuration-allow-empty-passwords?
428 (default #t))
429 (auto-login? slim-configuration-auto-login?
430 (default #f))
431 (default-user slim-configuration-default-user
432 (default ""))
433 (theme slim-configuration-theme
434 (default %default-slim-theme))
435 (theme-name slim-configuration-theme-name
436 (default %default-slim-theme-name))
437 (xauth slim-configuration-xauth
438 (default xauth))
439 (shepherd slim-configuration-shepherd
440 (default shepherd))
441 (auto-login-session slim-configuration-auto-login-session
442 (default #f))
443 (startx slim-configuration-startx
444 (default (xorg-start-command)))
445 (sessreg slim-configuration-sessreg
446 (default sessreg)))
447
448 (define (slim-pam-service config)
449 "Return a PAM service for @command{slim}."
450 (list (unix-pam-service
451 "slim"
452 #:allow-empty-passwords?
453 (slim-configuration-allow-empty-passwords? config))))
454
455 (define (slim-shepherd-service config)
456 (define slim.cfg
457 (let ((xinitrc (xinitrc #:fallback-session
458 (slim-configuration-auto-login-session config)))
459 (slim (slim-configuration-slim config))
460 (xauth (slim-configuration-xauth config))
461 (startx (slim-configuration-startx config))
462 (shepherd (slim-configuration-shepherd config))
463 (theme-name (slim-configuration-theme-name config))
464 (sessreg (slim-configuration-sessreg config)))
465 (mixed-text-file "slim.cfg" "
466 default_path /run/current-system/profile/bin
467 default_xserver " startx "
468 xserver_arguments :0 vt7
469 xauth_path " xauth "/bin/xauth
470 authfile /var/run/slim.auth
471
472 # The login command. '%session' is replaced by the chosen session name, one
473 # of the names specified in the 'sessions' setting: 'wmaker', 'xfce', etc.
474 login_cmd exec " xinitrc " %session
475 sessiondir /run/current-system/profile/share/xsessions
476 session_msg session (F1 to change):
477 sessionstart_cmd " sessreg "/bin/sessreg -a -l $DISPLAY %user
478 sessionstop_cmd " sessreg "/bin/sessreg -d -l $DISPLAY %user
479
480 halt_cmd " shepherd "/sbin/halt
481 reboot_cmd " shepherd "/sbin/reboot\n"
482 (if (slim-configuration-auto-login? config)
483 (string-append "auto_login yes\ndefault_user "
484 (slim-configuration-default-user config) "\n")
485 "")
486 (if theme-name
487 (string-append "current_theme " theme-name "\n")
488 ""))))
489
490 (define theme
491 (slim-configuration-theme config))
492
493 (list (shepherd-service
494 (documentation "Xorg display server")
495 (provision '(xorg-server))
496 (requirement '(user-processes host-name udev))
497 (start
498 #~(lambda ()
499 ;; A stale lock file can prevent SLiM from starting, so remove it to
500 ;; be on the safe side.
501 (false-if-exception (delete-file "/var/run/slim.lock"))
502
503 (fork+exec-command
504 (list (string-append #$slim "/bin/slim") "-nodaemon")
505 #:environment-variables
506 (list (string-append "SLIM_CFGFILE=" #$slim.cfg)
507 #$@(if theme
508 (list #~(string-append "SLIM_THEMESDIR=" #$theme))
509 #~())))))
510 (stop #~(make-kill-destructor))
511 (respawn? #t))))
512
513 (define slim-service-type
514 (service-type (name 'slim)
515 (extensions
516 (list (service-extension shepherd-root-service-type
517 slim-shepherd-service)
518 (service-extension pam-root-service-type
519 slim-pam-service)
520
521 ;; Unconditionally add xterm to the system profile, to
522 ;; avoid bad surprises.
523 (service-extension profile-service-type
524 (const (list xterm)))))
525 (default-value (slim-configuration))))
526
527 (define-deprecated (slim-service #:key (slim slim)
528 (allow-empty-passwords? #t) auto-login?
529 (default-user "")
530 (theme %default-slim-theme)
531 (theme-name %default-slim-theme-name)
532 (xauth xauth) (shepherd shepherd)
533 (auto-login-session #f)
534 (startx (xorg-start-command)))
535 slim-service-type
536 "Return a service that spawns the SLiM graphical login manager, which in
537 turn starts the X display server with @var{startx}, a command as returned by
538 @code{xorg-start-command}.
539
540 @cindex X session
541
542 SLiM automatically looks for session types described by the @file{.desktop}
543 files in @file{/run/current-system/profile/share/xsessions} and allows users
544 to choose a session from the log-in screen using @kbd{F1}. Packages such as
545 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
546 adding them to the system-wide set of packages automatically makes them
547 available at the log-in screen.
548
549 In addition, @file{~/.xsession} files are honored. When available,
550 @file{~/.xsession} must be an executable that starts a window manager
551 and/or other X clients.
552
553 When @var{allow-empty-passwords?} is true, allow logins with an empty
554 password. When @var{auto-login?} is true, log in automatically as
555 @var{default-user} with @var{auto-login-session}.
556
557 If @var{theme} is @code{#f}, the use the default log-in theme; otherwise
558 @var{theme} must be a gexp denoting the name of a directory containing the
559 theme to use. In that case, @var{theme-name} specifies the name of the
560 theme."
561 (service slim-service-type
562 (slim-configuration
563 (slim slim)
564 (allow-empty-passwords? allow-empty-passwords?)
565 (auto-login? auto-login?) (default-user default-user)
566 (theme theme) (theme-name theme-name)
567 (xauth xauth) (shepherd shepherd)
568 (auto-login-session auto-login-session)
569 (startx startx))))
570
571 \f
572 ;;;
573 ;;; Screen lockers & co.
574 ;;;
575
576 (define-record-type <screen-locker>
577 (screen-locker name program empty?)
578 screen-locker?
579 (name screen-locker-name) ;string
580 (program screen-locker-program) ;gexp
581 (empty? screen-locker-allows-empty-passwords?)) ;Boolean
582
583 (define screen-locker-pam-services
584 (match-lambda
585 (($ <screen-locker> name _ empty?)
586 (list (unix-pam-service name
587 #:allow-empty-passwords? empty?)))))
588
589 (define screen-locker-setuid-programs
590 (compose list screen-locker-program))
591
592 (define screen-locker-service-type
593 (service-type (name 'screen-locker)
594 (extensions
595 (list (service-extension pam-root-service-type
596 screen-locker-pam-services)
597 (service-extension setuid-program-service-type
598 screen-locker-setuid-programs)))))
599
600 (define* (screen-locker-service package
601 #:optional
602 (program (package-name package))
603 #:key allow-empty-passwords?)
604 "Add @var{package}, a package for a screen locker or screen saver whose
605 command is @var{program}, to the set of setuid programs and add a PAM entry
606 for it. For example:
607
608 @lisp
609 (screen-locker-service xlockmore \"xlock\")
610 @end lisp
611
612 makes the good ol' XlockMore usable."
613 (service screen-locker-service-type
614 (screen-locker program
615 (file-append package "/bin/" program)
616 allow-empty-passwords?)))
617
618 (define %gdm-accounts
619 (list (user-group (name "gdm") (system? #t))
620 (user-account
621 (name "gdm")
622 (group "gdm")
623 (system? #t)
624 (comment "GNOME Display Manager user")
625 (home-directory "/var/lib/gdm")
626 (shell (file-append shadow "/sbin/nologin")))))
627
628 (define dbus-daemon-wrapper
629 (program-file "gdm-dbus-wrapper"
630 #~(begin
631 (setenv "XDG_CONFIG_DIRS"
632 "/run/current-system/profile/etc/xdg")
633 (setenv "XDG_DATA_DIRS"
634 "/run/current-system/profile/share")
635 (apply execl (string-append #$dbus "/bin/dbus-daemon")
636 (program-arguments)))))
637
638 (define-record-type* <gdm-configuration>
639 gdm-configuration make-gdm-configuration
640 gdm-configuration?
641 (gdm gdm-configuration-gdm (default gdm))
642 (allow-empty-passwords? gdm-configuration-allow-empty-passwords? (default #t))
643 (auto-login? gdm-configuration-auto-login? (default #f))
644 (dbus-daemon gdm-configuration-dbus-daemon (default dbus-daemon-wrapper))
645 (default-user gdm-configuration-default-user (default #f))
646 (gnome-shell-assets gdm-configuration-gnome-shell-assets
647 (default (list adwaita-icon-theme font-cantarell)))
648 (x-server gdm-configuration-x-server
649 (default (xorg-wrapper)))
650 (x-session gdm-configuration-x-session
651 (default (xinitrc))))
652
653 (define (gdm-configuration-file config)
654 (mixed-text-file "gdm-custom.conf"
655 "[daemon]\n"
656 "#User=gdm\n"
657 "#Group=gdm\n"
658 (if (gdm-configuration-auto-login? config)
659 (string-append
660 "AutomaticLoginEnable=true\n"
661 "AutomaticLogin="
662 (or (gdm-configuration-default-user config)
663 (error "missing default user for auto-login"))
664 "\n")
665 (string-append
666 "AutomaticLoginEnable=false\n"
667 "#AutomaticLogin=\n"))
668 "#TimedLoginEnable=false\n"
669 "#TimedLogin=\n"
670 "#TimedLoginDelay=0\n"
671 "#InitialSetupEnable=true\n"
672 ;; Enable me once X is working.
673 "WaylandEnable=false\n"
674 "\n"
675 "[debug]\n"
676 "#Enable=true\n"
677 "\n"
678 "[security]\n"
679 "#DisallowTCP=true\n"
680 "#AllowRemoteAutoLogin=false\n"))
681
682 (define (gdm-pam-service config)
683 "Return a PAM service for @command{gdm}."
684 (list
685 (pam-service
686 (inherit (unix-pam-service "gdm-autologin"))
687 (auth (list (pam-entry
688 (control "[success=ok default=1]")
689 (module (file-append (gdm-configuration-gdm config)
690 "/lib/security/pam_gdm.so")))
691 (pam-entry
692 (control "sufficient")
693 (module "pam_permit.so")))))
694 (pam-service
695 (inherit (unix-pam-service "gdm-launch-environment"))
696 (auth (list (pam-entry
697 (control "required")
698 (module "pam_permit.so")))))
699 (unix-pam-service "gdm-password"
700 #:allow-empty-passwords?
701 (gdm-configuration-allow-empty-passwords? config))))
702
703 (define (gdm-shepherd-service config)
704 (list (shepherd-service
705 (documentation "Xorg display server (GDM)")
706 (provision '(xorg-server))
707 (requirement '(dbus-system user-processes host-name udev))
708 (start #~(lambda ()
709 (fork+exec-command
710 (list #$(file-append (gdm-configuration-gdm config)
711 "/bin/gdm"))
712 #:environment-variables
713 (list (string-append
714 "GDM_CUSTOM_CONF="
715 #$(gdm-configuration-file config))
716 (string-append
717 "GDM_DBUS_DAEMON="
718 #$(gdm-configuration-dbus-daemon config))
719 (string-append
720 "GDM_X_SERVER="
721 #$(gdm-configuration-x-server config))
722 (string-append
723 "GDM_X_SESSION="
724 #$(gdm-configuration-x-session config))
725 (string-append
726 "XDG_DATA_DIRS="
727 ((lambda (ls) (string-join ls ":"))
728 (map (lambda (path)
729 (string-append path "/share"))
730 ;; XXX: Remove gnome-shell below when GDM
731 ;; can depend on GNOME Shell directly.
732 (cons #$gnome-shell
733 '#$(gdm-configuration-gnome-shell-assets
734 config)))))))))
735 (stop #~(make-kill-destructor))
736 (respawn? #t))))
737
738 (define gdm-service-type
739 (service-type (name 'gdm)
740 (extensions
741 (list (service-extension shepherd-root-service-type
742 gdm-shepherd-service)
743 (service-extension account-service-type
744 (const %gdm-accounts))
745 (service-extension pam-root-service-type
746 gdm-pam-service)
747 (service-extension profile-service-type
748 gdm-configuration-gnome-shell-assets)
749 (service-extension dbus-root-service-type
750 (compose list
751 gdm-configuration-gdm))))
752 (default-value (gdm-configuration))
753 (description
754 "Run the GNOME Desktop Manager (GDM), a program that allows
755 you to log in in a graphical session, whether or not you use GNOME.")))
756
757 ;; This service isn't working yet; it gets as far as starting to run the
758 ;; greeter from gnome-shell but doesn't get any further. It is here because
759 ;; it doesn't hurt anyone and perhaps it inspires someone to fix it :)
760 (define-deprecated (gdm-service #:key (gdm gdm)
761 (allow-empty-passwords? #t)
762 (x-server (xorg-wrapper)))
763 gdm-service-type
764 "Return a service that spawns the GDM graphical login manager, which in turn
765 starts the X display server with @var{X}, a command as returned by
766 @code{xorg-wrapper}.
767
768 @cindex X session
769
770 GDM automatically looks for session types described by the @file{.desktop}
771 files in @file{/run/current-system/profile/share/xsessions} and allows users
772 to choose a session from the log-in screen using @kbd{F1}. Packages such as
773 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
774 adding them to the system-wide set of packages automatically makes them
775 available at the log-in screen.
776
777 In addition, @file{~/.xsession} files are honored. When available,
778 @file{~/.xsession} must be an executable that starts a window manager
779 and/or other X clients.
780
781 When @var{allow-empty-passwords?} is true, allow logins with an empty
782 password."
783 (service gdm-service-type
784 (gdm-configuration
785 (gdm gdm)
786 (allow-empty-passwords? allow-empty-passwords?)
787 (x-server x-server))))
788
789 ;;; xorg.scm ends here