| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 |
|
| 23 | (define-module (gnu services sddm)
|
| 24 | #:use-module (gnu packages admin)
|
| 25 | #:use-module (gnu packages display-managers)
|
| 26 | #:use-module (gnu packages freedesktop)
|
| 27 | #:use-module (gnu packages xorg)
|
| 28 | #:use-module (gnu services)
|
| 29 | #:use-module (gnu services shepherd)
|
| 30 | #:use-module (gnu services xorg)
|
| 31 | #:use-module (gnu system pam)
|
| 32 | #:use-module (gnu system shadow)
|
| 33 | #:use-module (guix gexp)
|
| 34 | #:use-module (guix records)
|
| 35 | #:use-module (guix deprecation)
|
| 36 | #:use-module (guix utils)
|
| 37 | #:use-module (guix packages)
|
| 38 | #:export (sddm-configuration
|
| 39 | sddm-configuration?
|
| 40 | sddm-service-type
|
| 41 | sddm-service))
|
| 42 |
|
| 43 | (define-record-type* <sddm-configuration>
|
| 44 | sddm-configuration make-sddm-configuration
|
| 45 | sddm-configuration?
|
| 46 | (sddm sddm-configuration-sddm
|
| 47 | (default sddm-qt5))
|
| 48 |
|
| 49 | |
| 50 | |
| 51 | |
| 52 | (display-server sddm-configuration-display-server
|
| 53 | (default "x11"))
|
| 54 | |
| 55 | (numlock sddm-configuration-numlock
|
| 56 | (default "on"))
|
| 57 | (halt-command sddm-configuration-halt-command
|
| 58 | (default (file-append shepherd "/sbin/halt")))
|
| 59 | (reboot-command sddm-configuration-reboot-command
|
| 60 | (default (file-append shepherd "/sbin/reboot")))
|
| 61 |
|
| 62 | |
| 63 | |
| 64 | (theme sddm-configuration-theme
|
| 65 | (default "maldives"))
|
| 66 | (themes-directory sddm-configuration-themes-directory
|
| 67 | (default "/run/current-system/profile/share/sddm/themes"))
|
| 68 | (faces-directory sddm-configuration-faces-directory
|
| 69 | (default "/run/current-system/profile/share/sddm/faces"))
|
| 70 |
|
| 71 | |
| 72 | (default-path sddm-configuration-default-path
|
| 73 | (default "/run/current-system/profile/bin"))
|
| 74 | (minimum-uid sddm-configuration-minimum-uid
|
| 75 | (default 1000))
|
| 76 | (maximum-uid sddm-configuration-maximum-uid
|
| 77 | (default 2000))
|
| 78 | (remember-last-user? sddm-configuration-remember-last-user?
|
| 79 | (default #t))
|
| 80 | (remember-last-session? sddm-configuration-remember-last-session?
|
| 81 | (default #t))
|
| 82 | (hide-users sddm-configuration-hide-users
|
| 83 | (default ""))
|
| 84 | (hide-shells sddm-configuration-hide-shells
|
| 85 | (default (file-append shadow "/sbin/nologin")))
|
| 86 |
|
| 87 | |
| 88 | (session-command sddm-configuration-session-command
|
| 89 | (default (file-append sddm "/share/sddm/scripts/wayland-session")))
|
| 90 | (sessions-directory sddm-configuration-sessions-directory
|
| 91 | (default "/run/current-system/profile/share/wayland-sessions"))
|
| 92 | |
| 93 | (xorg-configuration sddm-configuration-xorg
|
| 94 | (default (xorg-configuration)))
|
| 95 | (xauth-path sddm-configuration-xauth-path
|
| 96 | (default (file-append xauth "/bin/xauth")))
|
| 97 | (xephyr-path sddm-configuration-xephyr-path
|
| 98 | (default (file-append xorg-server "/bin/Xephyr")))
|
| 99 | (xdisplay-start sddm-configuration-xdisplay-start
|
| 100 | (default (file-append sddm "/share/sddm/scripts/Xsetup")))
|
| 101 | (xdisplay-stop sddm-configuration-xdisplay-stop
|
| 102 | (default (file-append sddm "/share/sddm/scripts/Xstop")))
|
| 103 | (xsession-command sddm-configuration-xsession-command
|
| 104 | (default (xinitrc)))
|
| 105 | (xsessions-directory sddm-configuration-xsessions-directory
|
| 106 | (default "/run/current-system/profile/share/xsessions"))
|
| 107 | (minimum-vt sddm-configuration-minimum-vt
|
| 108 | (default 7))
|
| 109 |
|
| 110 | |
| 111 | (auto-login-user sddm-configuration-auto-login-user
|
| 112 | (default ""))
|
| 113 | |
| 114 | (auto-login-session sddm-configuration-auto-login-session
|
| 115 | (default ""))
|
| 116 | (relogin? sddm-configuration-relogin?
|
| 117 | (default #f)))
|
| 118 |
|
| 119 | (define (sddm-configuration-file config)
|
| 120 | (mixed-text-file "sddm.conf" "
|
| 121 | [General]
|
| 122 | DisplayServer=" (sddm-configuration-display-server config) "
|
| 123 | Numlock=" (sddm-configuration-numlock config) "
|
| 124 | HaltCommand=" (sddm-configuration-halt-command config) "
|
| 125 | RebootCommand=" (sddm-configuration-reboot-command config) "
|
| 126 |
|
| 127 | [Users]
|
| 128 | DefaultPath=" (sddm-configuration-default-path config) "
|
| 129 | MinimumUid=" (number->string (sddm-configuration-minimum-uid config))"
|
| 130 | MaximumUid=" (number->string (sddm-configuration-maximum-uid config))"
|
| 131 | RememberLastUser=" (if (sddm-configuration-remember-last-user? config)
|
| 132 | "true" "false") "
|
| 133 | RememberLastSession=" (if (sddm-configuration-remember-last-session? config)
|
| 134 | "true" "false") "
|
| 135 | HideUsers=" (sddm-configuration-hide-users config) "
|
| 136 | Hideshells=" (sddm-configuration-hide-shells config) "
|
| 137 |
|
| 138 | [Theme]
|
| 139 | Current=" (sddm-configuration-theme config) "
|
| 140 | ThemeDir=" (sddm-configuration-themes-directory config) "
|
| 141 | FacesDir=" (sddm-configuration-faces-directory config) "
|
| 142 |
|
| 143 | [Wayland]
|
| 144 | SessionCommand=" (sddm-configuration-session-command config) "
|
| 145 | SessionDir=" (sddm-configuration-sessions-directory config) "
|
| 146 |
|
| 147 | [X11]
|
| 148 | ServerPath=" (xorg-start-command (sddm-configuration-xorg config)) "
|
| 149 | XauthPath=" (sddm-configuration-xauth-path config) "
|
| 150 | XephyrPath=" (sddm-configuration-xephyr-path config) "
|
| 151 | DisplayCommand=" (sddm-configuration-xdisplay-start config) "
|
| 152 | DisplayStopCommand=" (sddm-configuration-xdisplay-stop config) "
|
| 153 | SessionCommand=" (sddm-configuration-xsession-command config) "
|
| 154 | SessionDir=" (sddm-configuration-xsessions-directory config) "
|
| 155 | MinimumVT=" (number->string (sddm-configuration-minimum-vt config)) "
|
| 156 | ServerArguments=" (string-join
|
| 157 | (xorg-configuration-server-arguments
|
| 158 | (sddm-configuration-xorg config))) "
|
| 159 |
|
| 160 | [Autologin]
|
| 161 | User=" (sddm-configuration-auto-login-user config) "
|
| 162 | Session=" (sddm-configuration-auto-login-session config) "
|
| 163 | Relogin=" (if (sddm-configuration-relogin? config)
|
| 164 | "true" "false") "
|
| 165 | "))
|
| 166 |
|
| 167 | (define (sddm-shepherd-service config)
|
| 168 | "Return a <shepherd-service> for sddm with CONFIG."
|
| 169 |
|
| 170 | (define sddm (sddm-configuration-sddm config))
|
| 171 | (define qt6? (version-prefix?
|
| 172 | "6"
|
| 173 | (package-version (lookup-package-input sddm "qtbase"))))
|
| 174 |
|
| 175 | (define sddm-command
|
| 176 | #~(list (string-append #$sddm "/bin/sddm")))
|
| 177 |
|
| 178 | (list (shepherd-service
|
| 179 | (documentation "SDDM display manager.")
|
| 180 | (requirement '(user-processes elogind pam))
|
| 181 | (provision '(xorg-server display-manager))
|
| 182 | (start #~(make-forkexec-constructor
|
| 183 | #$sddm-command
|
| 184 | |
| 185 | #:environment-variables
|
| 186 | (cons*
|
| 187 | "XDG_DATA_DIRS=/run/current-system/profile/share"
|
| 188 | "XDG_CONFIG_DIRS=/run/current-system/profile/etc/xdg"
|
| 189 | #$(string-append "QT_PLUGIN_PATH=/run/current-system/profile/lib/qt"
|
| 190 | (if qt6? "6" "5")
|
| 191 | "/plugins")
|
| 192 | #$(string-append "QML" (if qt6? "" "2")
|
| 193 | "_IMPORT_PATH=/run/current-system/profile/lib/qt"
|
| 194 | (if qt6? "6" "5") "/qml")
|
| 195 | (default-environment-variables))))
|
| 196 | (stop #~(make-kill-destructor)))))
|
| 197 |
|
| 198 | (define (sddm-etc-service config)
|
| 199 | (list `("sddm.conf" ,(sddm-configuration-file config))))
|
| 200 |
|
| 201 | (define (sddm-pam-service config)
|
| 202 | "Return a PAM service for @command{sddm}."
|
| 203 | (pam-service
|
| 204 | (name "sddm")
|
| 205 | (auth
|
| 206 | (list
|
| 207 | (pam-entry
|
| 208 | (control "requisite")
|
| 209 | (module "pam_nologin.so"))
|
| 210 | (pam-entry
|
| 211 | (control "required")
|
| 212 | (module "pam_env.so"))
|
| 213 | (pam-entry
|
| 214 | (control "required")
|
| 215 | (module "pam_succeed_if.so")
|
| 216 | (arguments (list (string-append "uid >= "
|
| 217 | (number->string (sddm-configuration-minimum-uid config)))
|
| 218 | "quiet")))
|
| 219 | |
| 220 | (pam-entry
|
| 221 | (control "required")
|
| 222 | (module "pam_unix.so"))))
|
| 223 | (account
|
| 224 | (list
|
| 225 | |
| 226 | (pam-entry
|
| 227 | (control "required")
|
| 228 | (module "pam_unix.so"))))
|
| 229 | (password
|
| 230 | (list
|
| 231 | |
| 232 | (pam-entry
|
| 233 | (control "required")
|
| 234 | (module "pam_unix.so")
|
| 235 | (arguments (list "sha512" "shadow" "try_first_pass")))))
|
| 236 | (session
|
| 237 | (list
|
| 238 | (pam-entry
|
| 239 | (control "required")
|
| 240 | (module "pam_env.so")) |
| 241 | |
| 242 | |
| 243 | (pam-entry
|
| 244 | (control "required")
|
| 245 | (module "pam_unix.so"))))))
|
| 246 |
|
| 247 | (define (sddm-greeter-pam-service)
|
| 248 | "Return a PAM service for @command{sddm-greeter}."
|
| 249 | (pam-service
|
| 250 | (name "sddm-greeter")
|
| 251 | (auth
|
| 252 | (list
|
| 253 | |
| 254 | (pam-entry
|
| 255 | (control "required")
|
| 256 | (module "pam_env.so"))
|
| 257 | |
| 258 | (pam-entry
|
| 259 | (control "required")
|
| 260 | (module "pam_permit.so"))))
|
| 261 | (account
|
| 262 | (list
|
| 263 | |
| 264 | (pam-entry
|
| 265 | (control "required")
|
| 266 | (module "pam_permit.so"))))
|
| 267 | (password
|
| 268 | (list
|
| 269 | |
| 270 | (pam-entry
|
| 271 | (control "required")
|
| 272 | (module "pam_deny.so"))))
|
| 273 | (session
|
| 274 | (list
|
| 275 | |
| 276 | (pam-entry
|
| 277 | (control "required")
|
| 278 | (module "pam_unix.so"))))))
|
| 279 |
|
| 280 | (define (sddm-autologin-pam-service config)
|
| 281 | "Return a PAM service for @command{sddm-autologin}"
|
| 282 | (pam-service
|
| 283 | (name "sddm-autologin")
|
| 284 | (auth
|
| 285 | (list
|
| 286 | (pam-entry
|
| 287 | (control "requisite")
|
| 288 | (module "pam_nologin.so"))
|
| 289 | (pam-entry
|
| 290 | (control "required")
|
| 291 | (module "pam_succeed_if.so")
|
| 292 | (arguments (list (string-append "uid >= "
|
| 293 | (number->string (sddm-configuration-minimum-uid config)))
|
| 294 | "quiet")))
|
| 295 | (pam-entry
|
| 296 | (control "required")
|
| 297 | (module "pam_permit.so"))))
|
| 298 | (account
|
| 299 | (list
|
| 300 | (pam-entry
|
| 301 | (control "include")
|
| 302 | (module "sddm"))))
|
| 303 | (password
|
| 304 | (list
|
| 305 | (pam-entry
|
| 306 | (control "required")
|
| 307 | (module "pam_deny.so"))))
|
| 308 | (session
|
| 309 | (list
|
| 310 | (pam-entry
|
| 311 | (control "include")
|
| 312 | (module "sddm"))))))
|
| 313 |
|
| 314 | (define (sddm-pam-services config)
|
| 315 | (list (sddm-pam-service config)
|
| 316 | (sddm-greeter-pam-service)
|
| 317 | (sddm-autologin-pam-service config)))
|
| 318 |
|
| 319 | (define %sddm-accounts
|
| 320 | (list (user-group (name "sddm") (system? #t))
|
| 321 | (user-account
|
| 322 | (name "sddm")
|
| 323 | (group "sddm")
|
| 324 | (system? #t)
|
| 325 | (comment "SDDM user")
|
| 326 | (home-directory "/var/lib/sddm")
|
| 327 | (shell (file-append shadow "/sbin/nologin")))))
|
| 328 |
|
| 329 | |
| 330 | (define sddm-profile-service
|
| 331 | (compose list sddm-configuration-sddm))
|
| 332 |
|
| 333 | (define sddm-service-type
|
| 334 | (handle-xorg-configuration sddm-configuration
|
| 335 | (service-type (name 'sddm)
|
| 336 | (extensions
|
| 337 | (list (service-extension shepherd-root-service-type
|
| 338 | sddm-shepherd-service)
|
| 339 | (service-extension etc-service-type
|
| 340 | sddm-etc-service)
|
| 341 | (service-extension pam-root-service-type
|
| 342 | sddm-pam-services)
|
| 343 | (service-extension account-service-type
|
| 344 | (const %sddm-accounts))
|
| 345 | (service-extension profile-service-type
|
| 346 | sddm-profile-service)
|
| 347 | (service-extension localed-service-type
|
| 348 | (compose
|
| 349 | xorg-configuration-keyboard-layout
|
| 350 | sddm-configuration-xorg))))
|
| 351 | (default-value (sddm-configuration))
|
| 352 | (description
|
| 353 | "Run SDDM, a display and log-in manager for X11 and
|
| 354 | Wayland."))))
|