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 ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
7 ;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu services xorg)
25 #:use-module (gnu artwork)
26 #:use-module (gnu services)
27 #:use-module (gnu services shepherd)
28 #:use-module (gnu system pam)
29 #:use-module (gnu system keyboard)
30 #:use-module (gnu services base)
31 #:use-module (gnu services dbus)
32 #:use-module ((gnu packages base) #:select (canonical-package))
33 #:use-module (gnu packages guile)
34 #:use-module (gnu packages xorg)
35 #:use-module (gnu packages fonts)
36 #:use-module (gnu packages gl)
37 #:use-module (gnu packages glib)
38 #:use-module (gnu packages display-managers)
39 #:use-module (gnu packages freedesktop)
40 #:use-module (gnu packages gnustep)
41 #:use-module (gnu packages gnome)
42 #:use-module (gnu packages admin)
43 #:use-module (gnu packages bash)
44 #:use-module (gnu system shadow)
45 #:use-module (guix gexp)
46 #:use-module (guix store)
47 #:use-module (guix packages)
48 #:use-module (guix derivations)
49 #:use-module (guix records)
50 #:use-module (guix deprecation)
51 #:use-module (srfi srfi-1)
52 #:use-module (srfi srfi-9)
53 #:use-module (srfi srfi-26)
54 #:use-module (ice-9 match)
55 #:export (xorg-configuration
57 xorg-configuration-modules
58 xorg-configuration-fonts
59 xorg-configuration-drivers
60 xorg-configuration-resolutions
61 xorg-configuration-extra-config
62 xorg-configuration-server
63 xorg-configuration-server-arguments
72 %default-slim-theme-name
76 slim-configuration-slim
77 slim-configuration-allow-empty-passwords?
78 slim-configuration-auto-login?
79 slim-configuration-default-user
80 slim-configuration-theme
81 slim-configuration-theme-name
82 slim-configuration-xauth
83 slim-configuration-shepherd
84 slim-configuration-auto-login-session
85 slim-configuration-xorg
86 slim-configuration-display
88 slim-configuration-sessreg
95 screen-locker-service-type
99 localed-configuration?
105 set-xorg-configuration))
109 ;;; Services that relate to the X Window System.
113 (define %default-xorg-modules
114 ;; Default list of modules loaded by the server. When multiple drivers
115 ;; match, the first one in the list is loaded.
116 (list xf86-video-vesa
127 ;; Libinput is the new thing and is recommended over evdev/synaptics:
128 ;; <http://who-t.blogspot.fr/2015/01/xf86-input-libinput-compatibility-with.html>.
134 xf86-input-synaptics))
136 (define %default-xorg-fonts
137 ;; Default list of fonts available to the X server.
138 (list (file-append font-alias "/share/fonts/X11/75dpi")
139 (file-append font-alias "/share/fonts/X11/100dpi")
140 (file-append font-alias "/share/fonts/X11/misc")
141 (file-append font-alias "/share/fonts/X11/cyrillic")
142 (file-append font-misc-misc ;default fonts for xterm
143 "/share/fonts/X11/misc")
144 (file-append font-adobe75dpi "/share/fonts/X11/75dpi")))
146 (define %default-xorg-server-arguments
147 ;; Default command-line arguments for X.
148 '("-nolisten" "tcp"))
150 ;; Configuration of an Xorg server.
151 (define-record-type* <xorg-configuration>
152 xorg-configuration make-xorg-configuration
154 (modules xorg-configuration-modules ;list of packages
155 (default %default-xorg-modules))
156 (fonts xorg-configuration-fonts ;list of packges
157 (default %default-xorg-fonts))
158 (drivers xorg-configuration-drivers ;list of strings
160 (resolutions xorg-configuration-resolutions ;list of tuples
162 (keyboard-layout xorg-configuration-keyboard-layout ;#f | <keyboard-layout>
164 (extra-config xorg-configuration-extra-config ;list of strings
166 (server xorg-configuration-server ;package
167 (default xorg-server))
168 (server-arguments xorg-configuration-server-arguments ;list of strings
169 (default %default-xorg-server-arguments)))
171 (define (xorg-configuration->file config)
172 "Compute an Xorg configuration file corresponding to CONFIG, an
173 <xorg-configuration> record."
175 ;; 'xorg-server' provides 'fbdevhw.so' etc.
176 (append (xorg-configuration-modules config)
181 (use-modules (ice-9 match)
185 (call-with-output-file #$output
188 '#$(xorg-configuration-drivers config))
190 (define (device-section driver)
193 Identifier \"device-" driver "\"
194 Driver \"" driver "\"
197 (define (screen-section driver resolutions)
200 Identifier \"screen-" driver "\"
201 Device \"device-" driver "\"
202 SubSection \"Display\"
204 (string-join (map (match-lambda
206 (string-append "\"" (number->string x)
207 "x" (number->string y) "\"")))
212 (define (input-class-section layout variant model options)
214 Section \"InputClass\"
215 Identifier \"evdev keyboard catchall\"
216 MatchIsKeyboard \"on\"
217 Option \"XkbLayout\" " (object->string layout)
219 (string-append " Option \"XkbVariant\" \""
223 (string-append " Option \"XkbModel\" \""
230 (string-append " Option \"XkbOptions\" \""
231 (string-join options ",") "\""))) "
233 MatchDevicePath \"/dev/input/event*\"
237 (define (expand modules)
238 ;; Append to MODULES the relevant /lib/xorg/modules
240 (append-map (lambda (module)
241 (filter-map (lambda (directory)
242 (let ((full (string-append module
244 (and (file-exists? full)
246 '("/lib/xorg/modules/drivers"
247 "/lib/xorg/modules/input"
248 "/lib/xorg/modules/multimedia"
249 "/lib/xorg/modules/extensions")))
252 (display "Section \"Files\"\n" port)
253 (for-each (lambda (font)
254 (format port " FontPath \"~a\"~%" font))
255 '#$(xorg-configuration-fonts config))
256 (for-each (lambda (module)
258 " ModulePath \"~a\"~%"
260 (append (expand '#$all-modules)
262 ;; For fbdevhw.so and so on.
263 (list #$(file-append xorg-server
264 "/lib/xorg/modules"))))
265 (display "EndSection\n" port)
267 Section \"ServerFlags\"
268 Option \"AllowMouseOpenFail\" \"on\"
271 (display (string-join (map device-section drivers) "\n")
274 (display (string-join
275 (map (cut screen-section <>
276 '#$(xorg-configuration-resolutions config))
282 (let ((layout #$(and=> (xorg-configuration-keyboard-layout config)
283 keyboard-layout-name))
284 (variant #$(and=> (xorg-configuration-keyboard-layout config)
285 keyboard-layout-variant))
286 (model #$(and=> (xorg-configuration-keyboard-layout config)
287 keyboard-layout-model))
288 (options '#$(and=> (xorg-configuration-keyboard-layout config)
289 keyboard-layout-options)))
291 (display (input-class-section layout variant model options)
295 (for-each (lambda (config)
296 (display config port))
297 '#$(xorg-configuration-extra-config config))))))
299 (computed-file "xserver.conf" build))
301 (define (xorg-configuration-directory modules)
302 "Return a directory that contains the @code{.conf} files for X.org that
303 includes the @code{share/X11/xorg.conf.d} directories of each package listed
305 (with-imported-modules '((guix build utils))
306 (computed-file "xorg.conf.d"
308 (use-modules (guix build utils)
312 (append-map (lambda (module)
313 (find-files (string-append
315 "/share/X11/xorg.conf.d")
320 (for-each (lambda (file)
322 (string-append #$output "/"
327 (define* (xorg-wrapper #:optional (config (xorg-configuration)))
328 "Return a derivation that builds a script to start the X server with the
329 given @var{config}. The resulting script should be used in place of
332 ;; Write a small wrapper around the X server.
334 (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
335 (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
337 (let ((X (string-append #$(xorg-configuration-server config) "/bin/X")))
339 "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
340 "-config" #$(xorg-configuration->file config)
341 "-configdir" #$(xorg-configuration-directory
342 (xorg-configuration-modules config))
343 (cdr (command-line))))))
345 (program-file "X-wrapper" exp))
347 (define* (xorg-start-command #:optional (config (xorg-configuration)))
348 "Return a @code{startx} script in which the modules, fonts, etc. specified
349 in @var{config}, are available. The result should be used in place of
352 (xorg-wrapper config))
355 ;; Write a small wrapper around the X server.
356 #~(apply execl #$X #$X ;; Second #$X is for argv[0].
357 "-logverbose" "-verbose" "-terminate"
358 #$@(xorg-configuration-server-arguments config)
359 (cdr (command-line))))
361 (program-file "startx" exp))
363 (define* (xinitrc #:key fallback-session)
364 "Return a system-wide xinitrc script that starts the specified X session,
365 which should be passed to this script as the first argument. If not, the
366 @var{fallback-session} will be used or, if @var{fallback-session} is false, a
367 desktop session from the system or user profile will be used."
370 (use-modules (ice-9 match)
377 (define (close-all-fdes)
378 ;; Close all the open file descriptors except 0 to 2.
380 (when (< fd 4096) ;FIXME: use sysconf + _SC_OPEN_MAX
381 (false-if-exception (close-fdes fd))
384 (define (exec-from-login-shell command . args)
385 ;; Run COMMAND from a login shell so that it gets to see the same
386 ;; environment variables that one gets when logging in on a tty, for
388 (let* ((pw (getpw (getuid)))
389 (shell (passwd:shell pw)))
390 ;; Close any open file descriptors. This is all the more
391 ;; important that SLiM itself exec's us directly without closing
392 ;; its own file descriptors!
395 ;; The '--login' option is supported at least by Bash and zsh.
396 (execl shell shell "--login" "-c"
397 (string-join (cons command args)))))
399 (define system-profile
400 "/run/current-system/profile")
403 (and=> (getpw (getuid))
405 (string-append (passwd:dir pw) "/.guix-profile"))))
407 (define (xsession-command desktop-file)
408 ;; Read from DESKTOP-FILE its X session command and return it as a
411 (make-regexp "^[[:blank:]]*Exec=(.*)$"))
413 (call-with-input-file desktop-file
416 (match (read-line port)
418 ((= (cut regexp-exec exec-regexp <>) result)
420 (string-tokenize (match:substring result 1))
423 (define (find-session profile)
424 ;; Return an X session command from PROFILE or #f if none was found.
425 (let ((directory (string-append profile "/share/xsessions")))
426 (match (scandir directory
427 (cut string-suffix? ".desktop" <>))
431 (any xsession-command
432 (map (cut string-append directory "/" <>)
435 (let* ((home (getenv "HOME"))
436 (xsession-file (string-append home "/.xsession"))
437 (session (match (command-line)
439 #$(if fallback-session
440 #~(list #$fallback-session)
444 (if (file-exists? xsession-file)
445 ;; Run ~/.xsession when it exists.
446 (apply exec-from-login-shell xsession-file
448 ;; Otherwise, start the specified session or a fallback.
449 (apply exec-from-login-shell
451 (find-session user-profile)
452 (find-session system-profile)))))))
454 (program-file "xinitrc" builder))
458 ;;; SLiM log-in manager.
461 (define %default-slim-theme
462 ;; Theme based on work by Felipe López.
463 (file-append %artwork-repository "/slim"))
465 (define %default-slim-theme-name
466 ;; This must be the name of the sub-directory in %DEFAULT-SLIM-THEME that
467 ;; contains the actual theme files.
470 (define-record-type* <slim-configuration>
471 slim-configuration make-slim-configuration
473 (slim slim-configuration-slim
475 (allow-empty-passwords? slim-configuration-allow-empty-passwords?
477 (auto-login? slim-configuration-auto-login?
479 (default-user slim-configuration-default-user
481 (theme slim-configuration-theme
482 (default %default-slim-theme))
483 (theme-name slim-configuration-theme-name
484 (default %default-slim-theme-name))
485 (xauth slim-configuration-xauth
487 (shepherd slim-configuration-shepherd
489 (auto-login-session slim-configuration-auto-login-session
491 (xorg-configuration slim-configuration-xorg
492 (default (xorg-configuration)))
493 (display slim-configuration-display
495 (vt slim-configuration-vt
497 (sessreg slim-configuration-sessreg
500 (define (slim-pam-service config)
501 "Return a PAM service for @command{slim}."
502 (list (unix-pam-service
505 #:allow-empty-passwords?
506 (slim-configuration-allow-empty-passwords? config))))
508 (define (slim-shepherd-service config)
509 (let* ((xinitrc (xinitrc #:fallback-session
510 (slim-configuration-auto-login-session config)))
511 (xauth (slim-configuration-xauth config))
512 (startx (xorg-start-command (slim-configuration-xorg config)))
513 (display (slim-configuration-display config))
514 (vt (slim-configuration-vt config))
515 (shepherd (slim-configuration-shepherd config))
516 (theme-name (slim-configuration-theme-name config))
517 (sessreg (slim-configuration-sessreg config))
518 (lockfile (string-append "/var/run/slim-" vt ".lock")))
520 (mixed-text-file "slim.cfg" "
521 default_path /run/current-system/profile/bin
522 default_xserver " startx "
523 display_name " display "
524 xserver_arguments " vt "
525 xauth_path " xauth "/bin/xauth
526 authfile /var/run/slim-" vt ".auth
527 lockfile " lockfile "
528 logfile /var/log/slim-" vt ".log
530 # The login command. '%session' is replaced by the chosen session name, one
531 # of the names specified in the 'sessions' setting: 'wmaker', 'xfce', etc.
532 login_cmd exec " xinitrc " %session
533 sessiondir /run/current-system/profile/share/xsessions
534 session_msg session (F1 to change):
535 sessionstart_cmd " sessreg "/bin/sessreg -a -l $DISPLAY %user
536 sessionstop_cmd " sessreg "/bin/sessreg -d -l $DISPLAY %user
538 halt_cmd " shepherd "/sbin/halt
539 reboot_cmd " shepherd "/sbin/reboot\n"
540 (if (slim-configuration-auto-login? config)
541 (string-append "auto_login yes\ndefault_user "
542 (slim-configuration-default-user config) "\n")
545 (string-append "current_theme " theme-name "\n")
549 (slim-configuration-theme config))
551 (list (shepherd-service
552 (documentation "Xorg display server")
554 ;; For compatibility, also provide 'xorg-server'.
555 (if (string=? vt "vt7")
559 (list (symbol-append 'xorg-server-
560 (string->symbol vt)))))
561 (requirement '(user-processes host-name udev))
564 ;; A stale lock file can prevent SLiM from starting, so remove it to
565 ;; be on the safe side.
566 (false-if-exception (delete-file lockfile))
569 (list (string-append #$(slim-configuration-slim config)
572 #:environment-variables
573 (list (string-append "SLIM_CFGFILE=" #$slim.cfg)
575 (list #~(string-append "SLIM_THEMESDIR=" #$theme))
577 (stop #~(make-kill-destructor))
580 (define slim-service-type
581 (service-type (name 'slim)
583 (list (service-extension shepherd-root-service-type
584 slim-shepherd-service)
585 (service-extension pam-root-service-type
588 ;; Unconditionally add xterm to the system profile, to
589 ;; avoid bad surprises.
590 (service-extension profile-service-type
591 (const (list xterm)))))
592 (default-value (slim-configuration))))
594 (define-deprecated (slim-service #:key (slim slim)
595 (allow-empty-passwords? #t) auto-login?
597 (theme %default-slim-theme)
598 (theme-name %default-slim-theme-name)
599 (xauth xauth) (shepherd shepherd)
600 (auto-login-session #f)
601 (startx (xorg-start-command)))
603 "Return a service that spawns the SLiM graphical login manager, which in
604 turn starts the X display server with @var{startx}, a command as returned by
605 @code{xorg-start-command}.
609 SLiM automatically looks for session types described by the @file{.desktop}
610 files in @file{/run/current-system/profile/share/xsessions} and allows users
611 to choose a session from the log-in screen using @kbd{F1}. Packages such as
612 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
613 adding them to the system-wide set of packages automatically makes them
614 available at the log-in screen.
616 In addition, @file{~/.xsession} files are honored. When available,
617 @file{~/.xsession} must be an executable that starts a window manager
618 and/or other X clients.
620 When @var{allow-empty-passwords?} is true, allow logins with an empty
621 password. When @var{auto-login?} is true, log in automatically as
622 @var{default-user} with @var{auto-login-session}.
624 If @var{theme} is @code{#f}, the use the default log-in theme; otherwise
625 @var{theme} must be a gexp denoting the name of a directory containing the
626 theme to use. In that case, @var{theme-name} specifies the name of the
628 (service slim-service-type
631 (allow-empty-passwords? allow-empty-passwords?)
632 (auto-login? auto-login?) (default-user default-user)
633 (theme theme) (theme-name theme-name)
634 (xauth xauth) (shepherd shepherd)
635 (auto-login-session auto-login-session))))
639 ;;; Screen lockers & co.
642 (define-record-type <screen-locker>
643 (screen-locker name program empty?)
645 (name screen-locker-name) ;string
646 (program screen-locker-program) ;gexp
647 (empty? screen-locker-allows-empty-passwords?)) ;Boolean
649 (define screen-locker-pam-services
651 (($ <screen-locker> name _ empty?)
652 (list (unix-pam-service name
653 #:allow-empty-passwords? empty?)))))
655 (define screen-locker-setuid-programs
656 (compose list screen-locker-program))
658 (define screen-locker-service-type
659 (service-type (name 'screen-locker)
661 (list (service-extension pam-root-service-type
662 screen-locker-pam-services)
663 (service-extension setuid-program-service-type
664 screen-locker-setuid-programs)))))
666 (define* (screen-locker-service package
668 (program (package-name package))
669 #:key allow-empty-passwords?)
670 "Add @var{package}, a package for a screen locker or screen saver whose
671 command is @var{program}, to the set of setuid programs and add a PAM entry
675 (screen-locker-service xlockmore \"xlock\")
678 makes the good ol' XlockMore usable."
679 (service screen-locker-service-type
680 (screen-locker program
681 (file-append package "/bin/" program)
682 allow-empty-passwords?)))
689 (define-record-type* <localed-configuration>
690 localed-configuration make-localed-configuration
691 localed-configuration?
692 (localed localed-configuration-localed
694 (keyboard-layout localed-configuration-keyboard-layout
697 (define (localed-dbus-service config)
698 "Return the 'localed' D-Bus service for @var{config}, a
699 @code{<localed-configuration>} record."
700 (define keyboard-layout
701 (localed-configuration-keyboard-layout config))
703 ;; The primary purpose of 'localed' is to tell GDM what the "current" Xorg
704 ;; keyboard layout is. If 'localed' is missing, or if it's unable to
705 ;; determine the current XKB layout, then GDM forcefully installs its
706 ;; default XKB config (US English). Here we communicate the configured
707 ;; layout through environment variables.
710 (let* ((layout (keyboard-layout-name keyboard-layout))
711 (variant (keyboard-layout-variant keyboard-layout))
712 (model (keyboard-layout-model keyboard-layout))
713 (options (keyboard-layout-options keyboard-layout)))
714 (list (wrapped-dbus-service
715 (localed-configuration-localed config)
716 "libexec/localed/localed"
717 `(("GUIX_XKB_LAYOUT" ,layout)
719 `(("GUIX_XKB_VARIANT" ,variant))
722 `(("GUIX_XKB_MODEL" ,model))
724 ,@(if (null? options)
726 `(("GUIX_XKB_OPTIONS"
727 ,(string-join options ","))))))))
730 (define localed-service-type
731 (let ((package (lambda (config)
732 ;; Don't bother if the user didn't specify any keyboard
734 (if (localed-configuration-keyboard-layout config)
735 (list (localed-configuration-localed config))
737 (service-type (name 'localed)
739 (list (service-extension dbus-root-service-type
740 localed-dbus-service)
741 (service-extension udev-service-type package)
742 (service-extension polkit-service-type package)
744 ;; Add 'localectl' to the profile.
745 (service-extension profile-service-type package)))
747 ;; This service can be extended, typically by the X login
748 ;; manager, to communicate the chosen Xorg keyboard layout.
749 (compose (lambda (extensions)
750 (find keyboard-layout? extensions)))
751 (extend (lambda (config keyboard-layout)
752 (localed-configuration
754 (keyboard-layout keyboard-layout))))
756 "Run the locale daemon, @command{localed}, which can be used
757 to control the system locale and keyboard mapping from user programs such as
758 the GNOME desktop environment.")
759 (default-value (localed-configuration)))))
763 ;;; GNOME Desktop Manager.
766 (define %gdm-accounts
767 (list (user-group (name "gdm") (system? #t))
772 (comment "GNOME Display Manager user")
773 (home-directory "/var/lib/gdm")
774 (shell (file-append shadow "/sbin/nologin")))))
776 (define dbus-daemon-wrapper
780 (use-modules (srfi srfi-26))
782 (define system-profile
783 "/run/current-system/profile")
786 (and=> (getpw (getuid))
788 (string-append (passwd:dir pw) "/.guix-profile"))))
790 ;; If we are able to find the user's profile, we can add it to
791 ;; the search paths set below. We need to do this so that D-Bus
792 ;; can start services installed by the user. This allows
793 ;; applications that require session D-Bus services (e.g,
794 ;; 'evolution') to work even if those services are only available
795 ;; in the user's profile. See <https://bugs.gnu.org/35267>.
798 (list user-profile system-profile)
799 (list system-profile)))
801 (setenv "XDG_CONFIG_DIRS"
802 (string-join (map (cut string-append <> "/etc/xdg") profiles)
804 (setenv "XDG_DATA_DIRS"
805 (string-join (map (cut string-append <> "/share") profiles)
807 (apply execl (string-append #$dbus "/bin/dbus-daemon")
808 (program-arguments)))))
810 (define-record-type* <gdm-configuration>
811 gdm-configuration make-gdm-configuration
813 (gdm gdm-configuration-gdm (default gdm))
814 (allow-empty-passwords? gdm-configuration-allow-empty-passwords? (default #t))
815 (auto-login? gdm-configuration-auto-login? (default #f))
816 (dbus-daemon gdm-configuration-dbus-daemon (default dbus-daemon-wrapper))
817 (default-user gdm-configuration-default-user (default #f))
818 (gnome-shell-assets gdm-configuration-gnome-shell-assets
819 (default (list adwaita-icon-theme font-cantarell)))
820 (xorg-configuration gdm-configuration-xorg
821 (default (xorg-configuration)))
822 (x-session gdm-configuration-x-session
823 (default (xinitrc))))
825 (define (gdm-configuration-file config)
826 (mixed-text-file "gdm-custom.conf"
830 (if (gdm-configuration-auto-login? config)
832 "AutomaticLoginEnable=true\n"
834 (or (gdm-configuration-default-user config)
835 (error "missing default user for auto-login"))
838 "AutomaticLoginEnable=false\n"
839 "#AutomaticLogin=\n"))
840 "#TimedLoginEnable=false\n"
842 "#TimedLoginDelay=0\n"
843 "#InitialSetupEnable=true\n"
844 ;; Enable me once X is working.
845 "WaylandEnable=false\n"
851 "#DisallowTCP=true\n"
852 "#AllowRemoteAutoLogin=false\n"))
854 (define (gdm-pam-service config)
855 "Return a PAM service for @command{gdm}."
858 (inherit (unix-pam-service "gdm-autologin"
860 (auth (list (pam-entry
861 (control "[success=ok default=1]")
862 (module (file-append (gdm-configuration-gdm config)
863 "/lib/security/pam_gdm.so")))
865 (control "sufficient")
866 (module "pam_permit.so")))))
868 (inherit (unix-pam-service "gdm-launch-environment"))
869 (auth (list (pam-entry
871 (module "pam_permit.so")))))
872 (unix-pam-service "gdm-password"
874 #:allow-empty-passwords?
875 (gdm-configuration-allow-empty-passwords? config))))
877 (define (gdm-shepherd-service config)
878 (list (shepherd-service
879 (documentation "Xorg display server (GDM)")
880 (provision '(xorg-server))
881 (requirement '(dbus-system user-processes host-name udev))
884 (list #$(file-append (gdm-configuration-gdm config)
886 #:environment-variables
889 #$(gdm-configuration-file config))
892 #$(gdm-configuration-dbus-daemon config))
896 (gdm-configuration-xorg config)))
899 #$(gdm-configuration-x-session config))
902 ((lambda (ls) (string-join ls ":"))
904 (string-append path "/share"))
905 ;; XXX: Remove gnome-shell below when GDM
906 ;; can depend on GNOME Shell directly.
908 '#$(gdm-configuration-gnome-shell-assets
910 (stop #~(make-kill-destructor))
913 (define gdm-service-type
914 (service-type (name 'gdm)
916 (list (service-extension shepherd-root-service-type
917 gdm-shepherd-service)
918 (service-extension account-service-type
919 (const %gdm-accounts))
920 (service-extension pam-root-service-type
922 (service-extension profile-service-type
923 gdm-configuration-gnome-shell-assets)
924 (service-extension dbus-root-service-type
926 gdm-configuration-gdm))
927 (service-extension localed-service-type
929 xorg-configuration-keyboard-layout
930 gdm-configuration-xorg))))
932 ;; For convenience, this service can be extended with an
933 ;; <xorg-configuration> record. Take the first one that
935 (compose (lambda (extensions)
938 ((config . _) config))))
939 (extend (lambda (config xorg-configuration)
940 (if xorg-configuration
943 (xorg-configuration xorg-configuration))
946 (default-value (gdm-configuration))
948 "Run the GNOME Desktop Manager (GDM), a program that allows
949 you to log in in a graphical session, whether or not you use GNOME.")))
951 (define-deprecated (gdm-service #:key (gdm gdm)
952 (allow-empty-passwords? #t)
953 (x-server (xorg-wrapper)))
955 "Return a service that spawns the GDM graphical login manager, which in turn
956 starts the X display server with @var{X}, a command as returned by
961 GDM automatically looks for session types described by the @file{.desktop}
962 files in @file{/run/current-system/profile/share/xsessions} and allows users
963 to choose a session from the log-in screen using @kbd{F1}. Packages such as
964 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
965 adding them to the system-wide set of packages automatically makes them
966 available at the log-in screen.
968 In addition, @file{~/.xsession} files are honored. When available,
969 @file{~/.xsession} must be an executable that starts a window manager
970 and/or other X clients.
972 When @var{allow-empty-passwords?} is true, allow logins with an empty
974 (service gdm-service-type
977 (allow-empty-passwords? allow-empty-passwords?))))
979 (define* (set-xorg-configuration config
981 (login-manager-service-type
983 "Tell the log-in manager (of type @var{login-manager-service-type}) to use
984 @var{config}, an <xorg-configuration> record."
985 (simple-service 'set-xorg-configuration
986 login-manager-service-type
989 ;;; xorg.scm ends here