Commit | Line | Data |
---|---|---|
935644c0 DC |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2016 David Craven <david@craven.ch> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | ;;; under the terms of the GNU General Public License as published by | |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (gnu services sddm) | |
20 | #:use-module (gnu packages admin) | |
21 | #:use-module (gnu packages display-managers) | |
22 | #:use-module (gnu packages freedesktop) | |
23 | #:use-module (gnu packages xorg) | |
24 | #:use-module (gnu services) | |
25 | #:use-module (gnu services shepherd) | |
26 | #:use-module (gnu services xorg) | |
27 | #:use-module (gnu system pam) | |
28 | #:use-module (gnu system shadow) | |
29 | #:use-module (guix gexp) | |
30 | #:use-module (guix records) | |
31 | #:export (sddm-configuration | |
32 | sddm-confiugration? | |
33 | sddm-service-type | |
34 | sddm-service)) | |
35 | ||
36 | (define-record-type* <sddm-configuration> | |
37 | sddm-configuration make-sddm-configuration | |
38 | sddm-configuration? | |
39 | (sddm sddm-configuration-sddm | |
40 | (default sddm)) | |
41 | ||
42 | ;; [General] | |
43 | ;; valid values are x11 and wayland | |
44 | ;; currently doesn't do anything is enabled by wayland greeter PR | |
45 | (display-server sddm-configuration-display-server | |
46 | (default "x11")) | |
47 | ;; valid values are on, off or none | |
48 | (numlock sddm-configuration-numlock | |
49 | (default "on")) | |
50 | (halt-command sddm-configuration-halt-command | |
51 | (default #~(string-append #$shepherd "/sbin/halt"))) | |
52 | (reboot-command sddm-configuration-reboot-command | |
53 | (default #~(string-append #$shepherd "/sbin/reboot"))) | |
54 | ||
55 | ;; [Theme] | |
56 | ;; valid values are elarun or maldives | |
57 | (theme sddm-configuration-theme | |
58 | (default "maldives")) | |
59 | (themes-directory sddm-configuration-themes-directory | |
60 | (default "/run/current-system/profile/share/sddm/themes")) | |
61 | (faces-directory sddm-configuration-faces-directory | |
62 | (default "/run/current-system/profile/share/sddm/faces")) | |
63 | ||
64 | ;; [Users] | |
65 | (default-path sddm-configuration-default-path | |
66 | (default "/run/current-system/profile/bin")) | |
67 | (minimum-uid sddm-configuration-minimum-uid | |
68 | (default 1000)) | |
69 | (maximum-uid sddm-configuration-maximum-uid | |
70 | (default 2000)) | |
71 | (remember-last-user? sddm-configuration-remember-last-user? | |
72 | (default #t)) | |
73 | (remember-last-session? sddm-configuration-remember-last-session? | |
74 | (default #t)) | |
75 | (hide-users sddm-configuration-hide-users | |
76 | (default "")) | |
77 | (hide-shells sddm-configuration-hide-shells | |
78 | (default #~(string-append #$shadow "/sbin/nologin"))) | |
79 | ||
80 | ;; [Wayland] | |
81 | (session-command sddm-configuration-session-command | |
82 | (default #~(string-append #$sddm "/share/sddm/scripts/wayland-session"))) | |
83 | (sessions-directory sddm-configuration-sessions-directory | |
84 | (default "/run/current-system/profile/share/wayland-sessions")) | |
85 | ;; [X11] | |
86 | (xorg-server-path sddm-configuration-xorg-server-path | |
87 | (default (xorg-start-command))) | |
88 | (xauth-path sddm-configuration-xauth-path | |
89 | (default #~(string-append #$xauth "/bin/xauth"))) | |
90 | (xephyr-path sddm-configuration-xephyr-path | |
91 | (default #~(string-append #$xorg-server "/bin/Xephyr"))) | |
92 | (xdisplay-start sddm-configuration-xdisplay-start | |
93 | (default #~(string-append #$sddm "/share/sddm/scripts/Xsetup"))) | |
94 | (xdisplay-stop sddm-configuration-xdisplay-stop | |
95 | (default #~(string-append #$sddm "/share/sddm/scripts/Xstop"))) | |
96 | (xsession-command sddm-configuration-xsession-command | |
97 | (default (xinitrc))) | |
98 | (xsessions-directory sddm-configuration-xsessions-directory | |
99 | (default "/run/current-system/profile/share/xsessions")) | |
100 | (minimum-vt sddm-configuration-minimum-vt | |
101 | (default 7)) | |
102 | (xserver-arguments sddm-configuration-xserver-arguments | |
103 | (default "-nolisten tcp")) | |
104 | ||
105 | ;; [Autologin] | |
106 | (auto-login-user sddm-configuration-auto-login-user | |
107 | (default "")) | |
108 | ;; valid values are xfce.desktop gnome.desktop weston.desktop hawaii.desktop | |
109 | (auto-login-session sddm-configuration-auto-login-session | |
110 | (default "")) | |
111 | (relogin? sddm-configuration-relogin? | |
112 | (default #f))) | |
113 | ||
114 | (define (sddm-configuration-file config) | |
115 | (mixed-text-file "sddm.conf" " | |
116 | [General] | |
117 | DisplayServer=" (sddm-configuration-display-server config) " | |
118 | Numlock=" (sddm-configuration-numlock config) " | |
119 | HaltCommand=" (sddm-configuration-halt-command config) " | |
120 | RebootCommand=" (sddm-configuration-reboot-command config) " | |
121 | ||
122 | [Users] | |
123 | DefaultPath=" (sddm-configuration-default-path config) " | |
124 | MinimumUid=" (number->string (sddm-configuration-minimum-uid config))" | |
125 | MaximumUid=" (number->string (sddm-configuration-maximum-uid config))" | |
126 | RememberLastUser=" (if (sddm-configuration-remember-last-user? config) | |
127 | "true" "false") " | |
128 | RememberLastSession=" (if (sddm-configuration-remember-last-session? config) | |
129 | "true" "false") " | |
130 | HideUsers=" (sddm-configuration-hide-users config) " | |
131 | Hideshells=" (sddm-configuration-hide-shells config) " | |
132 | ||
133 | [Theme] | |
134 | Current=" (sddm-configuration-theme config) " | |
135 | ThemeDir=" (sddm-configuration-themes-directory config) " | |
136 | FacesDir=" (sddm-configuration-faces-directory config) " | |
137 | ||
138 | [Wayland] | |
139 | SessionCommand=" (sddm-configuration-session-command config) " | |
140 | SessionDir=" (sddm-configuration-sessions-directory config) " | |
141 | ||
142 | [X11] | |
143 | ServerPath=" (sddm-configuration-xorg-server-path config) " | |
144 | XauthPath=" (sddm-configuration-xauth-path config) " | |
145 | XephyrPath=" (sddm-configuration-xephyr-path config) " | |
146 | DisplayCommand=" (sddm-configuration-xdisplay-start config) " | |
147 | DisplayStopCommand=" (sddm-configuration-xdisplay-stop config) " | |
148 | SessionCommand=" (sddm-configuration-xsession-command config) " | |
149 | SessionDir=" (sddm-configuration-xsessions-directory config) " | |
150 | MinimumVT=" (number->string (sddm-configuration-minimum-vt config)) " | |
151 | ServerArguments=" (sddm-configuration-xserver-arguments config) " | |
152 | ||
153 | [Autologin] | |
154 | User=" (sddm-configuration-auto-login-user config) " | |
155 | Session=" (sddm-configuration-auto-login-session config) " | |
156 | Relogin=" (if (sddm-configuration-relogin? config) | |
157 | "true" "false") " | |
158 | ")) | |
159 | ||
160 | (define (sddm-shepherd-service config) | |
161 | "Return a <shepherd-service> for sddm with CONFIG." | |
162 | ||
163 | (define sddm-command | |
164 | #~(list (string-append #$(sddm-configuration-sddm config) "/bin/sddm"))) | |
165 | ||
166 | (list (shepherd-service | |
167 | (documentation "SDDM display manager.") | |
168 | (requirement '(user-processes)) | |
169 | (provision '(display-manager)) | |
170 | (start #~(make-forkexec-constructor #$sddm-command)) | |
171 | (stop #~(make-kill-destructor))))) | |
172 | ||
173 | (define (sddm-etc-service config) | |
174 | (list `("sddm.conf" ,(sddm-configuration-file config)))) | |
175 | ||
176 | (define (sddm-pam-service) | |
177 | "Return a PAM service for @command{sddm}." | |
178 | (pam-service | |
179 | (name "sddm") | |
180 | (auth | |
181 | (list | |
182 | (pam-entry | |
183 | (control "requisite") | |
184 | (module "pam_nologin.so")) | |
185 | (pam-entry | |
186 | (control "required") | |
187 | (module "pam_env.so")) | |
188 | (pam-entry | |
189 | (control "required") | |
190 | (module "pam_succeed_if.so") | |
191 | (arguments (list "uid >= 1000" "quiet"))) | |
192 | ;; should be factored out into system-auth | |
193 | (pam-entry | |
194 | (control "required") | |
195 | (module "pam_unix.so")))) | |
196 | (account | |
197 | (list | |
198 | ;; should be factored out into system-account | |
199 | (pam-entry | |
200 | (control "required") | |
201 | (module "pam_unix.so")))) | |
202 | (password | |
203 | (list | |
204 | ;; should be factored out into system-password | |
205 | (pam-entry | |
206 | (control "required") | |
207 | (module "pam_unix.so") | |
208 | (arguments (list "sha512" "shadow" "try_first_pass"))))) | |
209 | (session | |
210 | (list | |
211 | ;; lfs has a required pam_limits.so | |
212 | ;; should be factored out into system-session | |
213 | (pam-entry | |
214 | (control "required") | |
215 | (module "pam_unix.so")))))) | |
216 | ||
217 | (define (sddm-greeter-pam-service) | |
218 | "Return a PAM service for @command{sddm-greeter}." | |
219 | (pam-service | |
220 | (name "sddm-greeter") | |
221 | (auth | |
222 | (list | |
223 | ;; Load environment form /etc/environment and ~/.pam_environment | |
224 | (pam-entry | |
225 | (control "required") | |
226 | (module "pam_env.so")) | |
227 | ;; Always let the greeter start without authentication | |
228 | (pam-entry | |
229 | (control "required") | |
230 | (module "pam_permit.so")))) | |
231 | (account | |
232 | (list | |
233 | ;; No action required for account management | |
234 | (pam-entry | |
235 | (control "required") | |
236 | (module "pam_permit.so")))) | |
237 | (password | |
238 | (list | |
239 | ;; Can't change password | |
240 | (pam-entry | |
241 | (control "required") | |
242 | (module "pam_deny.so")))) | |
243 | (session | |
244 | (list | |
245 | ;; Setup session | |
246 | (pam-entry | |
247 | (control "required") | |
248 | (module "pam_unix.so")))))) | |
249 | ||
250 | (define (sddm-autologin-pam-service) | |
251 | "Return a PAM service for @command{sddm-autologin}" | |
252 | (pam-service | |
253 | (name "sddm-autologin") | |
254 | (auth | |
255 | (list | |
256 | (pam-entry | |
257 | (control "requisite") | |
258 | (module "pam_nologin.so")) | |
259 | (pam-entry | |
260 | (control "required") | |
261 | (module "pam_succeed_if.so") | |
262 | (arguments (list "uid >= 1000" "quiet"))) | |
263 | (pam-entry | |
264 | (control "required") | |
265 | (module "pam_permit.so")))) | |
266 | (account | |
267 | (list | |
268 | (pam-entry | |
269 | (control "include") | |
270 | (module "sddm")))) | |
271 | (password | |
272 | (list | |
273 | (pam-entry | |
274 | (control "required") | |
275 | (module "pam_deny.so")))) | |
276 | (session | |
277 | (list | |
278 | (pam-entry | |
279 | (control "include") | |
280 | (module "sddm")))))) | |
281 | ||
282 | (define (sddm-pam-services config) | |
283 | (list (sddm-pam-service) | |
284 | (sddm-greeter-pam-service) | |
285 | (sddm-autologin-pam-service))) | |
286 | ||
287 | (define %sddm-accounts | |
288 | (list (user-group (name "sddm") (system? #t)) | |
289 | (user-account | |
290 | (name "sddm") | |
291 | (group "sddm") | |
292 | (system? #t) | |
293 | (comment "SDDM user") | |
294 | (home-directory "/var/lib/sddm") | |
295 | (shell #~(string-append #$shadow "/sbin/nologin"))))) | |
296 | ||
297 | ;; Add default themes to profile | |
298 | (define sddm-profile-service | |
299 | (compose list sddm-configuration-sddm)) | |
300 | ||
301 | (define sddm-service-type | |
302 | (service-type (name 'sddm) | |
303 | (extensions | |
304 | (list (service-extension shepherd-root-service-type | |
305 | sddm-shepherd-service) | |
306 | (service-extension etc-service-type | |
307 | sddm-etc-service) | |
308 | (service-extension pam-root-service-type | |
309 | sddm-pam-services) | |
310 | (service-extension account-service-type | |
311 | (const %sddm-accounts)) | |
312 | (service-extension profile-service-type | |
313 | sddm-profile-service))))) | |
314 | ||
315 | (define* (sddm-service #:optional (config (sddm-configuration))) | |
316 | "Run the @uref{https://github.com/sddm/sddm,SSDM display manager} | |
317 | with the given @var{config}, a @code{<sddm-configuration>} object." | |
318 | (service sddm-service-type config)) |