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>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu services xorg)
26 #:use-module (gnu artwork)
27 #:use-module (gnu services)
28 #:use-module (gnu services shepherd)
29 #:use-module (gnu system pam)
30 #:use-module (gnu system keyboard)
31 #:use-module (gnu services base)
32 #:use-module (gnu services dbus)
33 #:use-module ((gnu packages base) #:select (canonical-package))
34 #:use-module (gnu packages guile)
35 #:use-module (gnu packages xorg)
36 #:use-module (gnu packages fonts)
37 #:use-module (gnu packages gl)
38 #:use-module (gnu packages glib)
39 #:use-module (gnu packages display-managers)
40 #:use-module (gnu packages freedesktop)
41 #:use-module (gnu packages gnustep)
42 #:use-module (gnu packages gnome)
43 #:use-module (gnu packages admin)
44 #:use-module (gnu packages bash)
45 #:use-module (gnu system shadow)
46 #:use-module (guix gexp)
47 #:use-module (guix store)
48 #:use-module (guix packages)
49 #:use-module (guix derivations)
50 #:use-module (guix records)
51 #:use-module (guix deprecation)
52 #:use-module (srfi srfi-1)
53 #:use-module (srfi srfi-9)
54 #:use-module (srfi srfi-26)
55 #:use-module (ice-9 match)
56 #:export (xorg-configuration
58 xorg-configuration-modules
59 xorg-configuration-fonts
60 xorg-configuration-drivers
61 xorg-configuration-resolutions
62 xorg-configuration-extra-config
63 xorg-configuration-server
64 xorg-configuration-server-arguments
73 %default-slim-theme-name
77 slim-configuration-slim
78 slim-configuration-allow-empty-passwords?
79 slim-configuration-auto-login?
80 slim-configuration-default-user
81 slim-configuration-theme
82 slim-configuration-theme-name
83 slim-configuration-xauth
84 slim-configuration-shepherd
85 slim-configuration-auto-login-session
86 slim-configuration-xorg
87 slim-configuration-display
89 slim-configuration-sessreg
96 screen-locker-service-type
100 localed-configuration?
106 set-xorg-configuration))
110 ;;; Services that relate to the X Window System.
114 (define %default-xorg-modules
115 ;; Default list of modules loaded by the server. When multiple drivers
116 ;; match, the first one in the list is loaded.
117 (list xf86-video-vesa
128 ;; Libinput is the new thing and is recommended over evdev/synaptics:
129 ;; <http://who-t.blogspot.fr/2015/01/xf86-input-libinput-compatibility-with.html>.
135 xf86-input-synaptics))
137 (define %default-xorg-fonts
138 ;; Default list of fonts available to the X server.
139 (list (file-append font-alias "/share/fonts/X11/75dpi")
140 (file-append font-alias "/share/fonts/X11/100dpi")
141 (file-append font-alias "/share/fonts/X11/misc")
142 (file-append font-alias "/share/fonts/X11/cyrillic")
143 (file-append font-misc-misc ;default fonts for xterm
144 "/share/fonts/X11/misc")
145 (file-append font-adobe75dpi "/share/fonts/X11/75dpi")))
147 (define %default-xorg-server-arguments
148 ;; Default command-line arguments for X.
149 '("-nolisten" "tcp"))
151 ;; Configuration of an Xorg server.
152 (define-record-type* <xorg-configuration>
153 xorg-configuration make-xorg-configuration
155 (modules xorg-configuration-modules ;list of packages
156 ; filter out modules not supported on current system
159 (member (%current-system)
160 (package-supported-systems p)))
161 %default-xorg-modules)))
162 (fonts xorg-configuration-fonts ;list of packges
163 (default %default-xorg-fonts))
164 (drivers xorg-configuration-drivers ;list of strings
166 (resolutions xorg-configuration-resolutions ;list of tuples
168 (keyboard-layout xorg-configuration-keyboard-layout ;#f | <keyboard-layout>
170 (extra-config xorg-configuration-extra-config ;list of strings
172 (server xorg-configuration-server ;package
173 (default xorg-server))
174 (server-arguments xorg-configuration-server-arguments ;list of strings
175 (default %default-xorg-server-arguments)))
177 (define (xorg-configuration->file config)
178 "Compute an Xorg configuration file corresponding to CONFIG, an
179 <xorg-configuration> record."
181 ;; 'xorg-server' provides 'fbdevhw.so' etc.
182 (append (xorg-configuration-modules config)
187 (use-modules (ice-9 match)
191 (call-with-output-file #$output
194 '#$(xorg-configuration-drivers config))
196 (define (device-section driver)
199 Identifier \"device-" driver "\"
200 Driver \"" driver "\"
203 (define (screen-section driver resolutions)
206 Identifier \"screen-" driver "\"
207 Device \"device-" driver "\"
208 SubSection \"Display\"
210 (string-join (map (match-lambda
212 (string-append "\"" (number->string x)
213 "x" (number->string y) "\"")))
218 (define (input-class-section layout variant model options)
220 Section \"InputClass\"
221 Identifier \"evdev keyboard catchall\"
222 MatchIsKeyboard \"on\"
223 Option \"XkbLayout\" " (object->string layout)
225 (string-append " Option \"XkbVariant\" \""
229 (string-append " Option \"XkbModel\" \""
236 (string-append " Option \"XkbOptions\" \""
237 (string-join options ",") "\""))) "
239 MatchDevicePath \"/dev/input/event*\"
243 (define (expand modules)
244 ;; Append to MODULES the relevant /lib/xorg/modules
246 (append-map (lambda (module)
247 (filter-map (lambda (directory)
248 (let ((full (string-append module
250 (and (file-exists? full)
252 '("/lib/xorg/modules/drivers"
253 "/lib/xorg/modules/input"
254 "/lib/xorg/modules/multimedia"
255 "/lib/xorg/modules/extensions")))
258 (display "Section \"Files\"\n" port)
259 (for-each (lambda (font)
260 (format port " FontPath \"~a\"~%" font))
261 '#$(xorg-configuration-fonts config))
262 (for-each (lambda (module)
264 " ModulePath \"~a\"~%"
266 (append (expand '#$all-modules)
268 ;; For fbdevhw.so and so on.
269 (list #$(file-append xorg-server
270 "/lib/xorg/modules"))))
271 (display "EndSection\n" port)
273 Section \"ServerFlags\"
274 Option \"AllowMouseOpenFail\" \"on\"
277 (display (string-join (map device-section drivers) "\n")
280 (display (string-join
281 (map (cut screen-section <>
282 '#$(xorg-configuration-resolutions config))
288 (let ((layout #$(and=> (xorg-configuration-keyboard-layout config)
289 keyboard-layout-name))
290 (variant #$(and=> (xorg-configuration-keyboard-layout config)
291 keyboard-layout-variant))
292 (model #$(and=> (xorg-configuration-keyboard-layout config)
293 keyboard-layout-model))
294 (options '#$(and=> (xorg-configuration-keyboard-layout config)
295 keyboard-layout-options)))
297 (display (input-class-section layout variant model options)
301 (for-each (lambda (config)
302 (display config port))
303 '#$(xorg-configuration-extra-config config))))))
305 (computed-file "xserver.conf" build))
307 (define (xorg-configuration-directory modules)
308 "Return a directory that contains the @code{.conf} files for X.org that
309 includes the @code{share/X11/xorg.conf.d} directories of each package listed
311 (with-imported-modules '((guix build utils))
312 (computed-file "xorg.conf.d"
314 (use-modules (guix build utils)
318 (append-map (lambda (module)
319 (find-files (string-append
321 "/share/X11/xorg.conf.d")
326 (for-each (lambda (file)
328 (string-append #$output "/"
333 (define* (xorg-wrapper #:optional (config (xorg-configuration)))
334 "Return a derivation that builds a script to start the X server with the
335 given @var{config}. The resulting script should be used in place of
338 ;; Write a small wrapper around the X server.
340 (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
341 (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
343 (let ((X (string-append #$(xorg-configuration-server config) "/bin/X")))
345 "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
346 "-config" #$(xorg-configuration->file config)
347 "-configdir" #$(xorg-configuration-directory
348 (xorg-configuration-modules config))
349 (cdr (command-line))))))
351 (program-file "X-wrapper" exp))
353 (define* (xorg-start-command #:optional (config (xorg-configuration)))
354 "Return a @code{startx} script in which the modules, fonts, etc. specified
355 in @var{config}, are available. The result should be used in place of
358 (xorg-wrapper config))
361 ;; Write a small wrapper around the X server.
362 #~(apply execl #$X #$X ;; Second #$X is for argv[0].
363 "-logverbose" "-verbose" "-terminate"
364 #$@(xorg-configuration-server-arguments config)
365 (cdr (command-line))))
367 (program-file "startx" exp))
369 (define* (xinitrc #:key fallback-session)
370 "Return a system-wide xinitrc script that starts the specified X session,
371 which should be passed to this script as the first argument. If not, the
372 @var{fallback-session} will be used or, if @var{fallback-session} is false, a
373 desktop session from the system or user profile will be used."
376 (use-modules (ice-9 match)
383 (define (close-all-fdes)
384 ;; Close all the open file descriptors except 0 to 2.
386 (when (< fd 4096) ;FIXME: use sysconf + _SC_OPEN_MAX
387 (false-if-exception (close-fdes fd))
390 (define (exec-from-login-shell command . args)
391 ;; Run COMMAND from a login shell so that it gets to see the same
392 ;; environment variables that one gets when logging in on a tty, for
394 (let* ((pw (getpw (getuid)))
395 (shell (passwd:shell pw)))
396 ;; Close any open file descriptors. This is all the more
397 ;; important that SLiM itself exec's us directly without closing
398 ;; its own file descriptors!
401 ;; The '--login' option is supported at least by Bash and zsh.
402 (execl shell shell "--login" "-c"
403 (string-join (cons command args)))))
405 (define system-profile
406 "/run/current-system/profile")
409 (and=> (getpw (getuid))
411 (string-append (passwd:dir pw) "/.guix-profile"))))
413 (define (xsession-command desktop-file)
414 ;; Read from DESKTOP-FILE its X session command and return it as a
417 (make-regexp "^[[:blank:]]*Exec=(.*)$"))
419 (call-with-input-file desktop-file
422 (match (read-line port)
424 ((= (cut regexp-exec exec-regexp <>) result)
426 (string-tokenize (match:substring result 1))
429 (define (find-session profile)
430 ;; Return an X session command from PROFILE or #f if none was found.
431 (let ((directory (string-append profile "/share/xsessions")))
432 (match (scandir directory
433 (cut string-suffix? ".desktop" <>))
437 (any xsession-command
438 (map (cut string-append directory "/" <>)
441 (let* ((home (getenv "HOME"))
442 (xsession-file (string-append home "/.xsession"))
443 (session (match (command-line)
445 #$(if fallback-session
446 #~(list #$fallback-session)
450 (if (file-exists? xsession-file)
451 ;; Run ~/.xsession when it exists.
452 (apply exec-from-login-shell xsession-file
454 ;; Otherwise, start the specified session or a fallback.
455 (apply exec-from-login-shell
457 (find-session user-profile)
458 (find-session system-profile)))))))
460 (program-file "xinitrc" builder))
464 ;;; SLiM log-in manager.
467 (define %default-slim-theme
468 ;; Theme based on work by Felipe López.
469 (file-append %artwork-repository "/slim"))
471 (define %default-slim-theme-name
472 ;; This must be the name of the sub-directory in %DEFAULT-SLIM-THEME that
473 ;; contains the actual theme files.
476 (define-record-type* <slim-configuration>
477 slim-configuration make-slim-configuration
479 (slim slim-configuration-slim
481 (allow-empty-passwords? slim-configuration-allow-empty-passwords?
483 (auto-login? slim-configuration-auto-login?
485 (default-user slim-configuration-default-user
487 (theme slim-configuration-theme
488 (default %default-slim-theme))
489 (theme-name slim-configuration-theme-name
490 (default %default-slim-theme-name))
491 (xauth slim-configuration-xauth
493 (shepherd slim-configuration-shepherd
495 (auto-login-session slim-configuration-auto-login-session
497 (xorg-configuration slim-configuration-xorg
498 (default (xorg-configuration)))
499 (display slim-configuration-display
501 (vt slim-configuration-vt
503 (sessreg slim-configuration-sessreg
506 (define (slim-pam-service config)
507 "Return a PAM service for @command{slim}."
508 (list (unix-pam-service
511 #:allow-empty-passwords?
512 (slim-configuration-allow-empty-passwords? config))))
514 (define (slim-shepherd-service config)
515 (let* ((xinitrc (xinitrc #:fallback-session
516 (slim-configuration-auto-login-session config)))
517 (xauth (slim-configuration-xauth config))
518 (startx (xorg-start-command (slim-configuration-xorg config)))
519 (display (slim-configuration-display config))
520 (vt (slim-configuration-vt config))
521 (shepherd (slim-configuration-shepherd config))
522 (theme-name (slim-configuration-theme-name config))
523 (sessreg (slim-configuration-sessreg config))
524 (lockfile (string-append "/var/run/slim-" vt ".lock")))
526 (mixed-text-file "slim.cfg" "
527 default_path /run/current-system/profile/bin
528 default_xserver " startx "
529 display_name " display "
530 xserver_arguments " vt "
531 xauth_path " xauth "/bin/xauth
532 authfile /var/run/slim-" vt ".auth
533 lockfile " lockfile "
534 logfile /var/log/slim-" vt ".log
536 # The login command. '%session' is replaced by the chosen session name, one
537 # of the names specified in the 'sessions' setting: 'wmaker', 'xfce', etc.
538 login_cmd exec " xinitrc " %session
539 sessiondir /run/current-system/profile/share/xsessions
540 session_msg session (F1 to change):
541 sessionstart_cmd " sessreg "/bin/sessreg -a -l $DISPLAY %user
542 sessionstop_cmd " sessreg "/bin/sessreg -d -l $DISPLAY %user
544 halt_cmd " shepherd "/sbin/halt
545 reboot_cmd " shepherd "/sbin/reboot\n"
546 (if (slim-configuration-auto-login? config)
547 (string-append "auto_login yes\ndefault_user "
548 (slim-configuration-default-user config) "\n")
551 (string-append "current_theme " theme-name "\n")
555 (slim-configuration-theme config))
557 (list (shepherd-service
558 (documentation "Xorg display server")
560 ;; For compatibility, also provide 'xorg-server'.
561 (if (string=? vt "vt7")
565 (list (symbol-append 'xorg-server-
566 (string->symbol vt)))))
567 (requirement '(user-processes host-name udev))
570 ;; A stale lock file can prevent SLiM from starting, so remove it to
571 ;; be on the safe side.
572 (false-if-exception (delete-file lockfile))
575 (list (string-append #$(slim-configuration-slim config)
578 #:environment-variables
579 (list (string-append "SLIM_CFGFILE=" #$slim.cfg)
581 (list #~(string-append "SLIM_THEMESDIR=" #$theme))
583 (stop #~(make-kill-destructor))
586 (define slim-service-type
587 (service-type (name 'slim)
589 (list (service-extension shepherd-root-service-type
590 slim-shepherd-service)
591 (service-extension pam-root-service-type
594 ;; Unconditionally add xterm to the system profile, to
595 ;; avoid bad surprises.
596 (service-extension profile-service-type
597 (const (list xterm)))))
598 (default-value (slim-configuration))))
600 (define-deprecated (slim-service #:key (slim slim)
601 (allow-empty-passwords? #t) auto-login?
603 (theme %default-slim-theme)
604 (theme-name %default-slim-theme-name)
605 (xauth xauth) (shepherd shepherd)
606 (auto-login-session #f)
607 (startx (xorg-start-command)))
609 "Return a service that spawns the SLiM graphical login manager, which in
610 turn starts the X display server with @var{startx}, a command as returned by
611 @code{xorg-start-command}.
615 SLiM automatically looks for session types described by the @file{.desktop}
616 files in @file{/run/current-system/profile/share/xsessions} and allows users
617 to choose a session from the log-in screen using @kbd{F1}. Packages such as
618 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
619 adding them to the system-wide set of packages automatically makes them
620 available at the log-in screen.
622 In addition, @file{~/.xsession} files are honored. When available,
623 @file{~/.xsession} must be an executable that starts a window manager
624 and/or other X clients.
626 When @var{allow-empty-passwords?} is true, allow logins with an empty
627 password. When @var{auto-login?} is true, log in automatically as
628 @var{default-user} with @var{auto-login-session}.
630 If @var{theme} is @code{#f}, the use the default log-in theme; otherwise
631 @var{theme} must be a gexp denoting the name of a directory containing the
632 theme to use. In that case, @var{theme-name} specifies the name of the
634 (service slim-service-type
637 (allow-empty-passwords? allow-empty-passwords?)
638 (auto-login? auto-login?) (default-user default-user)
639 (theme theme) (theme-name theme-name)
640 (xauth xauth) (shepherd shepherd)
641 (auto-login-session auto-login-session))))
645 ;;; Screen lockers & co.
648 (define-record-type <screen-locker>
649 (screen-locker name program empty?)
651 (name screen-locker-name) ;string
652 (program screen-locker-program) ;gexp
653 (empty? screen-locker-allows-empty-passwords?)) ;Boolean
655 (define screen-locker-pam-services
657 (($ <screen-locker> name _ empty?)
658 (list (unix-pam-service name
659 #:allow-empty-passwords? empty?)))))
661 (define screen-locker-setuid-programs
662 (compose list screen-locker-program))
664 (define screen-locker-service-type
665 (service-type (name 'screen-locker)
667 (list (service-extension pam-root-service-type
668 screen-locker-pam-services)
669 (service-extension setuid-program-service-type
670 screen-locker-setuid-programs)))))
672 (define* (screen-locker-service package
674 (program (package-name package))
675 #:key allow-empty-passwords?)
676 "Add @var{package}, a package for a screen locker or screen saver whose
677 command is @var{program}, to the set of setuid programs and add a PAM entry
681 (screen-locker-service xlockmore \"xlock\")
684 makes the good ol' XlockMore usable."
685 (service screen-locker-service-type
686 (screen-locker program
687 (file-append package "/bin/" program)
688 allow-empty-passwords?)))
695 (define-record-type* <localed-configuration>
696 localed-configuration make-localed-configuration
697 localed-configuration?
698 (localed localed-configuration-localed
700 (keyboard-layout localed-configuration-keyboard-layout
703 (define (localed-dbus-service config)
704 "Return the 'localed' D-Bus service for @var{config}, a
705 @code{<localed-configuration>} record."
706 (define keyboard-layout
707 (localed-configuration-keyboard-layout config))
709 ;; The primary purpose of 'localed' is to tell GDM what the "current" Xorg
710 ;; keyboard layout is. If 'localed' is missing, or if it's unable to
711 ;; determine the current XKB layout, then GDM forcefully installs its
712 ;; default XKB config (US English). Here we communicate the configured
713 ;; layout through environment variables.
716 (let* ((layout (keyboard-layout-name keyboard-layout))
717 (variant (keyboard-layout-variant keyboard-layout))
718 (model (keyboard-layout-model keyboard-layout))
719 (options (keyboard-layout-options keyboard-layout)))
720 (list (wrapped-dbus-service
721 (localed-configuration-localed config)
722 "libexec/localed/localed"
723 `(("GUIX_XKB_LAYOUT" ,layout)
725 `(("GUIX_XKB_VARIANT" ,variant))
728 `(("GUIX_XKB_MODEL" ,model))
730 ,@(if (null? options)
732 `(("GUIX_XKB_OPTIONS"
733 ,(string-join options ","))))))))
736 (define localed-service-type
737 (let ((package (lambda (config)
738 ;; Don't bother if the user didn't specify any keyboard
740 (if (localed-configuration-keyboard-layout config)
741 (list (localed-configuration-localed config))
743 (service-type (name 'localed)
745 (list (service-extension dbus-root-service-type
746 localed-dbus-service)
747 (service-extension udev-service-type package)
748 (service-extension polkit-service-type package)
750 ;; Add 'localectl' to the profile.
751 (service-extension profile-service-type package)))
753 ;; This service can be extended, typically by the X login
754 ;; manager, to communicate the chosen Xorg keyboard layout.
755 (compose (lambda (extensions)
756 (find keyboard-layout? extensions)))
757 (extend (lambda (config keyboard-layout)
758 (localed-configuration
760 (keyboard-layout keyboard-layout))))
762 "Run the locale daemon, @command{localed}, which can be used
763 to control the system locale and keyboard mapping from user programs such as
764 the GNOME desktop environment.")
765 (default-value (localed-configuration)))))
769 ;;; GNOME Desktop Manager.
772 (define %gdm-accounts
773 (list (user-group (name "gdm") (system? #t))
778 (comment "GNOME Display Manager user")
779 (home-directory "/var/lib/gdm")
780 (shell (file-append shadow "/sbin/nologin")))))
782 (define %gdm-activation
783 ;; Ensure /var/lib/gdm is owned by the "gdm" user. This is normally the
784 ;; case but could be wrong if the "gdm" user was created, then removed, and
785 ;; then recreated under a different UID/GID: <https://bugs.gnu.org/37423>.
786 (with-imported-modules '((guix build utils))
788 (use-modules (guix build utils))
790 (let* ((gdm (getpwnam "gdm"))
791 (uid (passwd:uid gdm))
792 (gid (passwd:gid gdm))
793 (st (stat "/var/lib/gdm" #f)))
794 ;; Recurse into /var/lib/gdm only if it has wrong ownership.
796 (or (not (= uid (stat:uid st)))
797 (not (= gid (stat:gid st)))))
798 (for-each (lambda (file)
799 (chown file uid gid))
800 (find-files "/var/lib/gdm"
801 #:directories? #t)))))))
803 (define dbus-daemon-wrapper
807 (use-modules (srfi srfi-26))
809 (define system-profile
810 "/run/current-system/profile")
813 (and=> (getpw (getuid))
815 (string-append (passwd:dir pw) "/.guix-profile"))))
817 ;; If we are able to find the user's profile, we can add it to
818 ;; the search paths set below. We need to do this so that D-Bus
819 ;; can start services installed by the user. This allows
820 ;; applications that require session D-Bus services (e.g,
821 ;; 'evolution') to work even if those services are only available
822 ;; in the user's profile. See <https://bugs.gnu.org/35267>.
825 (list user-profile system-profile)
826 (list system-profile)))
828 (setenv "XDG_CONFIG_DIRS"
829 (string-join (map (cut string-append <> "/etc/xdg") profiles)
831 (setenv "XDG_DATA_DIRS"
832 (string-join (map (cut string-append <> "/share") profiles)
834 (apply execl (string-append #$dbus "/bin/dbus-daemon")
835 (program-arguments)))))
837 (define-record-type* <gdm-configuration>
838 gdm-configuration make-gdm-configuration
840 (gdm gdm-configuration-gdm (default gdm))
841 (allow-empty-passwords? gdm-configuration-allow-empty-passwords? (default #t))
842 (auto-login? gdm-configuration-auto-login? (default #f))
843 (dbus-daemon gdm-configuration-dbus-daemon (default dbus-daemon-wrapper))
844 (debug? gdm-configuration-debug? (default #f))
845 (default-user gdm-configuration-default-user (default #f))
846 (gnome-shell-assets gdm-configuration-gnome-shell-assets
847 (default (list adwaita-icon-theme font-cantarell)))
848 (xorg-configuration gdm-configuration-xorg
849 (default (xorg-configuration)))
850 (x-session gdm-configuration-x-session
851 (default (xinitrc))))
853 (define (gdm-configuration-file config)
854 (mixed-text-file "gdm-custom.conf"
858 (if (gdm-configuration-auto-login? config)
860 "AutomaticLoginEnable=true\n"
862 (or (gdm-configuration-default-user config)
863 (error "missing default user for auto-login"))
866 "AutomaticLoginEnable=false\n"
867 "#AutomaticLogin=\n"))
868 "#TimedLoginEnable=false\n"
870 "#TimedLoginDelay=0\n"
871 ;; Disable initial system setup inside GDM.
872 ;; Whatever settings are set there should already be
873 ;; taken care of through `guix system'.
875 ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39281>.
876 "InitialSetupEnable=false\n"
877 ;; Enable me once X is working.
878 "WaylandEnable=false\n"
881 "Enable=" (if (gdm-configuration-debug? config)
886 "#DisallowTCP=true\n"
887 "#AllowRemoteAutoLogin=false\n"))
889 (define (gdm-pam-service config)
890 "Return a PAM service for @command{gdm}."
893 (inherit (unix-pam-service "gdm-autologin"
895 (auth (list (pam-entry
896 (control "[success=ok default=1]")
897 (module (file-append (gdm-configuration-gdm config)
898 "/lib/security/pam_gdm.so")))
900 (control "sufficient")
901 (module "pam_permit.so")))))
903 (inherit (unix-pam-service "gdm-launch-environment"))
904 (auth (list (pam-entry
906 (module "pam_permit.so")))))
907 (unix-pam-service "gdm-password"
909 #:allow-empty-passwords?
910 (gdm-configuration-allow-empty-passwords? config))))
912 (define (gdm-shepherd-service config)
913 (list (shepherd-service
914 (documentation "Xorg display server (GDM)")
915 (provision '(xorg-server))
916 (requirement '(dbus-system user-processes host-name udev))
919 (list #$(file-append (gdm-configuration-gdm config)
921 #:environment-variables
924 #$(gdm-configuration-file config))
927 #$(gdm-configuration-dbus-daemon config))
931 (gdm-configuration-xorg config)))
934 #$(gdm-configuration-x-session config))
937 ((lambda (ls) (string-join ls ":"))
939 (string-append path "/share"))
940 ;; XXX: Remove gnome-shell below when GDM
941 ;; can depend on GNOME Shell directly.
943 '#$(gdm-configuration-gnome-shell-assets
945 (stop #~(make-kill-destructor))
948 (define gdm-service-type
949 (service-type (name 'gdm)
951 (list (service-extension shepherd-root-service-type
952 gdm-shepherd-service)
953 (service-extension activation-service-type
954 (const %gdm-activation))
955 (service-extension account-service-type
956 (const %gdm-accounts))
957 (service-extension pam-root-service-type
959 (service-extension profile-service-type
960 gdm-configuration-gnome-shell-assets)
961 (service-extension dbus-root-service-type
963 gdm-configuration-gdm))
964 (service-extension localed-service-type
966 xorg-configuration-keyboard-layout
967 gdm-configuration-xorg))))
969 ;; For convenience, this service can be extended with an
970 ;; <xorg-configuration> record. Take the first one that
972 (compose (lambda (extensions)
975 ((config . _) config))))
976 (extend (lambda (config xorg-configuration)
977 (if xorg-configuration
980 (xorg-configuration xorg-configuration))
983 (default-value (gdm-configuration))
985 "Run the GNOME Desktop Manager (GDM), a program that allows
986 you to log in in a graphical session, whether or not you use GNOME.")))
988 (define-deprecated (gdm-service #:key (gdm gdm)
989 (allow-empty-passwords? #t)
990 (x-server (xorg-wrapper)))
992 "Return a service that spawns the GDM graphical login manager, which in turn
993 starts the X display server with @var{X}, a command as returned by
998 GDM automatically looks for session types described by the @file{.desktop}
999 files in @file{/run/current-system/profile/share/xsessions} and allows users
1000 to choose a session from the log-in screen using @kbd{F1}. Packages such as
1001 @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
1002 adding them to the system-wide set of packages automatically makes them
1003 available at the log-in screen.
1005 In addition, @file{~/.xsession} files are honored. When available,
1006 @file{~/.xsession} must be an executable that starts a window manager
1007 and/or other X clients.
1009 When @var{allow-empty-passwords?} is true, allow logins with an empty
1011 (service gdm-service-type
1014 (allow-empty-passwords? allow-empty-passwords?))))
1016 (define* (set-xorg-configuration config
1018 (login-manager-service-type
1020 "Tell the log-in manager (of type @var{login-manager-service-type}) to use
1021 @var{config}, an <xorg-configuration> record."
1022 (simple-service 'set-xorg-configuration
1023 login-manager-service-type
1026 ;;; xorg.scm ends here