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>
8 ;;; Copyright © 2020 shtwzrd <shtwzrd@protonmail.com>
9 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.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 xorg)
27 #:use-module (gnu artwork)
28 #:use-module (gnu services)
29 #:use-module (gnu services shepherd)
30 #:use-module (gnu system pam)
31 #:use-module (gnu system keyboard)
32 #:use-module (gnu services base)
33 #:use-module (gnu services dbus)
34 #:use-module ((gnu packages base) #:select (canonical-package))
35 #:use-module (gnu packages guile)
36 #:use-module (gnu packages xorg)
37 #:use-module (gnu packages fonts)
38 #:use-module (gnu packages gl)
39 #:use-module (gnu packages glib)
40 #:use-module (gnu packages display-managers)
41 #:use-module (gnu packages freedesktop)
42 #:use-module (gnu packages gnustep)
43 #:use-module (gnu packages gnome)
44 #:use-module (gnu packages admin)
45 #:use-module (gnu packages bash)
46 #:use-module (gnu system shadow)
47 #:use-module (guix gexp)
48 #:use-module (guix store)
49 #:use-module (guix packages)
50 #:use-module (guix derivations)
51 #:use-module (guix records)
52 #:use-module (guix deprecation)
53 #:use-module (srfi srfi-1)
54 #:use-module (srfi srfi-9)
55 #:use-module (srfi srfi-26)
56 #:use-module (ice-9 match)
57 #:export (xorg-configuration
59 xorg-configuration-modules
60 xorg-configuration-fonts
61 xorg-configuration-drivers
62 xorg-configuration-resolutions
63 xorg-configuration-extra-config
64 xorg-configuration-server
65 xorg-configuration-server-arguments
74 %default-slim-theme-name
78 slim-configuration-slim
79 slim-configuration-allow-empty-passwords?
80 slim-configuration-auto-login?
81 slim-configuration-default-user
82 slim-configuration-theme
83 slim-configuration-theme-name
84 slim-configuration-xauth
85 slim-configuration-shepherd
86 slim-configuration-auto-login-session
87 slim-configuration-xorg
88 slim-configuration-display
90 slim-configuration-sessreg
97 screen-locker-service-type
100 localed-configuration
101 localed-configuration?
108 handle-xorg-configuration
109 set-xorg-configuration))
113 ;;; Services that relate to the X Window System.
117 (define %default-xorg-modules
118 ;; Default list of modules loaded by the server. When multiple drivers
119 ;; match, the first one in the list is loaded.
120 (list xf86-video-vesa
131 ;; Libinput is the new thing and is recommended over evdev/synaptics:
132 ;; <http://who-t.blogspot.fr/2015/01/xf86-input-libinput-compatibility-with.html>.
138 xf86-input-synaptics))
140 (define %default-xorg-fonts
141 ;; Default list of fonts available to the X server.
142 (list (file-append font-alias "/share/fonts/X11/75dpi")
143 (file-append font-alias "/share/fonts/X11/100dpi")
144 (file-append font-alias "/share/fonts/X11/misc")
145 (file-append font-alias "/share/fonts/X11/cyrillic")
146 (file-append font-misc-misc ;default fonts for xterm
147 "/share/fonts/X11/misc")
148 (file-append font-adobe75dpi "/share/fonts/X11/75dpi")))
150 (define %default-xorg-server-arguments
151 ;; Default command-line arguments for X.
152 '("-nolisten" "tcp"))
154 ;; Configuration of an Xorg server.
155 (define-record-type* <xorg-configuration>
156 xorg-configuration make-xorg-configuration
158 (modules xorg-configuration-modules ;list of packages
159 ; filter out modules not supported on current system
162 (member (%current-system)
163 (package-supported-systems p)))
164 %default-xorg-modules)))
165 (fonts xorg-configuration-fonts ;list of packges
166 (default %default-xorg-fonts))
167 (drivers xorg-configuration-drivers ;list of strings
169 (resolutions xorg-configuration-resolutions ;list of tuples
171 (keyboard-layout xorg-configuration-keyboard-layout ;#f | <keyboard-layout>
173 (extra-config xorg-configuration-extra-config ;list of strings
175 (server xorg-configuration-server ;package
176 (default xorg-server))
177 (server-arguments xorg-configuration-server-arguments ;list of strings
178 (default %default-xorg-server-arguments)))
180 (define (xorg-configuration->file config)
181 "Compute an Xorg configuration file corresponding to CONFIG, an
182 <xorg-configuration> record."
184 ;; 'xorg-server' provides 'fbdevhw.so' etc.
185 (append (xorg-configuration-modules config)
190 (use-modules (ice-9 match)
194 (call-with-output-file #$output
197 '#$(xorg-configuration-drivers config))
199 (define (device-section driver)
202 Identifier \"device-" driver "\"
203 Driver \"" driver "\"
206 (define (screen-section driver resolutions)
209 Identifier \"screen-" driver "\"
210 Device \"device-" driver "\"
211 SubSection \"Display\"
213 (string-join (map (match-lambda
215 (string-append "\"" (number->string x)
216 "x" (number->string y) "\"")))
221 (define (input-class-section layout variant model options)
223 Section \"InputClass\"
224 Identifier \"evdev keyboard catchall\"
225 MatchIsKeyboard \"on\"
226 Option \"XkbLayout\" " (object->string layout)
228 (string-append " Option \"XkbVariant\" \""
232 (string-append " Option \"XkbModel\" \""
239 (string-append " Option \"XkbOptions\" \""
240 (string-join options ",") "\""))) "
242 MatchDevicePath \"/dev/input/event*\"
246 (define (expand modules)
247 ;; Append to MODULES the relevant /lib/xorg/modules
249 (append-map (lambda (module)
250 (filter-map (lambda (directory)
251 (let ((full (string-append module
253 (and (file-exists? full)
255 '("/lib/xorg/modules/drivers"
256 "/lib/xorg/modules/input"
257 "/lib/xorg/modules/multimedia"
258 "/lib/xorg/modules/extensions")))
261 (display "Section \"Files\"\n" port)
262 (for-each (lambda (font)
263 (format port " FontPath \"~a\"~%" font))
264 '#$(xorg-configuration-fonts config))
265 (for-each (lambda (module)
267 " ModulePath \"~a\"~%"
269 (append (expand '#$all-modules)
271 ;; For fbdevhw.so and so on.
272 (list #$(file-append xorg-server
273 "/lib/xorg/modules"))))
274 (display "EndSection\n" port)
276 Section \"ServerFlags\"
277 Option \"AllowMouseOpenFail\" \"on\"
280 (display (string-join (map device-section drivers) "\n")
283 (display (string-join
284 (map (cut screen-section <>
285 '#$(xorg-configuration-resolutions config))
291 (let ((layout #$(and=> (xorg-configuration-keyboard-layout config)
292 keyboard-layout-name))
293 (variant #$(and=> (xorg-configuration-keyboard-layout config)
294 keyboard-layout-variant))
295 (model #$(and=> (xorg-configuration-keyboard-layout config)
296 keyboard-layout-model))
297 (options '#$(and=> (xorg-configuration-keyboard-layout config)
298 keyboard-layout-options)))
300 (display (input-class-section layout variant model options)
304 (for-each (lambda (config)
305 (display config port))
306 '#$(xorg-configuration-extra-config config))))))
308 (computed-file "xserver.conf" build))
310 (define (xorg-configuration-directory modules)
311 "Return a directory that contains the @code{.conf} files for X.org that
312 includes the @code{share/X11/xorg.conf.d} directories of each package listed
314 (with-imported-modules '((guix build utils))
315 (computed-file "xorg.conf.d"
317 (use-modules (guix build utils)
321 (append-map (lambda (module)
322 (find-files (string-append
324 "/share/X11/xorg.conf.d")
329 (for-each (lambda (file)
331 (string-append #$output "/"
336 (define* (xorg-wrapper #:optional (config (xorg-configuration)))
337 "Return a derivation that builds a script to start the X server with the
338 given @var{config}. The resulting script should be used in place of
341 ;; Write a small wrapper around the X server.
343 (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
344 (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
346 (let ((X (string-append #$(xorg-configuration-server config) "/bin/X")))
348 "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
349 "-config" #$(xorg-configuration->file config)
350 "-configdir" #$(xorg-configuration-directory
351 (xorg-configuration-modules config))
352 (cdr (command-line))))))
354 (program-file "X-wrapper" exp))
356 (define* (xorg-start-command #:optional (config (xorg-configuration)))
357 "Return a @code{startx} script in which the modules, fonts, etc. specified
358 in @var{config}, are available. The result should be used in place of
361 (xorg-wrapper config))
364 ;; Write a small wrapper around the X server.
365 #~(apply execl #$X #$X ;; Second #$X is for argv[0].
366 "-logverbose" "-verbose" "-terminate"
367 #$@(xorg-configuration-server-arguments config)
368 (cdr (command-line))))
370 (program-file "startx" exp))
372 (define* (xinitrc #:key fallback-session)
373 "Return a system-wide xinitrc script that starts the specified X session,
374 which should be passed to this script as the first argument. If not, the
375 @var{fallback-session} will be used or, if @var{fallback-session} is false, a
376 desktop session from the system or user profile will be used."
379 (use-modules (ice-9 match)
386 (define (close-all-fdes)
387 ;; Close all the open file descriptors except 0 to 2.
389 (when (< fd 4096) ;FIXME: use sysconf + _SC_OPEN_MAX
390 (false-if-exception (close-fdes fd))
393 (define (exec-from-login-shell command . args)
394 ;; Run COMMAND from a login shell so that it gets to see the same
395 ;; environment variables that one gets when logging in on a tty, for
397 (let* ((pw (getpw (getuid)))
398 (shell (passwd:shell pw)))
399 ;; Close any open file descriptors. This is all the more
400 ;; important that SLiM itself exec's us directly without closing
401 ;; its own file descriptors!
404 ;; The '--login' option is supported at least by Bash and zsh.
405 (execl shell shell "--login" "-c"
406 (string-join (cons command args)))))
408 (define system-profile
409 "/run/current-system/profile")
412 (and=> (getpw (getuid))
414 (string-append (passwd:dir pw) "/.guix-profile"))))
416 (define (xsession-command desktop-file)
417 ;; Read from DESKTOP-FILE its X session command and return it as a
420 (make-regexp "^[[:blank:]]*Exec=(.*)$"))
422 (call-with-input-file desktop-file
425 (match (read-line port)
427 ((= (cut regexp-exec exec-regexp <>) result)
429 (string-tokenize (match:substring result 1))
432 (define (find-session profile)
433 ;; Return an X session command from PROFILE or #f if none was found.
434 (let ((directory (string-append profile "/share/xsessions")))
435 (match (scandir directory
436 (cut string-suffix? ".desktop" <>))
440 (any xsession-command
441 (map (cut string-append directory "/" <>)
444 (let* ((home (getenv "HOME"))
445 (xsession-file (string-append home "/.xsession"))
446 (session (match (command-line)
448 #$(if fallback-session
449 #~(list #$fallback-session)
453 (if (file-exists? xsession-file)
454 ;; Run ~/.xsession when it exists.
455 (apply exec-from-login-shell xsession-file
457 ;; Otherwise, start the specified session or a fallback.
458 (apply exec-from-login-shell
460 (find-session user-profile)
461 (find-session system-profile)))))))
463 (program-file "xinitrc" builder))
465 (define-syntax handle-xorg-configuration
467 "Generate the `compose' and `extend' entries of a login manager
468 `service-type' to handle specifying the `xorg-configuration' through
469 a `service-extension', as used by `set-xorg-configuration'."
470 ((_ configuration-record service-type-definition)
472 (inherit service-type-definition)
473 (compose (lambda (extensions)
476 ((config . _) config))))
477 (extend (lambda (config xorg-configuration)
478 (if xorg-configuration
479 (configuration-record
481 (xorg-configuration xorg-configuration))
486 ;;; SLiM log-in manager.
489 (define %default-slim-theme
490 ;; Theme based on work by Felipe López.
491 (file-append %artwork-repository "/slim"))
493 (define %default-slim-theme-name
494 ;; This must be the name of the sub-directory in %DEFAULT-SLIM-THEME that
495 ;; contains the actual theme files.
498 (define-record-type* <slim-configuration>
499 slim-configuration make-slim-configuration
501 (slim slim-configuration-slim
503 (allow-empty-passwords? slim-configuration-allow-empty-passwords?
505 (auto-login? slim-configuration-auto-login?
507 (default-user slim-configuration-default-user
509 (theme slim-configuration-theme
510 (default %default-slim-theme))
511 (theme-name slim-configuration-theme-name
512 (default %default-slim-theme-name))
513 (xauth slim-configuration-xauth
515 (shepherd slim-configuration-shepherd
517 (auto-login-session slim-configuration-auto-login-session
519 (xorg-configuration slim-configuration-xorg
520 (default (xorg-configuration)))
521 (display slim-configuration-display
523 (vt slim-configuration-vt
525 (sessreg slim-configuration-sessreg
528 (define (slim-pam-service config)
529 "Return a PAM service for @command{slim}."
530 (list (unix-pam-service
533 #:allow-empty-passwords?
534 (slim-configuration-allow-empty-passwords? config))))
536 (define (slim-shepherd-service config)
537 (let* ((xinitrc (xinitrc #:fallback-session
538 (slim-configuration-auto-login-session config)))
539 (xauth (slim-configuration-xauth config))
540 (startx (xorg-start-command (slim-configuration-xorg config)))
541 (display (slim-configuration-display config))
542 (vt (slim-configuration-vt config))
543 (shepherd (slim-configuration-shepherd config))
544 (theme-name (slim-configuration-theme-name config))
545 (sessreg (slim-configuration-sessreg config))
546 (lockfile (string-append "/var/run/slim-" vt ".lock")))
548 (mixed-text-file "slim.cfg" "
549 default_path /run/current-system/profile/bin
550 default_xserver " startx "
551 display_name " display "
552 xserver_arguments " vt "
553 xauth_path " xauth "/bin/xauth
554 authfile /var/run/slim-" vt ".auth
555 lockfile " lockfile "
556 logfile /var/log/slim-" vt ".log
558 # The login command. '%session' is replaced by the chosen session name, one
559 # of the names specified in the 'sessions' setting: 'wmaker', 'xfce', etc.
560 login_cmd exec " xinitrc " %session
561 sessiondir /run/current-system/profile/share/xsessions
562 session_msg session (F1 to change):
563 sessionstart_cmd " sessreg "/bin/sessreg -a -l $DISPLAY %user
564 sessionstop_cmd " sessreg "/bin/sessreg -d -l $DISPLAY %user
566 halt_cmd " shepherd "/sbin/halt
567 reboot_cmd " shepherd "/sbin/reboot\n"
568 (if (slim-configuration-auto-login? config)
569 (string-append "auto_login yes\ndefault_user "
570 (slim-configuration-default-user config) "\n")
573 (string-append "current_theme " theme-name "\n")
577 (slim-configuration-theme config))
579 (list (shepherd-service
580 (documentation "Xorg display server")
582 ;; For compatibility, also provide 'xorg-server'.
583 (if (string=? vt "vt7")
587 (list (symbol-append 'xorg-server-
588 (string->symbol vt)))))
589 (requirement '(user-processes host-name udev))
592 ;; A stale lock file can prevent SLiM from starting, so remove it to
593 ;; be on the safe side.
594 (false-if-exception (delete-file lockfile))
597 (list (string-append #$(slim-configuration-slim config)
600 #:environment-variables
601 (list (string-append "SLIM_CFGFILE=" #$slim.cfg)
603 (list #~(string-append "SLIM_THEMESDIR=" #$theme))
605 (stop #~(make-kill-destructor))
608 (define slim-service-type
609 (handle-xorg-configuration slim-configuration
610 (service-type (name 'slim)
612 (list (service-extension shepherd-root-service-type
613 slim-shepherd-service)
614 (service-extension pam-root-service-type
617 ;; Unconditionally add xterm to the system profile, to
618 ;; avoid bad surprises.
619 (service-extension profile-service-type
620 (const (list xterm)))))
622 (default-value (slim-configuration)))))
624 (define-deprecated (slim-service #:key (slim slim)
625 (allow-empty-passwords? #t) auto-login?
627 (theme %default-slim-theme)
628 (theme-name %default-slim-theme-name)
629 (xauth xauth) (shepherd shepherd)
630 (auto-login-session #f)
631 (startx (xorg-start-command)))
633 "Return a service that spawns the SLiM graphical login manager, which in
634 turn starts the X display server with @var{startx}, a command as returned by
635 @code{xorg-start-command}.
639 SLiM automatically looks for session types described by the @file{.desktop}
640 files in @file{/run/current-system/profile/share/xsessions} and allows users
641 to choose a session from the log-in screen using @kbd{F1}. Packages such as
642 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
643 adding them to the system-wide set of packages automatically makes them
644 available at the log-in screen.
646 In addition, @file{~/.xsession} files are honored. When available,
647 @file{~/.xsession} must be an executable that starts a window manager
648 and/or other X clients.
650 When @var{allow-empty-passwords?} is true, allow logins with an empty
651 password. When @var{auto-login?} is true, log in automatically as
652 @var{default-user} with @var{auto-login-session}.
654 If @var{theme} is @code{#f}, the use the default log-in theme; otherwise
655 @var{theme} must be a gexp denoting the name of a directory containing the
656 theme to use. In that case, @var{theme-name} specifies the name of the
658 (service slim-service-type
661 (allow-empty-passwords? allow-empty-passwords?)
662 (auto-login? auto-login?) (default-user default-user)
663 (theme theme) (theme-name theme-name)
664 (xauth xauth) (shepherd shepherd)
665 (auto-login-session auto-login-session))))
669 ;;; Screen lockers & co.
672 (define-record-type <screen-locker>
673 (screen-locker name program empty?)
675 (name screen-locker-name) ;string
676 (program screen-locker-program) ;gexp
677 (empty? screen-locker-allows-empty-passwords?)) ;Boolean
679 (define screen-locker-pam-services
681 (($ <screen-locker> name _ empty?)
682 (list (unix-pam-service name
683 #:allow-empty-passwords? empty?)))))
685 (define screen-locker-setuid-programs
686 (compose list screen-locker-program))
688 (define screen-locker-service-type
689 (service-type (name 'screen-locker)
691 (list (service-extension pam-root-service-type
692 screen-locker-pam-services)
693 (service-extension setuid-program-service-type
694 screen-locker-setuid-programs)))))
696 (define* (screen-locker-service package
698 (program (package-name package))
699 #:key allow-empty-passwords?)
700 "Add @var{package}, a package for a screen locker or screen saver whose
701 command is @var{program}, to the set of setuid programs and add a PAM entry
705 (screen-locker-service xlockmore \"xlock\")
708 makes the good ol' XlockMore usable."
709 (service screen-locker-service-type
710 (screen-locker program
711 (file-append package "/bin/" program)
712 allow-empty-passwords?)))
719 (define-record-type* <localed-configuration>
720 localed-configuration make-localed-configuration
721 localed-configuration?
722 (localed localed-configuration-localed
724 (keyboard-layout localed-configuration-keyboard-layout
727 (define (localed-dbus-service config)
728 "Return the 'localed' D-Bus service for @var{config}, a
729 @code{<localed-configuration>} record."
730 (define keyboard-layout
731 (localed-configuration-keyboard-layout config))
733 ;; The primary purpose of 'localed' is to tell GDM what the "current" Xorg
734 ;; keyboard layout is. If 'localed' is missing, or if it's unable to
735 ;; determine the current XKB layout, then GDM forcefully installs its
736 ;; default XKB config (US English). Here we communicate the configured
737 ;; layout through environment variables.
740 (let* ((layout (keyboard-layout-name keyboard-layout))
741 (variant (keyboard-layout-variant keyboard-layout))
742 (model (keyboard-layout-model keyboard-layout))
743 (options (keyboard-layout-options keyboard-layout)))
744 (list (wrapped-dbus-service
745 (localed-configuration-localed config)
746 "libexec/localed/localed"
747 `(("GUIX_XKB_LAYOUT" ,layout)
749 `(("GUIX_XKB_VARIANT" ,variant))
752 `(("GUIX_XKB_MODEL" ,model))
754 ,@(if (null? options)
756 `(("GUIX_XKB_OPTIONS"
757 ,(string-join options ","))))))))
760 (define localed-service-type
761 (let ((package (lambda (config)
762 ;; Don't bother if the user didn't specify any keyboard
764 (if (localed-configuration-keyboard-layout config)
765 (list (localed-configuration-localed config))
767 (service-type (name 'localed)
769 (list (service-extension dbus-root-service-type
770 localed-dbus-service)
771 (service-extension udev-service-type package)
772 (service-extension polkit-service-type package)
774 ;; Add 'localectl' to the profile.
775 (service-extension profile-service-type package)))
777 ;; This service can be extended, typically by the X login
778 ;; manager, to communicate the chosen Xorg keyboard layout.
779 (compose (lambda (extensions)
780 (find keyboard-layout? extensions)))
781 (extend (lambda (config keyboard-layout)
782 (localed-configuration
784 (keyboard-layout keyboard-layout))))
786 "Run the locale daemon, @command{localed}, which can be used
787 to control the system locale and keyboard mapping from user programs such as
788 the GNOME desktop environment.")
789 (default-value (localed-configuration)))))
793 ;;; GNOME Desktop Manager.
796 (define %gdm-accounts
797 (list (user-group (name "gdm") (system? #t))
802 (comment "GNOME Display Manager user")
803 (home-directory "/var/lib/gdm")
804 (shell (file-append shadow "/sbin/nologin")))))
806 (define %gdm-activation
807 ;; Ensure /var/lib/gdm is owned by the "gdm" user. This is normally the
808 ;; case but could be wrong if the "gdm" user was created, then removed, and
809 ;; then recreated under a different UID/GID: <https://bugs.gnu.org/37423>.
810 (with-imported-modules '((guix build utils))
812 (use-modules (guix build utils))
814 (let* ((gdm (getpwnam "gdm"))
815 (uid (passwd:uid gdm))
816 (gid (passwd:gid gdm))
817 (st (stat "/var/lib/gdm" #f)))
818 ;; Recurse into /var/lib/gdm only if it has wrong ownership.
820 (or (not (= uid (stat:uid st)))
821 (not (= gid (stat:gid st)))))
822 (for-each (lambda (file)
823 (chown file uid gid))
824 (find-files "/var/lib/gdm"
825 #:directories? #t)))))))
827 (define dbus-daemon-wrapper
831 (use-modules (srfi srfi-26))
833 (define system-profile
834 "/run/current-system/profile")
837 (and=> (getpw (getuid))
839 (string-append (passwd:dir pw) "/.guix-profile"))))
841 ;; If we are able to find the user's profile, we can add it to
842 ;; the search paths set below. We need to do this so that D-Bus
843 ;; can start services installed by the user. This allows
844 ;; applications that require session D-Bus services (e.g,
845 ;; 'evolution') to work even if those services are only available
846 ;; in the user's profile. See <https://bugs.gnu.org/35267>.
849 (list user-profile system-profile)
850 (list system-profile)))
852 (setenv "XDG_CONFIG_DIRS"
853 (string-join (map (cut string-append <> "/etc/xdg") profiles)
855 (setenv "XDG_DATA_DIRS"
856 (string-join (map (cut string-append <> "/share") profiles)
858 (apply execl (string-append #$dbus "/bin/dbus-daemon")
859 (program-arguments)))))
861 (define-record-type* <gdm-configuration>
862 gdm-configuration make-gdm-configuration
864 (gdm gdm-configuration-gdm (default gdm))
865 (allow-empty-passwords? gdm-configuration-allow-empty-passwords? (default #t))
866 (auto-login? gdm-configuration-auto-login? (default #f))
867 (dbus-daemon gdm-configuration-dbus-daemon (default dbus-daemon-wrapper))
868 (debug? gdm-configuration-debug? (default #f))
869 (default-user gdm-configuration-default-user (default #f))
870 (gnome-shell-assets gdm-configuration-gnome-shell-assets
871 (default (list adwaita-icon-theme font-cantarell)))
872 (xorg-configuration gdm-configuration-xorg
873 (default (xorg-configuration)))
874 (x-session gdm-configuration-x-session
875 (default (xinitrc))))
877 (define (gdm-configuration-file config)
878 (mixed-text-file "gdm-custom.conf"
882 (if (gdm-configuration-auto-login? config)
884 "AutomaticLoginEnable=true\n"
886 (or (gdm-configuration-default-user config)
887 (error "missing default user for auto-login"))
890 "AutomaticLoginEnable=false\n"
891 "#AutomaticLogin=\n"))
892 "#TimedLoginEnable=false\n"
894 "#TimedLoginDelay=0\n"
895 ;; Disable initial system setup inside GDM.
896 ;; Whatever settings are set there should already be
897 ;; taken care of through `guix system'.
899 ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39281>.
900 "InitialSetupEnable=false\n"
901 ;; Enable me once X is working.
902 "WaylandEnable=false\n"
905 "Enable=" (if (gdm-configuration-debug? config)
910 "#DisallowTCP=true\n"
911 "#AllowRemoteAutoLogin=false\n"))
913 (define (gdm-pam-service config)
914 "Return a PAM service for @command{gdm}."
917 (inherit (unix-pam-service "gdm-autologin"
919 (auth (list (pam-entry
920 (control "[success=ok default=1]")
921 (module (file-append (gdm-configuration-gdm config)
922 "/lib/security/pam_gdm.so")))
924 (control "sufficient")
925 (module "pam_permit.so")))))
927 (inherit (unix-pam-service "gdm-launch-environment"))
928 (auth (list (pam-entry
930 (module "pam_permit.so")))))
931 (unix-pam-service "gdm-password"
933 #:allow-empty-passwords?
934 (gdm-configuration-allow-empty-passwords? config))))
936 (define (gdm-shepherd-service config)
937 (list (shepherd-service
938 (documentation "Xorg display server (GDM)")
939 (provision '(xorg-server))
940 (requirement '(dbus-system user-processes host-name udev))
943 (list #$(file-append (gdm-configuration-gdm config)
945 #:environment-variables
948 #$(gdm-configuration-file config))
951 #$(gdm-configuration-dbus-daemon config))
955 (gdm-configuration-xorg config)))
958 #$(gdm-configuration-x-session config))
961 ((lambda (ls) (string-join ls ":"))
963 (string-append path "/share"))
964 ;; XXX: Remove gnome-shell below when GDM
965 ;; can depend on GNOME Shell directly.
967 '#$(gdm-configuration-gnome-shell-assets
969 (stop #~(make-kill-destructor))
972 (define gdm-service-type
973 (handle-xorg-configuration gdm-configuration
974 (service-type (name 'gdm)
976 (list (service-extension shepherd-root-service-type
977 gdm-shepherd-service)
978 (service-extension activation-service-type
979 (const %gdm-activation))
980 (service-extension account-service-type
981 (const %gdm-accounts))
982 (service-extension pam-root-service-type
984 (service-extension profile-service-type
985 gdm-configuration-gnome-shell-assets)
986 (service-extension dbus-root-service-type
988 gdm-configuration-gdm))
989 (service-extension localed-service-type
991 xorg-configuration-keyboard-layout
992 gdm-configuration-xorg))))
993 (default-value (gdm-configuration))
995 "Run the GNOME Desktop Manager (GDM), a program that allows
996 you to log in in a graphical session, whether or not you use GNOME."))))
998 (define-deprecated (gdm-service #:key (gdm gdm)
999 (allow-empty-passwords? #t)
1000 (x-server (xorg-wrapper)))
1002 "Return a service that spawns the GDM graphical login manager, which in turn
1003 starts the X display server with @var{X}, a command as returned by
1004 @code{xorg-wrapper}.
1008 GDM automatically looks for session types described by the @file{.desktop}
1009 files in @file{/run/current-system/profile/share/xsessions} and allows users
1010 to choose a session from the log-in screen using @kbd{F1}. Packages such as
1011 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
1012 adding them to the system-wide set of packages automatically makes them
1013 available at the log-in screen.
1015 In addition, @file{~/.xsession} files are honored. When available,
1016 @file{~/.xsession} must be an executable that starts a window manager
1017 and/or other X clients.
1019 When @var{allow-empty-passwords?} is true, allow logins with an empty
1021 (service gdm-service-type
1024 (allow-empty-passwords? allow-empty-passwords?))))
1026 (define* (set-xorg-configuration config
1028 (login-manager-service-type
1030 "Tell the log-in manager (of type @var{login-manager-service-type}) to use
1031 @var{config}, an <xorg-configuration> record."
1032 (simple-service 'set-xorg-configuration
1033 login-manager-service-type
1036 ;;; xorg.scm ends here