Commit | Line | Data |
---|---|---|
db4fdc04 | 1 | ;;; GNU Guix --- Functional package management for GNU |
92753a8b | 2 | ;;; Copyright © 2017 Andy Wingo <wingo@igalia.com> |
dd0804c6 | 3 | ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org> |
4bd43bbe | 4 | ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com> |
e57c2adb | 5 | ;;; Copyright © 2018, 2019 Timothy Sample <samplet@ngyro.com> |
24f11b06 | 6 | ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> |
bab7a495 | 7 | ;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de> |
779d96c9 | 8 | ;;; Copyright © 2020 shtwzrd <shtwzrd@protonmail.com> |
50be0da7 | 9 | ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> |
d8258177 | 10 | ;;; Copyright © 2020 Alex Griffin <a@ajgrf.com> |
a85ec0bf | 11 | ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> |
b948ab8b | 12 | ;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> |
5c3f0c3e | 13 | ;;; Copyright © 2021 Josselin Poiret <josselin.poiret@protonmail.ch> |
79260c86 | 14 | ;;; Copyright © 2022 Chris Marusich <cmmarusich@gmail.com> |
db4fdc04 LC |
15 | ;;; |
16 | ;;; This file is part of GNU Guix. | |
17 | ;;; | |
18 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
19 | ;;; under the terms of the GNU General Public License as published by | |
20 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
21 | ;;; your option) any later version. | |
22 | ;;; | |
23 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
24 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 | ;;; GNU General Public License for more details. | |
27 | ;;; | |
28 | ;;; You should have received a copy of the GNU General Public License | |
29 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
30 | ||
31 | (define-module (gnu services xorg) | |
79260c86 | 32 | #:autoload (gnu services sddm) (sddm-service-type) |
84dfb458 | 33 | #:use-module (gnu artwork) |
db4fdc04 | 34 | #:use-module (gnu services) |
0190c1c0 | 35 | #:use-module (gnu services shepherd) |
6e828634 | 36 | #:use-module (gnu system pam) |
a85ec0bf | 37 | #:use-module (gnu system setuid) |
598757e0 | 38 | #:use-module (gnu system keyboard) |
607fcc75 | 39 | #:use-module (gnu services base) |
6e99c01b | 40 | #:use-module (gnu services dbus) |
dfc8ccbf | 41 | #:use-module (gnu packages base) |
bdb36958 | 42 | #:use-module (gnu packages guile) |
db4fdc04 | 43 | #:use-module (gnu packages xorg) |
7e614198 | 44 | #:use-module (gnu packages fonts) |
db4fdc04 | 45 | #:use-module (gnu packages gl) |
1f564c15 | 46 | #:use-module (gnu packages glib) |
5fd66a37 | 47 | #:use-module (gnu packages display-managers) |
607fcc75 | 48 | #:use-module (gnu packages freedesktop) |
9e4eddb4 | 49 | #:use-module (gnu packages gnustep) |
6e99c01b | 50 | #:use-module (gnu packages gnome) |
db4fdc04 LC |
51 | #:use-module (gnu packages admin) |
52 | #:use-module (gnu packages bash) | |
6e99c01b | 53 | #:use-module (gnu system shadow) |
c3fd310d | 54 | #:use-module (guix build-system glib-or-gtk) |
e429325d | 55 | #:use-module (guix build-system trivial) |
b5f4e686 | 56 | #:use-module (guix gexp) |
e87f0591 | 57 | #:use-module (guix store) |
6726282b | 58 | #:use-module (guix packages) |
db4fdc04 | 59 | #:use-module (guix derivations) |
ffc3a02b | 60 | #:use-module (guix records) |
65a67bf7 | 61 | #:use-module (guix deprecation) |
dc2b9010 | 62 | #:use-module (guix utils) |
d2e59637 | 63 | #:use-module (srfi srfi-1) |
6726282b | 64 | #:use-module (srfi srfi-9) |
d2e59637 LC |
65 | #:use-module (srfi srfi-26) |
66 | #:use-module (ice-9 match) | |
b2e56451 LC |
67 | #:export (xorg-configuration |
68 | xorg-configuration? | |
69 | xorg-configuration-modules | |
70 | xorg-configuration-fonts | |
71 | xorg-configuration-drivers | |
72 | xorg-configuration-resolutions | |
73 | xorg-configuration-extra-config | |
74 | xorg-configuration-server | |
75 | xorg-configuration-server-arguments | |
76 | ||
79fd74fa | 77 | %default-xorg-modules |
d344f5a5 | 78 | %default-xorg-fonts |
fe0826d5 VH |
79 | %default-xorg-server-arguments |
80 | ||
92753a8b | 81 | xorg-wrapper |
d1cdd7ba | 82 | xorg-start-command |
f2901d82 | 83 | xinitrc |
e429325d | 84 | xorg-server-service-type |
f2901d82 | 85 | |
0ecc3bf3 LC |
86 | %default-slim-theme |
87 | %default-slim-theme-name | |
b37f86d7 | 88 | |
4b7513e0 | 89 | slim-configuration |
b37f86d7 LC |
90 | slim-configuration? |
91 | slim-configuration-slim | |
92 | slim-configuration-allow-empty-passwords? | |
93 | slim-configuration-auto-login? | |
94 | slim-configuration-default-user | |
95 | slim-configuration-theme | |
96 | slim-configuration-theme-name | |
97 | slim-configuration-xauth | |
98 | slim-configuration-shepherd | |
99 | slim-configuration-auto-login-session | |
bab7a495 | 100 | slim-configuration-xorg |
61569171 DNB |
101 | slim-configuration-display |
102 | slim-configuration-vt | |
bab7a495 | 103 | slim-configuration-sessreg |
b37f86d7 | 104 | |
4b7513e0 | 105 | slim-service-type |
6726282b | 106 | |
24e96431 TČ |
107 | screen-locker |
108 | screen-locker? | |
6726282b | 109 | screen-locker-service-type |
6e99c01b AW |
110 | screen-locker-service |
111 | ||
607fcc75 LC |
112 | localed-configuration |
113 | localed-configuration? | |
114 | localed-service-type | |
115 | ||
6e99c01b AW |
116 | gdm-configuration |
117 | gdm-service-type | |
50be0da7 JK |
118 | |
119 | handle-xorg-configuration | |
305a732a | 120 | set-xorg-configuration)) |
db4fdc04 LC |
121 | |
122 | ;;; Commentary: | |
123 | ;;; | |
124 | ;;; Services that relate to the X Window System. | |
125 | ;;; | |
126 | ;;; Code: | |
127 | ||
d344f5a5 | 128 | (define %default-xorg-modules |
fd96f94f PN |
129 | ;; Default list of modules loaded by the server. When multiple drivers |
130 | ;; match, the first one in the list is loaded. | |
d344f5a5 LC |
131 | (list xf86-video-vesa |
132 | xf86-video-fbdev | |
fd96f94f | 133 | xf86-video-amdgpu |
d344f5a5 LC |
134 | xf86-video-ati |
135 | xf86-video-cirrus | |
136 | xf86-video-intel | |
137 | xf86-video-mach64 | |
138 | xf86-video-nouveau | |
139 | xf86-video-nv | |
140 | xf86-video-sis | |
141 | ||
142 | ;; Libinput is the new thing and is recommended over evdev/synaptics: | |
143 | ;; <http://who-t.blogspot.fr/2015/01/xf86-input-libinput-compatibility-with.html>. | |
144 | xf86-input-libinput | |
145 | ||
146 | xf86-input-evdev | |
147 | xf86-input-keyboard | |
2e55a4c6 | 148 | xf86-input-mouse)) |
d344f5a5 LC |
149 | |
150 | (define %default-xorg-fonts | |
151 | ;; Default list of fonts available to the X server. | |
152 | (list (file-append font-alias "/share/fonts/X11/75dpi") | |
153 | (file-append font-alias "/share/fonts/X11/100dpi") | |
154 | (file-append font-alias "/share/fonts/X11/misc") | |
155 | (file-append font-alias "/share/fonts/X11/cyrillic") | |
4afc903a LC |
156 | (file-append font-misc-misc ;default fonts for xterm |
157 | "/share/fonts/X11/misc") | |
d344f5a5 LC |
158 | (file-append font-adobe75dpi "/share/fonts/X11/75dpi"))) |
159 | ||
b2e56451 LC |
160 | (define %default-xorg-server-arguments |
161 | ;; Default command-line arguments for X. | |
162 | '("-nolisten" "tcp")) | |
163 | ||
164 | ;; Configuration of an Xorg server. | |
165 | (define-record-type* <xorg-configuration> | |
166 | xorg-configuration make-xorg-configuration | |
167 | xorg-configuration? | |
892f1b72 | 168 | (modules xorg-configuration-modules ;list of file-like |
f91ae942 | 169 | (thunked) |
779d96c9 | 170 | ; filter out modules not supported on current system |
171 | (default (filter | |
172 | (lambda (p) | |
173 | (member (%current-system) | |
174 | (package-supported-systems p))) | |
175 | %default-xorg-modules))) | |
b2e56451 LC |
176 | (fonts xorg-configuration-fonts ;list of packges |
177 | (default %default-xorg-fonts)) | |
178 | (drivers xorg-configuration-drivers ;list of strings | |
179 | (default '())) | |
180 | (resolutions xorg-configuration-resolutions ;list of tuples | |
181 | (default '())) | |
598757e0 LC |
182 | (keyboard-layout xorg-configuration-keyboard-layout ;#f | <keyboard-layout> |
183 | (default #f)) | |
b2e56451 LC |
184 | (extra-config xorg-configuration-extra-config ;list of strings |
185 | (default '())) | |
892f1b72 | 186 | (server xorg-configuration-server ;file-like |
b2e56451 LC |
187 | (default xorg-server)) |
188 | (server-arguments xorg-configuration-server-arguments ;list of strings | |
189 | (default %default-xorg-server-arguments))) | |
190 | ||
191 | (define (xorg-configuration->file config) | |
192 | "Compute an Xorg configuration file corresponding to CONFIG, an | |
193 | <xorg-configuration> record." | |
8b158e8b CR |
194 | (let ((xorg-server (xorg-configuration-server config))) |
195 | (define all-modules | |
196 | ;; 'xorg-server' provides 'fbdevhw.so' etc. | |
197 | (append (xorg-configuration-modules config) | |
198 | (list xorg-server))) | |
d344f5a5 | 199 | |
8b158e8b CR |
200 | (define build |
201 | #~(begin | |
202 | (use-modules (ice-9 match) | |
203 | (srfi srfi-1) | |
204 | (srfi srfi-26)) | |
d344f5a5 | 205 | |
8b158e8b CR |
206 | (call-with-output-file #$output |
207 | (lambda (port) | |
208 | (define drivers | |
209 | '#$(xorg-configuration-drivers config)) | |
d344f5a5 | 210 | |
8b158e8b CR |
211 | (define (device-section driver) |
212 | (string-append " | |
f703413e LC |
213 | Section \"Device\" |
214 | Identifier \"device-" driver "\" | |
215 | Driver \"" driver "\" | |
216 | EndSection")) | |
db4fdc04 | 217 | |
8b158e8b CR |
218 | (define (screen-section driver resolutions) |
219 | (string-append " | |
d2e59637 LC |
220 | Section \"Screen\" |
221 | Identifier \"screen-" driver "\" | |
222 | Device \"device-" driver "\" | |
223 | SubSection \"Display\" | |
224 | Modes " | |
225 | (string-join (map (match-lambda | |
d1cdd7ba LC |
226 | ((x y) |
227 | (string-append "\"" (number->string x) | |
228 | "x" (number->string y) "\""))) | |
d2e59637 LC |
229 | resolutions)) " |
230 | EndSubSection | |
231 | EndSection")) | |
232 | ||
8b158e8b CR |
233 | (define (input-class-section layout variant model options) |
234 | (string-append " | |
598757e0 LC |
235 | Section \"InputClass\" |
236 | Identifier \"evdev keyboard catchall\" | |
237 | MatchIsKeyboard \"on\" | |
238 | Option \"XkbLayout\" " (object->string layout) | |
239 | (if variant | |
240 | (string-append " Option \"XkbVariant\" \"" | |
241 | variant "\"") | |
242 | "") | |
243 | (if model | |
244 | (string-append " Option \"XkbModel\" \"" | |
245 | model "\"") | |
246 | "") | |
247 | (match options | |
248 | (() | |
249 | "") | |
250 | (_ | |
251 | (string-append " Option \"XkbOptions\" \"" | |
252 | (string-join options ",") "\""))) " | |
253 | ||
254 | MatchDevicePath \"/dev/input/event*\" | |
255 | Driver \"evdev\" | |
256 | EndSection\n")) | |
257 | ||
8b158e8b CR |
258 | (define (expand modules) |
259 | ;; Append to MODULES the relevant /lib/xorg/modules | |
260 | ;; sub-directories. | |
261 | (append-map (lambda (module) | |
262 | (filter-map (lambda (directory) | |
263 | (let ((full (string-append module | |
264 | directory))) | |
265 | (and (file-exists? full) | |
266 | full))) | |
267 | '("/lib/xorg/modules/drivers" | |
268 | "/lib/xorg/modules/input" | |
269 | "/lib/xorg/modules/multimedia" | |
270 | "/lib/xorg/modules/extensions"))) | |
271 | modules)) | |
db4fdc04 | 272 | |
8b158e8b CR |
273 | (display "Section \"Files\"\n" port) |
274 | (for-each (lambda (font) | |
275 | (format port " FontPath \"~a\"~%" font)) | |
276 | '#$(xorg-configuration-fonts config)) | |
277 | (for-each (lambda (module) | |
278 | (format port | |
279 | " ModulePath \"~a\"~%" | |
280 | module)) | |
281 | (append (expand '#$all-modules) | |
d344f5a5 | 282 | |
8b158e8b CR |
283 | ;; For fbdevhw.so and so on. |
284 | (list #$(file-append xorg-server | |
285 | "/lib/xorg/modules")))) | |
286 | (display "EndSection\n" port) | |
287 | (display " | |
db4fdc04 | 288 | Section \"ServerFlags\" |
e30442b5 | 289 | Option \"AllowMouseOpenFail\" \"on\" |
d344f5a5 | 290 | EndSection\n" port) |
12422c9d | 291 | |
8b158e8b CR |
292 | (display (string-join (map device-section drivers) "\n") |
293 | port) | |
294 | (newline port) | |
295 | (display (string-join | |
296 | (map (cut screen-section <> | |
297 | '#$(xorg-configuration-resolutions config)) | |
298 | drivers) | |
299 | "\n") | |
300 | port) | |
301 | (newline port) | |
d344f5a5 | 302 | |
8b158e8b CR |
303 | (let ((layout #$(and=> (xorg-configuration-keyboard-layout config) |
304 | keyboard-layout-name)) | |
305 | (variant #$(and=> (xorg-configuration-keyboard-layout config) | |
306 | keyboard-layout-variant)) | |
307 | (model #$(and=> (xorg-configuration-keyboard-layout config) | |
308 | keyboard-layout-model)) | |
309 | (options '#$(and=> (xorg-configuration-keyboard-layout config) | |
310 | keyboard-layout-options))) | |
311 | (when layout | |
312 | (display (input-class-section layout variant model options) | |
313 | port) | |
314 | (newline port))) | |
598757e0 | 315 | |
8b158e8b CR |
316 | (for-each (lambda (config) |
317 | (display config port)) | |
318 | '#$(xorg-configuration-extra-config config)))))) | |
d344f5a5 | 319 | |
8b158e8b | 320 | (computed-file "xserver.conf" build))) |
db4fdc04 | 321 | |
79fd74fa AW |
322 | (define (xorg-configuration-directory modules) |
323 | "Return a directory that contains the @code{.conf} files for X.org that | |
324 | includes the @code{share/X11/xorg.conf.d} directories of each package listed | |
325 | in @var{modules}." | |
4ee96a79 LC |
326 | (with-imported-modules '((guix build utils)) |
327 | (computed-file "xorg.conf.d" | |
328 | #~(begin | |
329 | (use-modules (guix build utils) | |
330 | (srfi srfi-1)) | |
331 | ||
332 | (define files | |
333 | (append-map (lambda (module) | |
334 | (find-files (string-append | |
335 | module | |
336 | "/share/X11/xorg.conf.d") | |
337 | "\\.conf$")) | |
338 | (list #$@modules))) | |
339 | ||
340 | (mkdir #$output) | |
341 | (for-each (lambda (file) | |
342 | (symlink file | |
343 | (string-append #$output "/" | |
344 | (basename file)))) | |
345 | files) | |
346 | #t)))) | |
79fd74fa | 347 | |
b2e56451 LC |
348 | (define* (xorg-wrapper #:optional (config (xorg-configuration))) |
349 | "Return a derivation that builds a script to start the X server with the | |
350 | given @var{config}. The resulting script should be used in place of | |
351 | @code{/usr/bin/X}." | |
be1c2c54 LC |
352 | (define exp |
353 | ;; Write a small wrapper around the X server. | |
354 | #~(begin | |
355 | (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri")) | |
356 | (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin")) | |
357 | ||
b2e56451 | 358 | (let ((X (string-append #$(xorg-configuration-server config) "/bin/X"))) |
92753a8b AW |
359 | (apply execl X X |
360 | "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb") | |
b2e56451 LC |
361 | "-config" #$(xorg-configuration->file config) |
362 | "-configdir" #$(xorg-configuration-directory | |
363 | (xorg-configuration-modules config)) | |
92753a8b AW |
364 | (cdr (command-line)))))) |
365 | ||
366 | (program-file "X-wrapper" exp)) | |
be1c2c54 | 367 | |
b2e56451 LC |
368 | (define* (xorg-start-command #:optional (config (xorg-configuration))) |
369 | "Return a @code{startx} script in which the modules, fonts, etc. specified | |
370 | in @var{config}, are available. The result should be used in place of | |
371 | @code{startx}." | |
92753a8b | 372 | (define X |
b2e56451 LC |
373 | (xorg-wrapper config)) |
374 | ||
92753a8b AW |
375 | (define exp |
376 | ;; Write a small wrapper around the X server. | |
377 | #~(apply execl #$X #$X ;; Second #$X is for argv[0]. | |
b2e56451 LC |
378 | "-logverbose" "-verbose" "-terminate" |
379 | #$@(xorg-configuration-server-arguments config) | |
24f11b06 | 380 | (cdr (command-line)))) |
be1c2c54 | 381 | |
92753a8b | 382 | (program-file "startx" exp)) |
db4fdc04 | 383 | |
956607e3 | 384 | (define* (xinitrc #:key fallback-session) |
24d56899 SB |
385 | "Return a system-wide xinitrc script that starts the specified X session, |
386 | which should be passed to this script as the first argument. If not, the | |
65c0f436 LC |
387 | @var{fallback-session} will be used or, if @var{fallback-session} is false, a |
388 | desktop session from the system or user profile will be used." | |
8779d342 LC |
389 | (define builder |
390 | #~(begin | |
65c0f436 LC |
391 | (use-modules (ice-9 match) |
392 | (ice-9 regex) | |
393 | (ice-9 ftw) | |
4e1efba4 | 394 | (ice-9 rdelim) |
65c0f436 LC |
395 | (srfi srfi-1) |
396 | (srfi srfi-26)) | |
8779d342 | 397 | |
16c33bfb LC |
398 | (define (close-all-fdes) |
399 | ;; Close all the open file descriptors except 0 to 2. | |
400 | (let loop ((fd 3)) | |
401 | (when (< fd 4096) ;FIXME: use sysconf + _SC_OPEN_MAX | |
402 | (false-if-exception (close-fdes fd)) | |
403 | (loop (+ 1 fd))))) | |
404 | ||
b2bd7c25 LC |
405 | (define (exec-from-login-shell command . args) |
406 | ;; Run COMMAND from a login shell so that it gets to see the same | |
407 | ;; environment variables that one gets when logging in on a tty, for | |
408 | ;; instance. | |
409 | (let* ((pw (getpw (getuid))) | |
e0b85670 SB |
410 | (shell (passwd:shell pw))) |
411 | ;; Close any open file descriptors. This is all the more | |
412 | ;; important that SLiM itself exec's us directly without closing | |
413 | ;; its own file descriptors! | |
414 | (close-all-fdes) | |
415 | ||
416 | ;; The '--login' option is supported at least by Bash and zsh. | |
417 | (execl shell shell "--login" "-c" | |
418 | (string-join (cons command args))))) | |
419 | ||
65c0f436 LC |
420 | (define system-profile |
421 | "/run/current-system/profile") | |
422 | ||
423 | (define user-profile | |
424 | (and=> (getpw (getuid)) | |
425 | (lambda (pw) | |
426 | (string-append (passwd:dir pw) "/.guix-profile")))) | |
427 | ||
428 | (define (xsession-command desktop-file) | |
429 | ;; Read from DESKTOP-FILE its X session command and return it as a | |
430 | ;; list. | |
431 | (define exec-regexp | |
432 | (make-regexp "^[[:blank:]]*Exec=(.*)$")) | |
433 | ||
434 | (call-with-input-file desktop-file | |
435 | (lambda (port) | |
436 | (let loop () | |
437 | (match (read-line port) | |
438 | ((? eof-object?) #f) | |
439 | ((= (cut regexp-exec exec-regexp <>) result) | |
440 | (if result | |
441 | (string-tokenize (match:substring result 1)) | |
442 | (loop)))))))) | |
443 | ||
444 | (define (find-session profile) | |
445 | ;; Return an X session command from PROFILE or #f if none was found. | |
446 | (let ((directory (string-append profile "/share/xsessions"))) | |
447 | (match (scandir directory | |
448 | (cut string-suffix? ".desktop" <>)) | |
449 | ((or () #f) | |
450 | #f) | |
451 | ((sessions ...) | |
452 | (any xsession-command | |
453 | (map (cut string-append directory "/" <>) | |
454 | sessions)))))) | |
455 | ||
e0b85670 SB |
456 | (let* ((home (getenv "HOME")) |
457 | (xsession-file (string-append home "/.xsession")) | |
458 | (session (match (command-line) | |
65c0f436 LC |
459 | ((_) |
460 | #$(if fallback-session | |
461 | #~(list #$fallback-session) | |
462 | #f)) | |
463 | ((_ x ..1) | |
464 | x)))) | |
e0b85670 SB |
465 | (if (file-exists? xsession-file) |
466 | ;; Run ~/.xsession when it exists. | |
617e87bf LC |
467 | (apply exec-from-login-shell xsession-file |
468 | (or session '())) | |
65c0f436 LC |
469 | ;; Otherwise, start the specified session or a fallback. |
470 | (apply exec-from-login-shell | |
471 | (or session | |
472 | (find-session user-profile) | |
473 | (find-session system-profile))))))) | |
c510cbb4 | 474 | |
be1c2c54 | 475 | (program-file "xinitrc" builder)) |
9e4eddb4 | 476 | |
50be0da7 JK |
477 | (define-syntax handle-xorg-configuration |
478 | (syntax-rules () | |
479 | "Generate the `compose' and `extend' entries of a login manager | |
480 | `service-type' to handle specifying the `xorg-configuration' through | |
481 | a `service-extension', as used by `set-xorg-configuration'." | |
482 | ((_ configuration-record service-type-definition) | |
483 | (service-type | |
484 | (inherit service-type-definition) | |
485 | (compose (lambda (extensions) | |
486 | (match extensions | |
487 | (() #f) | |
488 | ((config . _) config)))) | |
489 | (extend (lambda (config xorg-configuration) | |
490 | (if xorg-configuration | |
491 | (configuration-record | |
492 | (inherit config) | |
493 | (xorg-configuration xorg-configuration)) | |
494 | config))))))) | |
495 | ||
e429325d SB |
496 | (define (xorg-server-profile-service config) |
497 | ;; XXX: profile-service-type only accepts <package> objects. | |
498 | (list | |
499 | (package | |
500 | (name "xorg-wrapper") | |
501 | (version (package-version xorg-server)) | |
502 | (source (xorg-wrapper config)) | |
503 | (build-system trivial-build-system) | |
504 | (arguments | |
505 | '(#:modules ((guix build utils)) | |
506 | #:builder | |
507 | (begin | |
508 | (use-modules (guix build utils)) | |
509 | (let* ((source (assoc-ref %build-inputs "source")) | |
510 | (out (assoc-ref %outputs "out")) | |
511 | (bin (string-append out "/bin"))) | |
512 | (mkdir-p bin) | |
513 | (symlink source (string-append bin "/X")) | |
514 | (symlink source (string-append bin "/Xorg")) | |
515 | #t)))) | |
516 | (home-page (package-home-page xorg-server)) | |
517 | (synopsis (package-synopsis xorg-server)) | |
518 | (description (package-description xorg-server)) | |
519 | (license (package-license xorg-server))))) | |
520 | ||
521 | (define xorg-server-service-type | |
522 | (service-type | |
523 | (name 'xorg-server) | |
524 | (extensions | |
525 | (list (service-extension profile-service-type | |
526 | xorg-server-profile-service))) | |
527 | (default-value (xorg-configuration)) | |
528 | (description "Add @command{X} to the system profile, to be used with | |
529 | @command{sx} or @command{xinit}."))) | |
530 | ||
0ecc3bf3 LC |
531 | \f |
532 | ;;; | |
533 | ;;; SLiM log-in manager. | |
534 | ;;; | |
535 | ||
0ecc3bf3 LC |
536 | (define %default-slim-theme |
537 | ;; Theme based on work by Felipe López. | |
9e41130b | 538 | (file-append %artwork-repository "/slim")) |
0ecc3bf3 LC |
539 | |
540 | (define %default-slim-theme-name | |
541 | ;; This must be the name of the sub-directory in %DEFAULT-SLIM-THEME that | |
542 | ;; contains the actual theme files. | |
2f9f792a | 543 | "1.x") |
0ecc3bf3 | 544 | |
0adfe95a LC |
545 | (define-record-type* <slim-configuration> |
546 | slim-configuration make-slim-configuration | |
547 | slim-configuration? | |
548 | (slim slim-configuration-slim | |
549 | (default slim)) | |
b37f86d7 LC |
550 | (allow-empty-passwords? slim-configuration-allow-empty-passwords? |
551 | (default #t)) | |
b948ab8b OP |
552 | (gnupg? slim-configuration-gnupg? |
553 | (default #f)) | |
b37f86d7 LC |
554 | (auto-login? slim-configuration-auto-login? |
555 | (default #f)) | |
556 | (default-user slim-configuration-default-user | |
557 | (default "")) | |
558 | (theme slim-configuration-theme | |
559 | (default %default-slim-theme)) | |
560 | (theme-name slim-configuration-theme-name | |
561 | (default %default-slim-theme-name)) | |
0adfe95a LC |
562 | (xauth slim-configuration-xauth |
563 | (default xauth)) | |
26b94866 AK |
564 | (shepherd slim-configuration-shepherd |
565 | (default shepherd)) | |
b37f86d7 | 566 | (auto-login-session slim-configuration-auto-login-session |
65c0f436 | 567 | (default #f)) |
554b8607 LC |
568 | (xorg-configuration slim-configuration-xorg |
569 | (default (xorg-configuration))) | |
61569171 DNB |
570 | (display slim-configuration-display |
571 | (default ":0")) | |
572 | (vt slim-configuration-vt | |
573 | (default "vt7")) | |
736e45a2 DM |
574 | (sessreg slim-configuration-sessreg |
575 | (default sessreg))) | |
0adfe95a LC |
576 | |
577 | (define (slim-pam-service config) | |
578 | "Return a PAM service for @command{slim}." | |
579 | (list (unix-pam-service | |
580 | "slim" | |
e6b1a224 | 581 | #:login-uid? #t |
0adfe95a | 582 | #:allow-empty-passwords? |
b948ab8b OP |
583 | (slim-configuration-allow-empty-passwords? config) |
584 | #:gnupg? | |
585 | (slim-configuration-gnupg? config)))) | |
0adfe95a | 586 | |
d4053c71 | 587 | (define (slim-shepherd-service config) |
61569171 DNB |
588 | (let* ((xinitrc (xinitrc #:fallback-session |
589 | (slim-configuration-auto-login-session config))) | |
590 | (xauth (slim-configuration-xauth config)) | |
591 | (startx (xorg-start-command (slim-configuration-xorg config))) | |
592 | (display (slim-configuration-display config)) | |
593 | (vt (slim-configuration-vt config)) | |
594 | (shepherd (slim-configuration-shepherd config)) | |
595 | (theme-name (slim-configuration-theme-name config)) | |
596 | (sessreg (slim-configuration-sessreg config)) | |
597 | (lockfile (string-append "/var/run/slim-" vt ".lock"))) | |
598 | (define slim.cfg | |
0adfe95a LC |
599 | (mixed-text-file "slim.cfg" " |
600 | default_path /run/current-system/profile/bin | |
601 | default_xserver " startx " | |
61569171 DNB |
602 | display_name " display " |
603 | xserver_arguments " vt " | |
0adfe95a | 604 | xauth_path " xauth "/bin/xauth |
61569171 DNB |
605 | authfile /var/run/slim-" vt ".auth |
606 | lockfile " lockfile " | |
607 | logfile /var/log/slim-" vt ".log | |
0adfe95a LC |
608 | |
609 | # The login command. '%session' is replaced by the chosen session name, one | |
610 | # of the names specified in the 'sessions' setting: 'wmaker', 'xfce', etc. | |
611 | login_cmd exec " xinitrc " %session | |
612 | sessiondir /run/current-system/profile/share/xsessions | |
613 | session_msg session (F1 to change): | |
736e45a2 DM |
614 | sessionstart_cmd " sessreg "/bin/sessreg -a -l $DISPLAY %user |
615 | sessionstop_cmd " sessreg "/bin/sessreg -d -l $DISPLAY %user | |
0adfe95a | 616 | |
26b94866 AK |
617 | halt_cmd " shepherd "/sbin/halt |
618 | reboot_cmd " shepherd "/sbin/reboot\n" | |
0adfe95a LC |
619 | (if (slim-configuration-auto-login? config) |
620 | (string-append "auto_login yes\ndefault_user " | |
621 | (slim-configuration-default-user config) "\n") | |
622 | "") | |
623 | (if theme-name | |
624 | (string-append "current_theme " theme-name "\n") | |
61569171 DNB |
625 | ""))) |
626 | ||
627 | (define theme | |
628 | (slim-configuration-theme config)) | |
629 | ||
630 | (list (shepherd-service | |
631 | (documentation "Xorg display server") | |
6ad799d7 LC |
632 | (provision (append |
633 | ;; For compatibility, also provide 'xorg-server'. | |
634 | (if (string=? vt "vt7") | |
635 | '(xorg-server) | |
636 | '()) | |
637 | ||
638 | (list (symbol-append 'xorg-server- | |
639 | (string->symbol vt))))) | |
61569171 DNB |
640 | (requirement '(user-processes host-name udev)) |
641 | (start | |
642 | #~(lambda () | |
643 | ;; A stale lock file can prevent SLiM from starting, so remove it to | |
644 | ;; be on the safe side. | |
645 | (false-if-exception (delete-file lockfile)) | |
646 | ||
647 | (fork+exec-command | |
648 | (list (string-append #$(slim-configuration-slim config) | |
649 | "/bin/slim") | |
650 | "-nodaemon") | |
651 | #:environment-variables | |
652 | (list (string-append "SLIM_CFGFILE=" #$slim.cfg) | |
653 | #$@(if theme | |
654 | (list #~(string-append "SLIM_THEMESDIR=" #$theme)) | |
655 | #~()))))) | |
656 | (stop #~(make-kill-destructor)) | |
657 | (respawn? #t))))) | |
0adfe95a LC |
658 | |
659 | (define slim-service-type | |
50be0da7 JK |
660 | (handle-xorg-configuration slim-configuration |
661 | (service-type (name 'slim) | |
662 | (extensions | |
663 | (list (service-extension shepherd-root-service-type | |
664 | slim-shepherd-service) | |
665 | (service-extension pam-root-service-type | |
666 | slim-pam-service) | |
e9b82124 | 667 | |
50be0da7 JK |
668 | ;; Unconditionally add xterm to the system profile, to |
669 | ;; avoid bad surprises. | |
670 | (service-extension profile-service-type | |
671 | (const (list xterm))))) | |
672 | ||
dd0804c6 LC |
673 | (default-value (slim-configuration)) |
674 | (description | |
675 | "Run the SLiM graphical login manager for X11.")))) | |
0adfe95a | 676 | |
6726282b LC |
677 | \f |
678 | ;;; | |
679 | ;;; Screen lockers & co. | |
680 | ;;; | |
681 | ||
682 | (define-record-type <screen-locker> | |
683 | (screen-locker name program empty?) | |
684 | screen-locker? | |
685 | (name screen-locker-name) ;string | |
686 | (program screen-locker-program) ;gexp | |
687 | (empty? screen-locker-allows-empty-passwords?)) ;Boolean | |
688 | ||
689 | (define screen-locker-pam-services | |
690 | (match-lambda | |
691 | (($ <screen-locker> name _ empty?) | |
692 | (list (unix-pam-service name | |
693 | #:allow-empty-passwords? empty?))))) | |
694 | ||
695 | (define screen-locker-setuid-programs | |
a85ec0bf | 696 | (compose list file-like->setuid-program screen-locker-program)) |
6726282b LC |
697 | |
698 | (define screen-locker-service-type | |
699 | (service-type (name 'screen-locker) | |
700 | (extensions | |
701 | (list (service-extension pam-root-service-type | |
702 | screen-locker-pam-services) | |
703 | (service-extension setuid-program-service-type | |
dd0804c6 LC |
704 | screen-locker-setuid-programs))) |
705 | (description | |
706 | "Allow the given program to be used as a screen locker for | |
707 | the graphical server by making it setuid-root, so it can authenticate users, | |
708 | and by creating a PAM service for it."))) | |
6726282b LC |
709 | |
710 | (define* (screen-locker-service package | |
711 | #:optional | |
712 | (program (package-name package)) | |
713 | #:key allow-empty-passwords?) | |
d64e1746 | 714 | "Add @var{package}, a package for a screen locker or screen saver whose |
6726282b LC |
715 | command is @var{program}, to the set of setuid programs and add a PAM entry |
716 | for it. For example: | |
717 | ||
718 | @lisp | |
9e41130b | 719 | (screen-locker-service xlockmore \"xlock\") |
6726282b LC |
720 | @end lisp |
721 | ||
722 | makes the good ol' XlockMore usable." | |
723 | (service screen-locker-service-type | |
724 | (screen-locker program | |
9e41130b | 725 | (file-append package "/bin/" program) |
6726282b LC |
726 | allow-empty-passwords?))) |
727 | ||
607fcc75 LC |
728 | \f |
729 | ;;; | |
730 | ;;; Locale service. | |
731 | ;;; | |
732 | ||
733 | (define-record-type* <localed-configuration> | |
734 | localed-configuration make-localed-configuration | |
735 | localed-configuration? | |
736 | (localed localed-configuration-localed | |
737 | (default localed)) | |
738 | (keyboard-layout localed-configuration-keyboard-layout | |
739 | (default #f))) | |
740 | ||
741 | (define (localed-dbus-service config) | |
742 | "Return the 'localed' D-Bus service for @var{config}, a | |
743 | @code{<localed-configuration>} record." | |
744 | (define keyboard-layout | |
745 | (localed-configuration-keyboard-layout config)) | |
746 | ||
747 | ;; The primary purpose of 'localed' is to tell GDM what the "current" Xorg | |
748 | ;; keyboard layout is. If 'localed' is missing, or if it's unable to | |
749 | ;; determine the current XKB layout, then GDM forcefully installs its | |
750 | ;; default XKB config (US English). Here we communicate the configured | |
751 | ;; layout through environment variables. | |
752 | ||
753 | (if keyboard-layout | |
754 | (let* ((layout (keyboard-layout-name keyboard-layout)) | |
755 | (variant (keyboard-layout-variant keyboard-layout)) | |
756 | (model (keyboard-layout-model keyboard-layout)) | |
757 | (options (keyboard-layout-options keyboard-layout))) | |
758 | (list (wrapped-dbus-service | |
759 | (localed-configuration-localed config) | |
760 | "libexec/localed/localed" | |
761 | `(("GUIX_XKB_LAYOUT" ,layout) | |
762 | ,@(if variant | |
763 | `(("GUIX_XKB_VARIANT" ,variant)) | |
764 | '()) | |
765 | ,@(if model | |
766 | `(("GUIX_XKB_MODEL" ,model)) | |
767 | '()) | |
768 | ,@(if (null? options) | |
769 | '() | |
770 | `(("GUIX_XKB_OPTIONS" | |
771 | ,(string-join options ",")))))))) | |
3ef3bdf1 | 772 | '())) |
607fcc75 LC |
773 | |
774 | (define localed-service-type | |
13615849 LC |
775 | (let ((package (lambda (config) |
776 | ;; Don't bother if the user didn't specify any keyboard | |
777 | ;; layout. | |
778 | (if (localed-configuration-keyboard-layout config) | |
779 | (list (localed-configuration-localed config)) | |
780 | '())))) | |
607fcc75 LC |
781 | (service-type (name 'localed) |
782 | (extensions | |
783 | (list (service-extension dbus-root-service-type | |
784 | localed-dbus-service) | |
785 | (service-extension udev-service-type package) | |
786 | (service-extension polkit-service-type package) | |
787 | ||
788 | ;; Add 'localectl' to the profile. | |
789 | (service-extension profile-service-type package))) | |
790 | ||
791 | ;; This service can be extended, typically by the X login | |
792 | ;; manager, to communicate the chosen Xorg keyboard layout. | |
13615849 LC |
793 | (compose (lambda (extensions) |
794 | (find keyboard-layout? extensions))) | |
607fcc75 LC |
795 | (extend (lambda (config keyboard-layout) |
796 | (localed-configuration | |
797 | (inherit config) | |
798 | (keyboard-layout keyboard-layout)))) | |
799 | (description | |
800 | "Run the locale daemon, @command{localed}, which can be used | |
801 | to control the system locale and keyboard mapping from user programs such as | |
802 | the GNOME desktop environment.") | |
803 | (default-value (localed-configuration))))) | |
804 | ||
805 | \f | |
806 | ;;; | |
807 | ;;; GNOME Desktop Manager. | |
808 | ;;; | |
809 | ||
6e99c01b AW |
810 | (define %gdm-accounts |
811 | (list (user-group (name "gdm") (system? #t)) | |
812 | (user-account | |
813 | (name "gdm") | |
814 | (group "gdm") | |
acb41a40 | 815 | (supplementary-groups '("video")) |
6e99c01b AW |
816 | (system? #t) |
817 | (comment "GNOME Display Manager user") | |
818 | (home-directory "/var/lib/gdm") | |
819 | (shell (file-append shadow "/sbin/nologin"))))) | |
820 | ||
a43e9157 LC |
821 | (define %gdm-activation |
822 | ;; Ensure /var/lib/gdm is owned by the "gdm" user. This is normally the | |
823 | ;; case but could be wrong if the "gdm" user was created, then removed, and | |
824 | ;; then recreated under a different UID/GID: <https://bugs.gnu.org/37423>. | |
825 | (with-imported-modules '((guix build utils)) | |
826 | #~(begin | |
827 | (use-modules (guix build utils)) | |
828 | ||
829 | (let* ((gdm (getpwnam "gdm")) | |
830 | (uid (passwd:uid gdm)) | |
831 | (gid (passwd:gid gdm)) | |
832 | (st (stat "/var/lib/gdm" #f))) | |
833 | ;; Recurse into /var/lib/gdm only if it has wrong ownership. | |
834 | (when (and st | |
835 | (or (not (= uid (stat:uid st))) | |
836 | (not (= gid (stat:gid st))))) | |
837 | (for-each (lambda (file) | |
838 | (chown file uid gid)) | |
839 | (find-files "/var/lib/gdm" | |
840 | #:directories? #t))))))) | |
841 | ||
1f564c15 | 842 | (define dbus-daemon-wrapper |
dcb3a0fe TS |
843 | (program-file |
844 | "gdm-dbus-wrapper" | |
845 | #~(begin | |
846 | (use-modules (srfi srfi-26)) | |
847 | ||
848 | (define system-profile | |
849 | "/run/current-system/profile") | |
850 | ||
851 | (define user-profile | |
852 | (and=> (getpw (getuid)) | |
853 | (lambda (pw) | |
854 | (string-append (passwd:dir pw) "/.guix-profile")))) | |
855 | ||
856 | ;; If we are able to find the user's profile, we can add it to | |
857 | ;; the search paths set below. We need to do this so that D-Bus | |
858 | ;; can start services installed by the user. This allows | |
859 | ;; applications that require session D-Bus services (e.g, | |
860 | ;; 'evolution') to work even if those services are only available | |
861 | ;; in the user's profile. See <https://bugs.gnu.org/35267>. | |
862 | (define profiles | |
863 | (if user-profile | |
864 | (list user-profile system-profile) | |
865 | (list system-profile))) | |
866 | ||
867 | (setenv "XDG_CONFIG_DIRS" | |
868 | (string-join (map (cut string-append <> "/etc/xdg") profiles) | |
869 | ":")) | |
870 | (setenv "XDG_DATA_DIRS" | |
871 | (string-join (map (cut string-append <> "/share") profiles) | |
872 | ":")) | |
873 | (apply execl (string-append #$dbus "/bin/dbus-daemon") | |
874 | (program-arguments))))) | |
1f564c15 | 875 | |
db4681a4 JP |
876 | ;; Wrapper script for Wayland sessions, similar to Xsession. |
877 | ;; | |
878 | ;; See `xinitrc`. By default, it launches the specified session through a | |
879 | ;; login shell. With the default Guix configuration, this should source | |
880 | ;; /etc/profile, setting up the Guix profile environment variables. However, | |
881 | ;; gdm launches its own graphical session through the same method, so we need | |
882 | ;; to ignore this case, since `gdm` doesn't have a login shell. | |
883 | (define gdm-wayland-session-wrapper | |
884 | (program-file | |
885 | "gdm-wayland-session-wrapper" | |
886 | #~((let* ((user (getpw (getuid))) | |
887 | (name (passwd:name user)) | |
888 | (shell (passwd:shell user)) | |
889 | (args (cdr (command-line)))) | |
890 | (if (string=? name "gdm") | |
891 | (apply execl (cons (car args) args)) | |
892 | (execl shell shell "--login" "-c" (string-join args))))))) | |
893 | ||
6e99c01b AW |
894 | (define-record-type* <gdm-configuration> |
895 | gdm-configuration make-gdm-configuration | |
896 | gdm-configuration? | |
897 | (gdm gdm-configuration-gdm (default gdm)) | |
898 | (allow-empty-passwords? gdm-configuration-allow-empty-passwords? (default #t)) | |
6e99c01b | 899 | (auto-login? gdm-configuration-auto-login? (default #f)) |
1f564c15 | 900 | (dbus-daemon gdm-configuration-dbus-daemon (default dbus-daemon-wrapper)) |
88f95687 | 901 | (debug? gdm-configuration-debug? (default #f)) |
6e99c01b | 902 | (default-user gdm-configuration-default-user (default #f)) |
7e614198 | 903 | (gnome-shell-assets gdm-configuration-gnome-shell-assets |
44469ffd | 904 | (default (list adwaita-icon-theme font-abattis-cantarell))) |
554b8607 LC |
905 | (xorg-configuration gdm-configuration-xorg |
906 | (default (xorg-configuration))) | |
41fa9f18 | 907 | (x-session gdm-configuration-x-session |
5c3f0c3e | 908 | (default (xinitrc))) |
db4681a4 JP |
909 | (wayland? gdm-configuration-wayland? (default #f)) |
910 | (wayland-session gdm-configuration-wayland-session | |
911 | (default gdm-wayland-session-wrapper))) | |
6e99c01b | 912 | |
e57c2adb TS |
913 | (define (gdm-configuration-file config) |
914 | (mixed-text-file "gdm-custom.conf" | |
915 | "[daemon]\n" | |
916 | "#User=gdm\n" | |
917 | "#Group=gdm\n" | |
918 | (if (gdm-configuration-auto-login? config) | |
919 | (string-append | |
920 | "AutomaticLoginEnable=true\n" | |
921 | "AutomaticLogin=" | |
922 | (or (gdm-configuration-default-user config) | |
923 | (error "missing default user for auto-login")) | |
924 | "\n") | |
925 | (string-append | |
926 | "AutomaticLoginEnable=false\n" | |
927 | "#AutomaticLogin=\n")) | |
928 | "#TimedLoginEnable=false\n" | |
929 | "#TimedLogin=\n" | |
930 | "#TimedLoginDelay=0\n" | |
9111f975 LP |
931 | ;; Disable initial system setup inside GDM. |
932 | ;; Whatever settings are set there should already be | |
933 | ;; taken care of through `guix system'. | |
934 | ;; See also | |
935 | ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39281>. | |
936 | "InitialSetupEnable=false\n" | |
5c3f0c3e JP |
937 | "WaylandEnable=" (if (gdm-configuration-wayland? config) |
938 | "true" | |
939 | "false") "\n" | |
e57c2adb TS |
940 | "\n" |
941 | "[debug]\n" | |
88f95687 TS |
942 | "Enable=" (if (gdm-configuration-debug? config) |
943 | "true" | |
944 | "false") "\n" | |
e57c2adb TS |
945 | "\n" |
946 | "[security]\n" | |
947 | "#DisallowTCP=true\n" | |
948 | "#AllowRemoteAutoLogin=false\n")) | |
6e99c01b AW |
949 | |
950 | (define (gdm-pam-service config) | |
951 | "Return a PAM service for @command{gdm}." | |
952 | (list | |
953 | (pam-service | |
e6b1a224 LC |
954 | (inherit (unix-pam-service "gdm-autologin" |
955 | #:login-uid? #t)) | |
6e99c01b | 956 | (auth (list (pam-entry |
d8258177 | 957 | (control "optional") |
6e99c01b AW |
958 | (module (file-append (gdm-configuration-gdm config) |
959 | "/lib/security/pam_gdm.so"))) | |
960 | (pam-entry | |
961 | (control "sufficient") | |
962 | (module "pam_permit.so"))))) | |
963 | (pam-service | |
964 | (inherit (unix-pam-service "gdm-launch-environment")) | |
965 | (auth (list (pam-entry | |
966 | (control "required") | |
967 | (module "pam_permit.so"))))) | |
de409e82 | 968 | (unix-pam-service "gdm-password" |
e6b1a224 | 969 | #:login-uid? #t |
de409e82 TS |
970 | #:allow-empty-passwords? |
971 | (gdm-configuration-allow-empty-passwords? config)))) | |
6e99c01b AW |
972 | |
973 | (define (gdm-shepherd-service config) | |
974 | (list (shepherd-service | |
975 | (documentation "Xorg display server (GDM)") | |
976 | (provision '(xorg-server)) | |
11b586db | 977 | (requirement '(dbus-system user-processes host-name udev elogind)) |
6e99c01b AW |
978 | (start #~(lambda () |
979 | (fork+exec-command | |
980 | (list #$(file-append (gdm-configuration-gdm config) | |
981 | "/bin/gdm")) | |
982 | #:environment-variables | |
983 | (list (string-append | |
e57c2adb TS |
984 | "GDM_CUSTOM_CONF=" |
985 | #$(gdm-configuration-file config)) | |
1f564c15 TS |
986 | (string-append |
987 | "GDM_DBUS_DAEMON=" | |
988 | #$(gdm-configuration-dbus-daemon config)) | |
e57c2adb | 989 | (string-append |
6e99c01b | 990 | "GDM_X_SERVER=" |
554b8607 LC |
991 | #$(xorg-wrapper |
992 | (gdm-configuration-xorg config))) | |
41fa9f18 TS |
993 | (string-append |
994 | "GDM_X_SESSION=" | |
995 | #$(gdm-configuration-x-session config)) | |
7e614198 TS |
996 | (string-append |
997 | "XDG_DATA_DIRS=" | |
998 | ((lambda (ls) (string-join ls ":")) | |
999 | (map (lambda (path) | |
1000 | (string-append path "/share")) | |
1001 | ;; XXX: Remove gnome-shell below when GDM | |
1002 | ;; can depend on GNOME Shell directly. | |
1003 | (cons #$gnome-shell | |
1004 | '#$(gdm-configuration-gnome-shell-assets | |
5c3f0c3e JP |
1005 | config))))) |
1006 | ;; Add XCURSOR_PATH so that mutter can find its | |
1007 | ;; cursors. gdm doesn't login so doesn't source | |
1008 | ;; the corresponding line in /etc/profile. | |
db4681a4 | 1009 | "XCURSOR_PATH=/run/current-system/profile/share/icons" |
c3fd310d JP |
1010 | (string-append |
1011 | "GDK_PIXBUF_MODULE_FILE=" | |
1012 | #$gnome-shell "/" #$%gdk-pixbuf-loaders-cache-file) | |
db4681a4 JP |
1013 | (string-append |
1014 | "GDM_WAYLAND_SESSION=" | |
1015 | #$(gdm-configuration-wayland-session config)))))) | |
6e99c01b AW |
1016 | (stop #~(make-kill-destructor)) |
1017 | (respawn? #t)))) | |
1018 | ||
1019 | (define gdm-service-type | |
50be0da7 JK |
1020 | (handle-xorg-configuration gdm-configuration |
1021 | (service-type (name 'gdm) | |
1022 | (extensions | |
1023 | (list (service-extension shepherd-root-service-type | |
1024 | gdm-shepherd-service) | |
1025 | (service-extension activation-service-type | |
1026 | (const %gdm-activation)) | |
1027 | (service-extension account-service-type | |
1028 | (const %gdm-accounts)) | |
1029 | (service-extension pam-root-service-type | |
1030 | gdm-pam-service) | |
1031 | (service-extension profile-service-type | |
1032 | gdm-configuration-gnome-shell-assets) | |
1033 | (service-extension dbus-root-service-type | |
1034 | (compose list | |
1035 | gdm-configuration-gdm)) | |
1036 | (service-extension localed-service-type | |
1037 | (compose | |
1038 | xorg-configuration-keyboard-layout | |
1039 | gdm-configuration-xorg)))) | |
1040 | (default-value (gdm-configuration)) | |
1041 | (description | |
1042 | "Run the GNOME Desktop Manager (GDM), a program that allows | |
1043 | you to log in in a graphical session, whether or not you use GNOME.")))) | |
6e99c01b | 1044 | |
79260c86 CM |
1045 | ;; Since GDM depends on Rust (gdm -> gnome-shell -> gjs -> mozjs -> rust) |
1046 | ;; and Rust is currently unavailable on non-x86_64 platforms, default to | |
1047 | ;; SDDM there (FIXME). | |
305a732a LC |
1048 | (define* (set-xorg-configuration config |
1049 | #:optional | |
1050 | (login-manager-service-type | |
dc2b9010 CM |
1051 | (if (target-x86-64?) |
1052 | gdm-service-type | |
1053 | sddm-service-type))) | |
305a732a LC |
1054 | "Tell the log-in manager (of type @var{login-manager-service-type}) to use |
1055 | @var{config}, an <xorg-configuration> record." | |
1056 | (simple-service 'set-xorg-configuration | |
1057 | login-manager-service-type | |
1058 | config)) | |
1059 | ||
db4fdc04 | 1060 | ;;; xorg.scm ends here |