Commit | Line | Data |
---|---|---|
935644c0 DC |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 David Craven <david@craven.ch> | |
554b8607 | 3 | ;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> |
02394462 | 4 | ;;; Copyright © 2019 Jesse Gildersleve <jessejohngildersleve@protonmail.com> |
935644c0 DC |
5 | ;;; |
6 | ;;; This file is part of GNU Guix. | |
7 | ;;; | |
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. | |
12 | ;;; | |
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. | |
17 | ;;; | |
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/>. | |
20 | ||
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) | |
8cf3e167 | 33 | #:use-module (guix deprecation) |
935644c0 | 34 | #:export (sddm-configuration |
6f30a55c | 35 | sddm-configuration? |
935644c0 DC |
36 | sddm-service-type |
37 | sddm-service)) | |
38 | ||
39 | (define-record-type* <sddm-configuration> | |
40 | sddm-configuration make-sddm-configuration | |
41 | sddm-configuration? | |
42 | (sddm sddm-configuration-sddm | |
43 | (default sddm)) | |
44 | ||
45 | ;; [General] | |
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 | |
49 | (default "x11")) | |
50 | ;; valid values are on, off or none | |
51 | (numlock sddm-configuration-numlock | |
52 | (default "on")) | |
53 | (halt-command sddm-configuration-halt-command | |
9e41130b | 54 | (default (file-append shepherd "/sbin/halt"))) |
935644c0 | 55 | (reboot-command sddm-configuration-reboot-command |
9e41130b | 56 | (default (file-append shepherd "/sbin/reboot"))) |
935644c0 DC |
57 | |
58 | ;; [Theme] | |
59 | ;; valid values are elarun or maldives | |
60 | (theme sddm-configuration-theme | |
61 | (default "maldives")) | |
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")) | |
66 | ||
67 | ;; [Users] | |
68 | (default-path sddm-configuration-default-path | |
69 | (default "/run/current-system/profile/bin")) | |
70 | (minimum-uid sddm-configuration-minimum-uid | |
71 | (default 1000)) | |
72 | (maximum-uid sddm-configuration-maximum-uid | |
73 | (default 2000)) | |
74 | (remember-last-user? sddm-configuration-remember-last-user? | |
75 | (default #t)) | |
76 | (remember-last-session? sddm-configuration-remember-last-session? | |
77 | (default #t)) | |
78 | (hide-users sddm-configuration-hide-users | |
79 | (default "")) | |
80 | (hide-shells sddm-configuration-hide-shells | |
9e41130b | 81 | (default (file-append shadow "/sbin/nologin"))) |
935644c0 DC |
82 | |
83 | ;; [Wayland] | |
84 | (session-command sddm-configuration-session-command | |
9e41130b | 85 | (default (file-append sddm "/share/sddm/scripts/wayland-session"))) |
935644c0 DC |
86 | (sessions-directory sddm-configuration-sessions-directory |
87 | (default "/run/current-system/profile/share/wayland-sessions")) | |
88 | ;; [X11] | |
554b8607 LC |
89 | (xorg-configuration sddm-configuration-xorg |
90 | (default (xorg-configuration))) | |
935644c0 | 91 | (xauth-path sddm-configuration-xauth-path |
9e41130b | 92 | (default (file-append xauth "/bin/xauth"))) |
935644c0 | 93 | (xephyr-path sddm-configuration-xephyr-path |
9e41130b | 94 | (default (file-append xorg-server "/bin/Xephyr"))) |
935644c0 | 95 | (xdisplay-start sddm-configuration-xdisplay-start |
9e41130b | 96 | (default (file-append sddm "/share/sddm/scripts/Xsetup"))) |
935644c0 | 97 | (xdisplay-stop sddm-configuration-xdisplay-stop |
9e41130b | 98 | (default (file-append sddm "/share/sddm/scripts/Xstop"))) |
935644c0 DC |
99 | (xsession-command sddm-configuration-xsession-command |
100 | (default (xinitrc))) | |
101 | (xsessions-directory sddm-configuration-xsessions-directory | |
102 | (default "/run/current-system/profile/share/xsessions")) | |
103 | (minimum-vt sddm-configuration-minimum-vt | |
104 | (default 7)) | |
935644c0 DC |
105 | |
106 | ;; [Autologin] | |
107 | (auto-login-user sddm-configuration-auto-login-user | |
108 | (default "")) | |
109 | ;; valid values are xfce.desktop gnome.desktop weston.desktop hawaii.desktop | |
110 | (auto-login-session sddm-configuration-auto-login-session | |
111 | (default "")) | |
112 | (relogin? sddm-configuration-relogin? | |
113 | (default #f))) | |
114 | ||
115 | (define (sddm-configuration-file config) | |
116 | (mixed-text-file "sddm.conf" " | |
117 | [General] | |
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) " | |
122 | ||
123 | [Users] | |
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) | |
128 | "true" "false") " | |
129 | RememberLastSession=" (if (sddm-configuration-remember-last-session? config) | |
130 | "true" "false") " | |
131 | HideUsers=" (sddm-configuration-hide-users config) " | |
132 | Hideshells=" (sddm-configuration-hide-shells config) " | |
133 | ||
134 | [Theme] | |
135 | Current=" (sddm-configuration-theme config) " | |
136 | ThemeDir=" (sddm-configuration-themes-directory config) " | |
137 | FacesDir=" (sddm-configuration-faces-directory config) " | |
138 | ||
139 | [Wayland] | |
140 | SessionCommand=" (sddm-configuration-session-command config) " | |
141 | SessionDir=" (sddm-configuration-sessions-directory config) " | |
142 | ||
143 | [X11] | |
02394462 | 144 | ServerPath=" (xorg-start-command (sddm-configuration-xorg config)) " |
935644c0 DC |
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)) " | |
554b8607 LC |
152 | ServerArguments=" (string-join |
153 | (xorg-configuration-server-arguments | |
154 | (sddm-configuration-xorg config))) " | |
935644c0 DC |
155 | |
156 | [Autologin] | |
157 | User=" (sddm-configuration-auto-login-user config) " | |
158 | Session=" (sddm-configuration-auto-login-session config) " | |
159 | Relogin=" (if (sddm-configuration-relogin? config) | |
160 | "true" "false") " | |
161 | ")) | |
162 | ||
163 | (define (sddm-shepherd-service config) | |
164 | "Return a <shepherd-service> for sddm with CONFIG." | |
165 | ||
166 | (define sddm-command | |
167 | #~(list (string-append #$(sddm-configuration-sddm config) "/bin/sddm"))) | |
168 | ||
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))))) | |
175 | ||
176 | (define (sddm-etc-service config) | |
177 | (list `("sddm.conf" ,(sddm-configuration-file config)))) | |
178 | ||
ed90104c | 179 | (define (sddm-pam-service config) |
935644c0 DC |
180 | "Return a PAM service for @command{sddm}." |
181 | (pam-service | |
182 | (name "sddm") | |
183 | (auth | |
184 | (list | |
185 | (pam-entry | |
186 | (control "requisite") | |
187 | (module "pam_nologin.so")) | |
188 | (pam-entry | |
189 | (control "required") | |
190 | (module "pam_env.so")) | |
191 | (pam-entry | |
192 | (control "required") | |
193 | (module "pam_succeed_if.so") | |
ed90104c RAM |
194 | (arguments (list (string-append "uid >= " |
195 | (number->string (sddm-configuration-minimum-uid config))) | |
196 | "quiet"))) | |
935644c0 DC |
197 | ;; should be factored out into system-auth |
198 | (pam-entry | |
199 | (control "required") | |
200 | (module "pam_unix.so")))) | |
201 | (account | |
202 | (list | |
203 | ;; should be factored out into system-account | |
204 | (pam-entry | |
205 | (control "required") | |
206 | (module "pam_unix.so")))) | |
207 | (password | |
208 | (list | |
209 | ;; should be factored out into system-password | |
210 | (pam-entry | |
211 | (control "required") | |
212 | (module "pam_unix.so") | |
213 | (arguments (list "sha512" "shadow" "try_first_pass"))))) | |
214 | (session | |
215 | (list | |
216 | ;; lfs has a required pam_limits.so | |
217 | ;; should be factored out into system-session | |
218 | (pam-entry | |
219 | (control "required") | |
220 | (module "pam_unix.so")))))) | |
221 | ||
222 | (define (sddm-greeter-pam-service) | |
223 | "Return a PAM service for @command{sddm-greeter}." | |
224 | (pam-service | |
225 | (name "sddm-greeter") | |
226 | (auth | |
227 | (list | |
d1f30631 | 228 | ;; Load environment from /etc/environment and ~/.pam_environment |
935644c0 DC |
229 | (pam-entry |
230 | (control "required") | |
231 | (module "pam_env.so")) | |
232 | ;; Always let the greeter start without authentication | |
233 | (pam-entry | |
234 | (control "required") | |
235 | (module "pam_permit.so")))) | |
236 | (account | |
237 | (list | |
238 | ;; No action required for account management | |
239 | (pam-entry | |
240 | (control "required") | |
241 | (module "pam_permit.so")))) | |
242 | (password | |
243 | (list | |
244 | ;; Can't change password | |
245 | (pam-entry | |
246 | (control "required") | |
247 | (module "pam_deny.so")))) | |
248 | (session | |
249 | (list | |
250 | ;; Setup session | |
251 | (pam-entry | |
252 | (control "required") | |
253 | (module "pam_unix.so")))))) | |
254 | ||
ed90104c | 255 | (define (sddm-autologin-pam-service config) |
935644c0 DC |
256 | "Return a PAM service for @command{sddm-autologin}" |
257 | (pam-service | |
258 | (name "sddm-autologin") | |
259 | (auth | |
260 | (list | |
261 | (pam-entry | |
262 | (control "requisite") | |
263 | (module "pam_nologin.so")) | |
264 | (pam-entry | |
265 | (control "required") | |
266 | (module "pam_succeed_if.so") | |
ed90104c RAM |
267 | (arguments (list (string-append "uid >= " |
268 | (number->string (sddm-configuration-minimum-uid config))) | |
269 | "quiet"))) | |
935644c0 DC |
270 | (pam-entry |
271 | (control "required") | |
272 | (module "pam_permit.so")))) | |
273 | (account | |
274 | (list | |
275 | (pam-entry | |
276 | (control "include") | |
277 | (module "sddm")))) | |
278 | (password | |
279 | (list | |
280 | (pam-entry | |
281 | (control "required") | |
282 | (module "pam_deny.so")))) | |
283 | (session | |
284 | (list | |
285 | (pam-entry | |
286 | (control "include") | |
287 | (module "sddm")))))) | |
288 | ||
289 | (define (sddm-pam-services config) | |
ed90104c | 290 | (list (sddm-pam-service config) |
935644c0 | 291 | (sddm-greeter-pam-service) |
ed90104c | 292 | (sddm-autologin-pam-service config))) |
935644c0 DC |
293 | |
294 | (define %sddm-accounts | |
295 | (list (user-group (name "sddm") (system? #t)) | |
296 | (user-account | |
297 | (name "sddm") | |
298 | (group "sddm") | |
299 | (system? #t) | |
300 | (comment "SDDM user") | |
301 | (home-directory "/var/lib/sddm") | |
9e41130b | 302 | (shell (file-append shadow "/sbin/nologin"))))) |
935644c0 DC |
303 | |
304 | ;; Add default themes to profile | |
305 | (define sddm-profile-service | |
306 | (compose list sddm-configuration-sddm)) | |
307 | ||
308 | (define sddm-service-type | |
309 | (service-type (name 'sddm) | |
310 | (extensions | |
311 | (list (service-extension shepherd-root-service-type | |
312 | sddm-shepherd-service) | |
313 | (service-extension etc-service-type | |
314 | sddm-etc-service) | |
315 | (service-extension pam-root-service-type | |
316 | sddm-pam-services) | |
317 | (service-extension account-service-type | |
318 | (const %sddm-accounts)) | |
319 | (service-extension profile-service-type | |
5ac5f2c1 | 320 | sddm-profile-service))) |
cfe8d806 LC |
321 | (default-value (sddm-configuration)) |
322 | (description | |
323 | "Run SDDM, a display and log-in manager for X11 and | |
324 | Wayland."))) | |
935644c0 | 325 | |
8cf3e167 LC |
326 | (define-deprecated (sddm-service #:optional (config (sddm-configuration))) |
327 | sddm-service-type | |
935644c0 DC |
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)) |