Subject: bug#52908: 'tests/guix-system.sh' fails on aarch64-linux

From: Chris Marusich <[email-masked]>
Date: Mon, 03 Jan 2022 18:15:52 -0800

Hi Leo and Aiko,

This issue also affects powerpc64le-linux.

Aiko's patch would indeed fix the failing test.  Thank you, Aiko, for
taking the initiative to help investigate and solve the issue!  However,
even though that patch would fix the test, anyone who is using
set-xorg-configuration on a non-x86_64 system would still need to change
the way they call it, which is not ideal.

I've attached a different patch that attempts to fix the issue without
requiring callers of set-xorg-configuration to update their code.  I
believe this is more consistent with the intent of Ludo's original
change in commit 49599fab564f203b8e92d32e9b28c99e99849bfb.

You'll notice that this patch moves the (gnu services sddm) code into
(gnu services xorg) and deprecates (gnu services sddm).  I did this in
order to avoid a circular dependency between the two modules.  Perhaps
there's a better way.  However, many of the existing display managers
already live in (gnu services xorg), so it seemed reasonable to me.

I've verified that the tests/guix-system.sh test passes on
powerpc64le-linux after applying this patch to current master branch (on
top of commit 9309b488ca4ceef4fcc9283546e3b05c57b16ca8).  I've also
verified that the deprecation warnings are being emitted, and that the
existing bindings in (gnu services sddm) are still usable, at the REPL:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix repl
GNU Guile 3.0.7
Copyright (C) 1995-2021 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use (gnu services sddm)
scheme@(guix-user)> (sddm-configuration)
guix repl: warning: 'sddm-configuration' is deprecated, use '(@ (gnu services xorg) sddm-configuration)' instead
$1 = #<<sddm-configuration> sddm: [... omitted for brevity ...]
scheme@(guix-user)> (sddm-configuration? $1)
guix repl: warning: 'sddm-configuration?' is deprecated, use '(@ (gnu services xorg) sddm-configuration?)' instead
$2 = #t
scheme@(guix-user)> sddm-service-type
guix repl: warning: 'sddm-service-type' is deprecated, use '(@ (gnu services xorg) sddm-service-type)' instead
$3 = #<service-type sddm 4b3812c0>
scheme@(guix-user)> (sddm-service)
guix repl: warning: 'sddm-service' is deprecated, use '(@ (gnu services xorg) sddm-service)' instead
guix repl: warning: 'sddm-service' is deprecated, use 'sddm-service-type' instead
$4 = #<<service> type: #<service-type sddm 4b3812c0> value:
#<<sddm-configuration> sddm: [... omitted for brevity ...]
scheme@(guix-user)>
--8<---------------cut here---------------end--------------->8---

What do you think?

-- 
Chris

PGP: https://savannah.gnu.org/people/viewgpg.php?user_id=106836
From 09091cc8495e0b4c302a58961e79ac8455ecd208 Mon Sep 17 00:00:00 2001
From: Chris Marusich <[email-masked]>
Date: Mon, 3 Jan 2022 14:59:35 -0800
Subject: [PATCH] services: Consistently use SDDM rather than GDM on
 non-x86_64.

This is a follow-up to 49599fab564f203b8e92d32e9b28c99e99849bfb.  Notably, it
also deprecates (gnu services sddm) and moves what was there into (gnu
services xorg).

Fixes: <https://issues.guix.gnu.org/52908>.

* gnu/services/sddm.scm (sddm-configuration, sddm-configuration?)
(sddm-service-type, sddm-service): Move the code for these exported bindings
to gnu/services/xorg.scm.  Use (guix deprecation) to ensure that existing code
can continue to call these original bindings in the (gnu services sddm)
module, in which case a deprecation warning will be issued to the caller.
(gnu-services-sddm-sentinel): New exported variable.
* gnu/services/xorg.scm (sddm-configuration, sddm-configuration?)
(sddm-service-type, sddm-service): New exported bindings.  The code was moved
verbatim from gnu/services/sddm.scm.  These bindings were moved here to avoid
introducing a circular dependency between the (gnu services sddm) and (gnu
services xorg) modules.
(set-xorg-configuration)[login-manager-service-type]: When the current system
or target system begins with the string "x86_64", use gdm-service type as
before; otherwise, use sddm-service-type (i.e., the one from the (gnu services
xorg) module).
* gnu/system/examples/vm-image.tmpl (services): Add sddm-service-type to the
list of service types to remove.
* gnu/services/desktop.scm: Remove the #:autoload for (gnu services sddm).  It
is no longer required, since (gnu services xorg) exports sddm-service-type.
---
 gnu/services/desktop.scm          |   1 -
 gnu/services/sddm.scm             | 320 ++----------------------------
 gnu/services/xorg.scm             | 311 ++++++++++++++++++++++++++++-
 gnu/system/examples/vm-image.tmpl |   4 +-
 4 files changed, 332 insertions(+), 304 deletions(-)

diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index c6761ca784..8395b51242 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -40,7 +40,6 @@
   #:use-module (gnu services sound)
   #:use-module ((gnu system file-systems)
                 #:select (%elogind-file-systems file-system))
-  #:autoload   (gnu services sddm) (sddm-service-type)
   #:use-module (gnu system)
   #:use-module (gnu system setuid)
   #:use-module (gnu system shadow)
diff --git a/gnu/services/sddm.scm b/gnu/services/sddm.scm
index 694ad736dc..54c0f1b594 100644
--- a/gnu/services/sddm.scm
+++ b/gnu/services/sddm.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2019 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2019 Jesse Gildersleve <[email-masked]>
 ;;; Copyright © 2020 Jakub Kądziołka <[email-masked]>
+;;; Copyright © 2022 Chris Marusich <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,313 +21,32 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu services sddm)
-  #:use-module (gnu packages admin)
-  #:use-module (gnu packages display-managers)
-  #:use-module (gnu packages freedesktop)
-  #:use-module (gnu packages xorg)
-  #:use-module (gnu services)
-  #:use-module (gnu services shepherd)
-  #:use-module (gnu services xorg)
-  #:use-module (gnu system pam)
-  #:use-module (gnu system shadow)
-  #:use-module (guix gexp)
-  #:use-module (guix records)
   #:use-module (guix deprecation)
+  #:use-module (gnu services xorg)
   #:export (sddm-configuration
             sddm-configuration?
             sddm-service-type
-            sddm-service))
-
-(define-record-type* <sddm-configuration>
-  sddm-configuration      make-sddm-configuration
-  sddm-configuration?
-  (sddm                   sddm-configuration-sddm
-                          (default sddm))
-
-  ;; [General]
-  ;; valid values are x11 and wayland
-  ;; currently doesn't do anything is enabled by wayland greeter PR
-  (display-server         sddm-configuration-display-server
-                          (default "x11"))
-  ;; valid values are on, off or none
-  (numlock                sddm-configuration-numlock
-                          (default "on"))
-  (halt-command           sddm-configuration-halt-command
-                          (default (file-append shepherd "/sbin/halt")))
-  (reboot-command         sddm-configuration-reboot-command
-                          (default (file-append shepherd "/sbin/reboot")))
-
-  ;; [Theme]
-  ;; valid values are elarun, maldives or maya
-  (theme                  sddm-configuration-theme
-                          (default "maldives"))
-  (themes-directory       sddm-configuration-themes-directory
-                          (default "/run/current-system/profile/share/sddm/themes"))
-  (faces-directory        sddm-configuration-faces-directory
-                          (default "/run/current-system/profile/share/sddm/faces"))
-
-  ;; [Users]
-  (default-path           sddm-configuration-default-path
-                          (default "/run/current-system/profile/bin"))
-  (minimum-uid            sddm-configuration-minimum-uid
-                          (default 1000))
-  (maximum-uid            sddm-configuration-maximum-uid
-                          (default 2000))
-  (remember-last-user?    sddm-configuration-remember-last-user?
-                          (default #t))
-  (remember-last-session? sddm-configuration-remember-last-session?
-                          (default #t))
-  (hide-users             sddm-configuration-hide-users
-                          (default ""))
-  (hide-shells            sddm-configuration-hide-shells
-                          (default (file-append shadow "/sbin/nologin")))
-
-  ;; [Wayland]
-  (session-command        sddm-configuration-session-command
-                          (default (file-append sddm "/share/sddm/scripts/wayland-session")))
-  (sessions-directory     sddm-configuration-sessions-directory
-                          (default "/run/current-system/profile/share/wayland-sessions"))
-  ;; [X11]
-  (xorg-configuration     sddm-configuration-xorg
-                          (default (xorg-configuration)))
-  (xauth-path             sddm-configuration-xauth-path
-                          (default (file-append xauth "/bin/xauth")))
-  (xephyr-path            sddm-configuration-xephyr-path
-                          (default (file-append xorg-server "/bin/Xephyr")))
-  (xdisplay-start         sddm-configuration-xdisplay-start
-                          (default (file-append sddm "/share/sddm/scripts/Xsetup")))
-  (xdisplay-stop          sddm-configuration-xdisplay-stop
-                          (default (file-append sddm "/share/sddm/scripts/Xstop")))
-  (xsession-command       sddm-configuration-xsession-command
-                          (default (xinitrc)))
-  (xsessions-directory    sddm-configuration-xsessions-directory
-                          (default "/run/current-system/profile/share/xsessions"))
-  (minimum-vt             sddm-configuration-minimum-vt
-                          (default 7))
-
-  ;; [Autologin]
-  (auto-login-user        sddm-configuration-auto-login-user
-                          (default ""))
-  ;; valid values are xfce.desktop gnome.desktop weston.desktop hawaii.desktop
-  (auto-login-session     sddm-configuration-auto-login-session
-                          (default ""))
-  (relogin?               sddm-configuration-relogin?
-                          (default #f)))
-
-(define (sddm-configuration-file config)
-  (mixed-text-file "sddm.conf" "
-[General]
-DisplayServer="        (sddm-configuration-display-server config)              "
-Numlock="              (sddm-configuration-numlock config)                     "
-HaltCommand="          (sddm-configuration-halt-command config)                "
-RebootCommand="        (sddm-configuration-reboot-command config)              "
-
-[Users]
-DefaultPath="          (sddm-configuration-default-path config)                "
-MinimumUid="           (number->string (sddm-configuration-minimum-uid config))"
-MaximumUid="           (number->string (sddm-configuration-maximum-uid config))"
-RememberLastUser="     (if (sddm-configuration-remember-last-user? config)
-                           "true" "false")                                     "
-RememberLastSession="  (if (sddm-configuration-remember-last-session? config)
-                           "true" "false")                                     "
-HideUsers="            (sddm-configuration-hide-users config)                  "
-Hideshells="           (sddm-configuration-hide-shells config)                 "
-
-[Theme]
-Current="              (sddm-configuration-theme config)                       "
-ThemeDir="             (sddm-configuration-themes-directory config)            "
-FacesDir="             (sddm-configuration-faces-directory config)             "
-
-[Wayland]
-SessionCommand="       (sddm-configuration-session-command config)             "
-SessionDir="           (sddm-configuration-sessions-directory config)          "
-
-[X11]
-ServerPath="           (xorg-start-command (sddm-configuration-xorg config))   "
-XauthPath="            (sddm-configuration-xauth-path config)                  "
-XephyrPath="           (sddm-configuration-xephyr-path config)                 "
-DisplayCommand="       (sddm-configuration-xdisplay-start config)              "
-DisplayStopCommand="   (sddm-configuration-xdisplay-stop config)               "
-SessionCommand="       (sddm-configuration-xsession-command config)            "
-SessionDir="           (sddm-configuration-xsessions-directory config)         "
-MinimumVT="            (number->string (sddm-configuration-minimum-vt config)) "
-ServerArguments="      (string-join
-                        (xorg-configuration-server-arguments
-                         (sddm-configuration-xorg config)))           "
-
-[Autologin]
-User="                 (sddm-configuration-auto-login-user config)             "
-Session="              (sddm-configuration-auto-login-session config)          "
-Relogin="              (if (sddm-configuration-relogin? config)
-                           "true" "false")                                     "
-"))
-
-(define (sddm-shepherd-service config)
-  "Return a <shepherd-service> for sddm with CONFIG."
-
-  (define sddm-command
-    #~(list (string-append #$(sddm-configuration-sddm config) "/bin/sddm")))
-
-  (list (shepherd-service
-         (documentation "SDDM display manager.")
-         (requirement '(user-processes elogind))
-         (provision '(xorg-server display-manager))
-         (start #~(make-forkexec-constructor #$sddm-command))
-         (stop #~(make-kill-destructor)))))
-
-(define (sddm-etc-service config)
-  (list `("sddm.conf" ,(sddm-configuration-file config))))
-
-(define (sddm-pam-service config)
-  "Return a PAM service for @command{sddm}."
-  (pam-service
-   (name "sddm")
-   (auth
-    (list
-     (pam-entry
-      (control "requisite")
-      (module "pam_nologin.so"))
-     (pam-entry
-      (control "required")
-      (module "pam_env.so"))
-     (pam-entry
-      (control "required")
-      (module "pam_succeed_if.so")
-      (arguments (list (string-append "uid >= "
-                                      (number->string (sddm-configuration-minimum-uid config)))
-                       "quiet")))
-     ;; should be factored out into system-auth
-     (pam-entry
-      (control "required")
-      (module "pam_unix.so"))))
-   (account
-    (list
-     ;; should be factored out into system-account
-     (pam-entry
-      (control "required")
-      (module "pam_unix.so"))))
-   (password
-    (list
-     ;; should be factored out into system-password
-     (pam-entry
-      (control "required")
-      (module "pam_unix.so")
-      (arguments (list "sha512" "shadow" "try_first_pass")))))
-   (session
-    (list
-     ;; lfs has a required pam_limits.so
-     ;; should be factored out into system-session
-     (pam-entry
-      (control "required")
-      (module "pam_unix.so"))))))
-
-(define (sddm-greeter-pam-service)
-  "Return a PAM service for @command{sddm-greeter}."
-  (pam-service
-   (name "sddm-greeter")
-   (auth
-    (list
-     ;; Load environment from /etc/environment and ~/.pam_environment
-     (pam-entry
-      (control "required")
-      (module "pam_env.so"))
-     ;; Always let the greeter start without authentication
-     (pam-entry
-      (control "required")
-      (module "pam_permit.so"))))
-   (account
-    (list
-     ;; No action required for account management
-     (pam-entry
-      (control "required")
-      (module "pam_permit.so"))))
-   (password
-    (list
-     ;; Can't change password
-     (pam-entry
-      (control "required")
-      (module "pam_deny.so"))))
-   (session
-    (list
-     ;; Setup session
-     (pam-entry
-      (control "required")
-      (module "pam_unix.so"))))))
+            sddm-service
+            gnu-services-sddm-sentinel))
 
-(define (sddm-autologin-pam-service config)
-  "Return a PAM service for @command{sddm-autologin}"
-  (pam-service
-   (name "sddm-autologin")
-   (auth
-    (list
-     (pam-entry
-      (control "requisite")
-      (module "pam_nologin.so"))
-     (pam-entry
-      (control "required")
-      (module "pam_succeed_if.so")
-      (arguments (list (string-append "uid >= "
-                                      (number->string (sddm-configuration-minimum-uid config)))
-                       "quiet")))
-     (pam-entry
-      (control "required")
-      (module "pam_permit.so"))))
-   (account
-    (list
-     (pam-entry
-      (control "include")
-      (module "sddm"))))
-   (password
-    (list
-     (pam-entry
-      (control "required")
-      (module "pam_deny.so"))))
-   (session
-    (list
-     (pam-entry
-      (control "include")
-      (module "sddm"))))))
+;; All bindings originally exported by this module have been moved to (gnu
+;; services xorg).  They were moved to avoid a circular dependency between
+;; (gnu services xorg) and this module.  After a deprecation period has
+;; passed, we can remove this module entirely.
 
-(define (sddm-pam-services config)
-  (list (sddm-pam-service config)
-        (sddm-greeter-pam-service)
-        (sddm-autologin-pam-service config)))
+(define-deprecated/alias sddm-configuration
+  (@ (gnu services xorg) sddm-configuration))
 
-(define %sddm-accounts
-  (list (user-group (name "sddm") (system? #t))
-        (user-account
-         (name "sddm")
-         (group "sddm")
-         (system? #t)
-         (comment "SDDM user")
-         (home-directory "/var/lib/sddm")
-         (shell (file-append shadow "/sbin/nologin")))))
+(define-deprecated/alias sddm-configuration?
+  (@ (gnu services xorg) sddm-configuration?))
 
-;; Add default themes to profile
-(define sddm-profile-service
-  (compose list sddm-configuration-sddm))
+(define-deprecated/alias sddm-service-type
+  (@ (gnu services xorg) sddm-service-type))
 
-(define sddm-service-type
-  (handle-xorg-configuration sddm-configuration
-    (service-type (name 'sddm)
-                  (extensions
-                    (list (service-extension shepherd-root-service-type
-                                             sddm-shepherd-service)
-                          (service-extension etc-service-type
-                                             sddm-etc-service)
-                          (service-extension pam-root-service-type
-                                             sddm-pam-services)
-                          (service-extension account-service-type
-                                             (const %sddm-accounts))
-                          (service-extension profile-service-type
-                                             sddm-profile-service)))
-                  (default-value (sddm-configuration))
-                  (description
-                   "Run SDDM, a display and log-in manager for X11 and
-Wayland."))))
+(define-deprecated/alias sddm-service
+  (@ (gnu services xorg) sddm-service))
 
-(define-deprecated (sddm-service #:optional (config (sddm-configuration)))
-  sddm-service-type
-  "Run the @uref{https://github.com/sddm/sddm,SDDM display manager}
-with the given @var{config}, a @code{<sddm-configuration>} object."
-  (service sddm-service-type config))
+;; The forms above only define macros.  To ensure that the (guix
+;; discovery) machinery finds this module, we must export at least one
+;; public variable.  Its value does not matter.
+(define gnu-services-sddm-sentinel #t)
diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm
index 82a7d25602..cbe77f1891 100644
--- a/gnu/services/xorg.scm
+++ b/gnu/services/xorg.scm
@@ -2,8 +2,10 @@
 ;;; Copyright © 2017 Andy Wingo <[email-masked]>
 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2015 Sou Bunnbu <[email-masked]>
+;;; Copyright © 2016 David Craven <[email-masked]>
 ;;; Copyright © 2018, 2019 Timothy Sample <[email-masked]>
 ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen <[email-masked]>
+;;; Copyright © 2019 Jesse Gildersleve <[email-masked]>
 ;;; Copyright © 2019 Tim Gesthuizen <[email-masked]>
 ;;; Copyright © 2020 shtwzrd <[email-masked]>
 ;;; Copyright © 2020 Jakub Kądziołka <[email-masked]>
@@ -11,6 +13,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <[email-masked]>
 ;;; Copyright © 2021 Oleg Pykhalov <[email-masked]>
 ;;; Copyright © 2021 Josselin Poiret <[email-masked]>
+;;; Copyright © 2022 Chris Marusich <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -113,6 +116,11 @@
             gdm-configuration
             gdm-service-type
 
+            sddm-configuration
+            sddm-configuration?
+            sddm-service-type
+            sddm-service
+
             handle-xorg-configuration
             set-xorg-configuration))
 
@@ -1040,10 +1048,311 @@ the GNOME desktop environment.")
                    "Run the GNOME Desktop Manager (GDM), a program that allows
 you to log in in a graphical session, whether or not you use GNOME."))))
 
+(define-record-type* <sddm-configuration>
+  sddm-configuration      make-sddm-configuration
+  sddm-configuration?
+  (sddm                   sddm-configuration-sddm
+                          (default sddm))
+
+  ;; [General]
+  ;; valid values are x11 and wayland
+  ;; currently doesn't do anything is enabled by wayland greeter PR
+  (display-server         sddm-configuration-display-server
+                          (default "x11"))
+  ;; valid values are on, off or none
+  (numlock                sddm-configuration-numlock
+                          (default "on"))
+  (halt-command           sddm-configuration-halt-command
+                          (default (file-append shepherd "/sbin/halt")))
+  (reboot-command         sddm-configuration-reboot-command
+                          (default (file-append shepherd "/sbin/reboot")))
+
+  ;; [Theme]
+  ;; valid values are elarun, maldives or maya
+  (theme                  sddm-configuration-theme
+                          (default "maldives"))
+  (themes-directory       sddm-configuration-themes-directory
+                          (default "/run/current-system/profile/share/sddm/themes"))
+  (faces-directory        sddm-configuration-faces-directory
+                          (default "/run/current-system/profile/share/sddm/faces"))
+
+  ;; [Users]
+  (default-path           sddm-configuration-default-path
+                          (default "/run/current-system/profile/bin"))
+  (minimum-uid            sddm-configuration-minimum-uid
+                          (default 1000))
+  (maximum-uid            sddm-configuration-maximum-uid
+                          (default 2000))
+  (remember-last-user?    sddm-configuration-remember-last-user?
+                          (default #t))
+  (remember-last-session? sddm-configuration-remember-last-session?
+                          (default #t))
+  (hide-users             sddm-configuration-hide-users
+                          (default ""))
+  (hide-shells            sddm-configuration-hide-shells
+                          (default (file-append shadow "/sbin/nologin")))
+
+  ;; [Wayland]
+  (session-command        sddm-configuration-session-command
+                          (default (file-append sddm "/share/sddm/scripts/wayland-session")))
+  (sessions-directory     sddm-configuration-sessions-directory
+                          (default "/run/current-system/profile/share/wayland-sessions"))
+  ;; [X11]
+  (xorg-configuration     sddm-configuration-xorg
+                          (default (xorg-configuration)))
+  (xauth-path             sddm-configuration-xauth-path
+                          (default (file-append xauth "/bin/xauth")))
+  (xephyr-path            sddm-configuration-xephyr-path
+                          (default (file-append xorg-server "/bin/Xephyr")))
+  (xdisplay-start         sddm-configuration-xdisplay-start
+                          (default (file-append sddm "/share/sddm/scripts/Xsetup")))
+  (xdisplay-stop          sddm-configuration-xdisplay-stop
+                          (default (file-append sddm "/share/sddm/scripts/Xstop")))
+  (xsession-command       sddm-configuration-xsession-command
+                          (default (xinitrc)))
+  (xsessions-directory    sddm-configuration-xsessions-directory
+                          (default "/run/current-system/profile/share/xsessions"))
+  (minimum-vt             sddm-configuration-minimum-vt
+                          (default 7))
+
+  ;; [Autologin]
+  (auto-login-user        sddm-configuration-auto-login-user
+                          (default ""))
+  ;; valid values are xfce.desktop gnome.desktop weston.desktop hawaii.desktop
+  (auto-login-session     sddm-configuration-auto-login-session
+                          (default ""))
+  (relogin?               sddm-configuration-relogin?
+                          (default #f)))
+
+(define (sddm-configuration-file config)
+  (mixed-text-file "sddm.conf" "
+[General]
+DisplayServer="        (sddm-configuration-display-server config)              "
+Numlock="              (sddm-configuration-numlock config)                     "
+HaltCommand="          (sddm-configuration-halt-command config)                "
+RebootCommand="        (sddm-configuration-reboot-command config)              "
+
+[Users]
+DefaultPath="          (sddm-configuration-default-path config)                "
+MinimumUid="           (number->string (sddm-configuration-minimum-uid config))"
+MaximumUid="           (number->string (sddm-configuration-maximum-uid config))"
+RememberLastUser="     (if (sddm-configuration-remember-last-user? config)
+                           "true" "false")                                     "
+RememberLastSession="  (if (sddm-configuration-remember-last-session? config)
+                           "true" "false")                                     "
+HideUsers="            (sddm-configuration-hide-users config)                  "
+Hideshells="           (sddm-configuration-hide-shells config)                 "
+
+[Theme]
+Current="              (sddm-configuration-theme config)                       "
+ThemeDir="             (sddm-configuration-themes-directory config)            "
+FacesDir="             (sddm-configuration-faces-directory config)             "
+
+[Wayland]
+SessionCommand="       (sddm-configuration-session-command config)             "
+SessionDir="           (sddm-configuration-sessions-directory config)          "
+
+[X11]
+ServerPath="           (xorg-start-command (sddm-configuration-xorg config))   "
+XauthPath="            (sddm-configuration-xauth-path config)                  "
+XephyrPath="           (sddm-configuration-xephyr-path config)                 "
+DisplayCommand="       (sddm-configuration-xdisplay-start config)              "
+DisplayStopCommand="   (sddm-configuration-xdisplay-stop config)               "
+SessionCommand="       (sddm-configuration-xsession-command config)            "
+SessionDir="           (sddm-configuration-xsessions-directory config)         "
+MinimumVT="            (number->string (sddm-configuration-minimum-vt config)) "
+ServerArguments="      (string-join
+                        (xorg-configuration-server-arguments
+                         (sddm-configuration-xorg config)))           "
+
+[Autologin]
+User="                 (sddm-configuration-auto-login-user config)             "
+Session="              (sddm-configuration-auto-login-session config)          "
+Relogin="              (if (sddm-configuration-relogin? config)
+                           "true" "false")                                     "
+"))
+
+(define (sddm-shepherd-service config)
+  "Return a <shepherd-service> for sddm with CONFIG."
+
+  (define sddm-command
+    #~(list (string-append #$(sddm-configuration-sddm config) "/bin/sddm")))
+
+  (list (shepherd-service
+         (documentation "SDDM display manager.")
+         (requirement '(user-processes elogind))
+         (provision '(xorg-server display-manager))
+         (start #~(make-forkexec-constructor #$sddm-command))
+         (stop #~(make-kill-destructor)))))
+
+(define (sddm-etc-service config)
+  (list `("sddm.conf" ,(sddm-configuration-file config))))
+
+(define (sddm-pam-service config)
+  "Return a PAM service for @command{sddm}."
+  (pam-service
+   (name "sddm")
+   (auth
+    (list
+     (pam-entry
+      (control "requisite")
+      (module "pam_nologin.so"))
+     (pam-entry
+      (control "required")
+      (module "pam_env.so"))
+     (pam-entry
+      (control "required")
+      (module "pam_succeed_if.so")
+      (arguments (list (string-append "uid >= "
+                                      (number->string (sddm-configuration-minimum-uid config)))
+                       "quiet")))
+     ;; should be factored out into system-auth
+     (pam-entry
+      (control "required")
+      (module "pam_unix.so"))))
+   (account
+    (list
+     ;; should be factored out into system-account
+     (pam-entry
+      (control "required")
+      (module "pam_unix.so"))))
+   (password
+    (list
+     ;; should be factored out into system-password
+     (pam-entry
+      (control "required")
+      (module "pam_unix.so")
+      (arguments (list "sha512" "shadow" "try_first_pass")))))
+   (session
+    (list
+     ;; lfs has a required pam_limits.so
+     ;; should be factored out into system-session
+     (pam-entry
+      (control "required")
+      (module "pam_unix.so"))))))
+
+(define (sddm-greeter-pam-service)
+  "Return a PAM service for @command{sddm-greeter}."
+  (pam-service
+   (name "sddm-greeter")
+   (auth
+    (list
+     ;; Load environment from /etc/environment and ~/.pam_environment
+     (pam-entry
+      (control "required")
+      (module "pam_env.so"))
+     ;; Always let the greeter start without authentication
+     (pam-entry
+      (control "required")
+      (module "pam_permit.so"))))
+   (account
+    (list
+     ;; No action required for account management
+     (pam-entry
+      (control "required")
+      (module "pam_permit.so"))))
+   (password
+    (list
+     ;; Can't change password
+     (pam-entry
+      (control "required")
+      (module "pam_deny.so"))))
+   (session
+    (list
+     ;; Setup session
+     (pam-entry
+      (control "required")
+      (module "pam_unix.so"))))))
+
+(define (sddm-autologin-pam-service config)
+  "Return a PAM service for @command{sddm-autologin}"
+  (pam-service
+   (name "sddm-autologin")
+   (auth
+    (list
+     (pam-entry
+      (control "requisite")
+      (module "pam_nologin.so"))
+     (pam-entry
+      (control "required")
+      (module "pam_succeed_if.so")
+      (arguments (list (string-append "uid >= "
+                                      (number->string (sddm-configuration-minimum-uid config)))
+                       "quiet")))
+     (pam-entry
+      (control "required")
+      (module "pam_permit.so"))))
+   (account
+    (list
+     (pam-entry
+      (control "include")
+      (module "sddm"))))
+   (password
+    (list
+     (pam-entry
+      (control "required")
+      (module "pam_deny.so"))))
+   (session
+    (list
+     (pam-entry
+      (control "include")
+      (module "sddm"))))))
+
+(define (sddm-pam-services config)
+  (list (sddm-pam-service config)
+        (sddm-greeter-pam-service)
+        (sddm-autologin-pam-service config)))
+
+(define %sddm-accounts
+  (list (user-group (name "sddm") (system? #t))
+        (user-account
+         (name "sddm")
+         (group "sddm")
+         (system? #t)
+         (comment "SDDM user")
+         (home-directory "/var/lib/sddm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+;; Add default themes to profile
+(define sddm-profile-service
+  (compose list sddm-configuration-sddm))
+
+(define sddm-service-type
+  (handle-xorg-configuration sddm-configuration
+    (service-type (name 'sddm)
+                  (extensions
+                    (list (service-extension shepherd-root-service-type
+                                             sddm-shepherd-service)
+                          (service-extension etc-service-type
+                                             sddm-etc-service)
+                          (service-extension pam-root-service-type
+                                             sddm-pam-services)
+                          (service-extension account-service-type
+                                             (const %sddm-accounts))
+                          (service-extension profile-service-type
+                                             sddm-profile-service)))
+                  (default-value (sddm-configuration))
+                  (description
+                   "Run SDDM, a display and log-in manager for X11 and
+Wayland."))))
+
+(define-deprecated (sddm-service #:optional (config (sddm-configuration)))
+  sddm-service-type
+  "Run the @uref{https://github.com/sddm/sddm,SDDM display manager}
+with the given @var{config}, a @code{<sddm-configuration>} object."
+  (service sddm-service-type config))
+
+;; Since GDM depends on Rust (gdm -> gnome-shell -> gjs -> mozjs -> rust)
+;; and Rust is currently unavailable on non-x86_64 platforms, default to
+;; SDDM there (FIXME).
 (define* (set-xorg-configuration config
                                  #:optional
                                  (login-manager-service-type
-                                  gdm-service-type))
+                                  (let ((system (or (%current-target-system)
+                                                    (%current-system))))
+                                    (if (string-prefix? "x86_64" system)
+                                        gdm-service-type
+                                        sddm-service-type))))
   "Tell the log-in manager (of type @var{login-manager-service-type}) to use
 @var{config}, an <xorg-configuration> record."
   (simple-service 'set-xorg-configuration
diff --git a/gnu/system/examples/vm-image.tmpl b/gnu/system/examples/vm-image.tmpl
index a59d91587b..07cf718466 100644
--- a/gnu/system/examples/vm-image.tmpl
+++ b/gnu/system/examples/vm-image.tmpl
@@ -107,12 +107,12 @@ root ALL=(ALL) ALL
                  ;; Use the DHCP client service rather than NetworkManager.
                  (service dhcp-client-service-type))
 
-           ;; Remove GDM, ModemManager, NetworkManager, and wpa-supplicant,
-           ;; which don't make sense in a VM.
+           ;; Remove some services that don't make sense in a VM.
            (remove (lambda (service)
                      (let ((type (service-kind service)))
                        (or (memq type
                                  (list gdm-service-type
+                                       sddm-service-type
                                        wpa-supplicant-service-type
                                        cups-pk-helper-service-type
                                        network-manager-service-type
-- 
2.26.3