1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 David Craven <david@craven.ch>
3 ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2019 Jesse Gildersleve <jessejohngildersleve@protonmail.com>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu services sddm)
22 #:use-module (gnu packages admin)
23 #:use-module (gnu packages display-managers)
24 #:use-module (gnu packages freedesktop)
25 #:use-module (gnu packages xorg)
26 #:use-module (gnu services)
27 #:use-module (gnu services shepherd)
28 #:use-module (gnu services xorg)
29 #:use-module (gnu system pam)
30 #:use-module (gnu system shadow)
31 #:use-module (guix gexp)
32 #:use-module (guix records)
33 #:use-module (guix deprecation)
34 #:export (sddm-configuration
39 (define-record-type* <sddm-configuration>
40 sddm-configuration make-sddm-configuration
42 (sddm sddm-configuration-sddm
46 ;; valid values are x11 and wayland
47 ;; currently doesn't do anything is enabled by wayland greeter PR
48 (display-server sddm-configuration-display-server
50 ;; valid values are on, off or none
51 (numlock sddm-configuration-numlock
53 (halt-command sddm-configuration-halt-command
54 (default (file-append shepherd "/sbin/halt")))
55 (reboot-command sddm-configuration-reboot-command
56 (default (file-append shepherd "/sbin/reboot")))
59 ;; valid values are elarun or maldives
60 (theme sddm-configuration-theme
62 (themes-directory sddm-configuration-themes-directory
63 (default "/run/current-system/profile/share/sddm/themes"))
64 (faces-directory sddm-configuration-faces-directory
65 (default "/run/current-system/profile/share/sddm/faces"))
68 (default-path sddm-configuration-default-path
69 (default "/run/current-system/profile/bin"))
70 (minimum-uid sddm-configuration-minimum-uid
72 (maximum-uid sddm-configuration-maximum-uid
74 (remember-last-user? sddm-configuration-remember-last-user?
76 (remember-last-session? sddm-configuration-remember-last-session?
78 (hide-users sddm-configuration-hide-users
80 (hide-shells sddm-configuration-hide-shells
81 (default (file-append shadow "/sbin/nologin")))
84 (session-command sddm-configuration-session-command
85 (default (file-append sddm "/share/sddm/scripts/wayland-session")))
86 (sessions-directory sddm-configuration-sessions-directory
87 (default "/run/current-system/profile/share/wayland-sessions"))
89 (xorg-configuration sddm-configuration-xorg
90 (default (xorg-configuration)))
91 (xauth-path sddm-configuration-xauth-path
92 (default (file-append xauth "/bin/xauth")))
93 (xephyr-path sddm-configuration-xephyr-path
94 (default (file-append xorg-server "/bin/Xephyr")))
95 (xdisplay-start sddm-configuration-xdisplay-start
96 (default (file-append sddm "/share/sddm/scripts/Xsetup")))
97 (xdisplay-stop sddm-configuration-xdisplay-stop
98 (default (file-append sddm "/share/sddm/scripts/Xstop")))
99 (xsession-command sddm-configuration-xsession-command
101 (xsessions-directory sddm-configuration-xsessions-directory
102 (default "/run/current-system/profile/share/xsessions"))
103 (minimum-vt sddm-configuration-minimum-vt
107 (auto-login-user sddm-configuration-auto-login-user
109 ;; valid values are xfce.desktop gnome.desktop weston.desktop hawaii.desktop
110 (auto-login-session sddm-configuration-auto-login-session
112 (relogin? sddm-configuration-relogin?
115 (define (sddm-configuration-file config)
116 (mixed-text-file "sddm.conf" "
118 DisplayServer=" (sddm-configuration-display-server config) "
119 Numlock=" (sddm-configuration-numlock config) "
120 HaltCommand=" (sddm-configuration-halt-command config) "
121 RebootCommand=" (sddm-configuration-reboot-command config) "
124 DefaultPath=" (sddm-configuration-default-path config) "
125 MinimumUid=" (number->string (sddm-configuration-minimum-uid config))"
126 MaximumUid=" (number->string (sddm-configuration-maximum-uid config))"
127 RememberLastUser=" (if (sddm-configuration-remember-last-user? config)
129 RememberLastSession=" (if (sddm-configuration-remember-last-session? config)
131 HideUsers=" (sddm-configuration-hide-users config) "
132 Hideshells=" (sddm-configuration-hide-shells config) "
135 Current=" (sddm-configuration-theme config) "
136 ThemeDir=" (sddm-configuration-themes-directory config) "
137 FacesDir=" (sddm-configuration-faces-directory config) "
140 SessionCommand=" (sddm-configuration-session-command config) "
141 SessionDir=" (sddm-configuration-sessions-directory config) "
144 ServerPath=" (xorg-start-command (sddm-configuration-xorg config)) "
145 XauthPath=" (sddm-configuration-xauth-path config) "
146 XephyrPath=" (sddm-configuration-xephyr-path config) "
147 DisplayCommand=" (sddm-configuration-xdisplay-start config) "
148 DisplayStopCommand=" (sddm-configuration-xdisplay-stop config) "
149 SessionCommand=" (sddm-configuration-xsession-command config) "
150 SessionDir=" (sddm-configuration-xsessions-directory config) "
151 MinimumVT=" (number->string (sddm-configuration-minimum-vt config)) "
152 ServerArguments=" (string-join
153 (xorg-configuration-server-arguments
154 (sddm-configuration-xorg config))) "
157 User=" (sddm-configuration-auto-login-user config) "
158 Session=" (sddm-configuration-auto-login-session config) "
159 Relogin=" (if (sddm-configuration-relogin? config)
163 (define (sddm-shepherd-service config)
164 "Return a <shepherd-service> for sddm with CONFIG."
167 #~(list (string-append #$(sddm-configuration-sddm config) "/bin/sddm")))
169 (list (shepherd-service
170 (documentation "SDDM display manager.")
171 (requirement '(user-processes))
172 (provision '(display-manager))
173 (start #~(make-forkexec-constructor #$sddm-command))
174 (stop #~(make-kill-destructor)))))
176 (define (sddm-etc-service config)
177 (list `("sddm.conf" ,(sddm-configuration-file config))))
179 (define (sddm-pam-service config)
180 "Return a PAM service for @command{sddm}."
186 (control "requisite")
187 (module "pam_nologin.so"))
190 (module "pam_env.so"))
193 (module "pam_succeed_if.so")
194 (arguments (list (string-append "uid >= "
195 (number->string (sddm-configuration-minimum-uid config)))
197 ;; should be factored out into system-auth
200 (module "pam_unix.so"))))
203 ;; should be factored out into system-account
206 (module "pam_unix.so"))))
209 ;; should be factored out into system-password
212 (module "pam_unix.so")
213 (arguments (list "sha512" "shadow" "try_first_pass")))))
216 ;; lfs has a required pam_limits.so
217 ;; should be factored out into system-session
220 (module "pam_unix.so"))))))
222 (define (sddm-greeter-pam-service)
223 "Return a PAM service for @command{sddm-greeter}."
225 (name "sddm-greeter")
228 ;; Load environment from /etc/environment and ~/.pam_environment
231 (module "pam_env.so"))
232 ;; Always let the greeter start without authentication
235 (module "pam_permit.so"))))
238 ;; No action required for account management
241 (module "pam_permit.so"))))
244 ;; Can't change password
247 (module "pam_deny.so"))))
253 (module "pam_unix.so"))))))
255 (define (sddm-autologin-pam-service config)
256 "Return a PAM service for @command{sddm-autologin}"
258 (name "sddm-autologin")
262 (control "requisite")
263 (module "pam_nologin.so"))
266 (module "pam_succeed_if.so")
267 (arguments (list (string-append "uid >= "
268 (number->string (sddm-configuration-minimum-uid config)))
272 (module "pam_permit.so"))))
282 (module "pam_deny.so"))))
289 (define (sddm-pam-services config)
290 (list (sddm-pam-service config)
291 (sddm-greeter-pam-service)
292 (sddm-autologin-pam-service config)))
294 (define %sddm-accounts
295 (list (user-group (name "sddm") (system? #t))
300 (comment "SDDM user")
301 (home-directory "/var/lib/sddm")
302 (shell (file-append shadow "/sbin/nologin")))))
304 ;; Add default themes to profile
305 (define sddm-profile-service
306 (compose list sddm-configuration-sddm))
308 (define sddm-service-type
309 (service-type (name 'sddm)
311 (list (service-extension shepherd-root-service-type
312 sddm-shepherd-service)
313 (service-extension etc-service-type
315 (service-extension pam-root-service-type
317 (service-extension account-service-type
318 (const %sddm-accounts))
319 (service-extension profile-service-type
320 sddm-profile-service)))
321 (default-value (sddm-configuration))
323 "Run SDDM, a display and log-in manager for X11 and
326 (define-deprecated (sddm-service #:optional (config (sddm-configuration)))
328 "Run the @uref{https://github.com/sddm/sddm,SSDM display manager}
329 with the given @var{config}, a @code{<sddm-configuration>} object."
330 (service sddm-service-type config))