Subject: Re: [bug#35305] LightDM service

From: Ricardo Wurmus <[email-masked]>
Date: Sat, 09 May 2020 00:18:14 +0200

I have applied all patches locally, pushed some of them to the master
branch already, and also made these local changes:

diff --git a/doc/guix.texi b/doc/guix.texi
index 14a42e7070..d1f6ed6685 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -80,6 +80,7 @@ Copyright @copyright{} 2020 Brice Waegeneire@*
 Copyright @copyright{} 2020 R Veera Kumar@*
 Copyright @copyright{} 2020 Pierre Langlois@*
 Copyright @copyright{} 2020 pinoaffe@*
+Copyright @copyright{} 2020 L  p R n  d n@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -14933,9 +14934,9 @@ auto-login session.
 
 @cindex LightDM, login manager
 @defvr {Scheme Variable} lightdm-service-type
-Service type for the LightDM graphical login manager.
-It uses the @code{lightdm-gtk-greeter} as default greeter.
-See @code{lightdm-configuration} below for configuration and greeters'
+Service type for the LightDM graphical login manager.  It uses the
+@code{lightdm-gtk-greeter} as default greeter.  See
+@code{lightdm-configuration} below for configuration and greeters'
 services for their specific configuration.
 @end defvr
 
@@ -14950,22 +14951,22 @@ The LightDM package to use.
 Whether to allow logins with empty passwords.
 
 @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
-Default configuration of the Xorg graphical server. This configuration
+Default configuration of the Xorg graphical server.  This configuration
 will be used for all seats unless explicitly defined.
 
-@item @code{sessions-directory} (default:"/run/current-system/profile/share/xsessions:/run/current-system/profile/share/wayland-sessions")
+@item @code{sessions-directories} (default: @code{'("/run/current-system/profile/share/xsessions" "/run/current-system/profile/share/wayland-sessions")})
 Directories where LightDM will search for sessions' @code{.desktop} files.
 
-@item @code{remote-sessions-directory} (default:"/run/current-system/profile/share/remote-session")
+@item @code{remote-sessions-directories} (default: @code{'("/run/current-system/profile/share/remote-session")})
 Directories where LightDM will search for remote sessions'
 @code{.desktop} files.
 
 @item @code{seats} (default: @code{'()})
-A list of @code{lightdm-seat-configuration} records (see below)
-to include in configuration. Note that needed additional packages or
-configuration will need to be done manually. Thus, we recommend using a
-greeter service for defining seats. If none are provided here or by a greeter,
-a fallback one is added.
+A list of @code{lightdm-seat-configuration} records (see below) to
+include in configuration.  Note that needed additional packages or
+configuration will need to be done manually.  Thus, we recommend using a
+greeter service for defining seats.  If none are provided here or by a
+greeter, a fallback one is added.
 
 @item @code{extra-config} (default: @code{'()})
 A list of strings each describing a custom setting to append to the LightDM
@@ -14981,8 +14982,8 @@ Record representing a seat configuration for LightDM.
 @item @code{name-glob} (default: @code{"*"})
 Seat configuration is matched to all seats matching the name glob.
 
-@item @code{type} (default: @code{"local"})
-Type of seat. @code{"local"} or @code{"xremote"}.
+@item @code{type} (default: @code{'local})
+Type of seat.  @code{'local} or @code{'xremote}.
 
 @item @code{xorg-configuration} (default: @code{#f})
 Configuration of the Xorg graphical server.
@@ -14998,9 +14999,9 @@ The name of the default @code{.desktop} file describing a session.
 Will be used for @code{user-session} and @code{autologin-session} if necessary.
 
 @item @code{autologin-user} (default: "")
-If @code{autologin-user} is set, LightDM logs in directly
-as @code{autologin-user} to the session defined in
-@code{default-user-session}. This user should be part of the
+If @code{autologin-user} is set, LightDM logs in directly as
+@code{autologin-user} to the session defined in
+@code{default-user-session}.  This user should be part of the
 @code{autologin} group.
 
 @item @code{extra-config} (default: @code{'()})
@@ -15043,7 +15044,7 @@ The size of the cursor.
 Path to the background image to be used.
 
 @item @code{a11y-state} (default: "contrast; font; keyboard; reader")
-String describing states of accessibility features. @code{"name"} saves state
+String describing states of accessibility features.  @code{"name"} saves state
 on exit, @code{"-name"} disables at start and @code{"+name"} enables it.
 
 @item @code{reader} (default: "")
@@ -15051,8 +15052,8 @@ Command to launch screen reader.
 
 @item @code{seats} (default: @code{'()})
 List of @code{lightdm-seat-configuration} records (see above) to add to
-lightdm.conf through extension. @code{greeter-session} fields
-will be forced to @code{"lightdm-gtk-greeter"}
+@file{lightdm.conf} through extension.  @code{greeter-session} fields
+are forced to @code{"lightdm-gtk-greeter"}.
 
 @item @code{extra-config} (default: @code{'()})
 A list of string each describing a custom setting to append to the greeter
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
index fa5330aade..8b0c1fcebd 100644
--- a/gnu/services/lightdm.scm
+++ b/gnu/services/lightdm.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2019,2020 L  p R n  d n   <[email-masked]>
+;;; Copyright © 2019, 2020 L  p R n  d n   <[email-masked]>
+;;; Copyright © 2020 Ricardo Wurmus <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -60,7 +61,7 @@
   (name-glob lightdm-seat-configuration-name-glob
              (default "*"))
   (type lightdm-seat-configuration-type
-        (default "local"))
+        (default 'local))
   (xorg-configuration lightdm-seat-configuration-xorg-configuration
                       (default #f))
   (session-wrapper lightdm-seat-configuration-session-wrapper
@@ -74,9 +75,9 @@
   (extra-config lightdm-seat-configuration-extra-config
                 (default '())))
 
-
 (define (lightdm-seat-configuration->list seat default-xorg-configuration)
-  "Given a seat, outputs a list to be used by mixed-text-file through `apply."
+  "Given a seat, outputs a list of configuration file chunks to be passed as
+arguments to mixed-text-file."
   (match-record seat <lightdm-seat-configuration>
                 (name-glob
                  type xorg-configuration session-wrapper
@@ -84,7 +85,7 @@
                  autologin-user extra-config)
                 (list "
   [Seat:"               name-glob                              "]
-  type = "              type
+  type = "              (symbol->string type)
   ;; If no xorg-configuration is set by the seat use the one provided
   ;; by the lightdm service
   "
@@ -114,15 +115,15 @@
            (default lightdm))
   (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
                           (default #f))
-  (sessions-directory
-   lightdm-configuration-sessions-directory
-   (default
-     "/run/current-system/profile/share/xsessions:/run/current-system/profile/share/wayland-sessions"))
+  (sessions-directories
+   lightdm-configuration-sessions-directories
+   (default '("/run/current-system/profile/share/xsessions"
+              "/run/current-system/profile/share/wayland-sessions")))
   (greeters-directory lightdm-configuration-greeters-directory
                       (default "/run/current-system/profile/share/xgreeters"))
-  (remote-sessions-directory lightdm-configuration-remote-sessions-directory
-                             (default
-                               "/run/current-system/profile/share/remote-sessions"))
+  (remote-sessions-directories
+   lightdm-configuration-remote-sessions-directories
+   (default '("/run/current-system/profile/share/remote-sessions")))
   ;; Having a xorg-configuration field here allows us
   ;; to benefit from set-xorg-configuration.
   (xorg-configuration lightdm-configuration-xorg-configuration
@@ -135,25 +136,27 @@
 (define (lightdm-configuration-file config)
   (match-record config <lightdm-configuration>
                 (allow-empty-passwords?
-                 sessions-directory greeters-directory
-                 remote-sessions-directory xorg-configuration
+                 sessions-directories greeters-directory
+                 remote-sessions-directories xorg-configuration
                  seats extra-config)
-                ;; Little trick to allow unquote-splicing of seats
-                (apply mixed-text-file `("lightdm.conf" "
+                (apply mixed-text-file "lightdm.conf"
+                       `("\
 [LightDM]
 greeter-user = lightdm
 greeters-directory = " ,greeters-directory "
-sessions-directory = " ,sessions-directory "
-remote-sessions-directory = " ,remote-sessions-directory "
+sessions-directory = " ,(string-join sessions-directories ":") "
+remote-sessions-directory = " ,(string-join remote-sessions-directories ":") "
 
 #Seats
- " ,@(if (null? seats)
-         (lightdm-seat-configuration->list (lightdm-seat-configuration)
-                                           xorg-configuration)
-         (concatenate
-          (map (lambda (seat)
-                 (lightdm-seat-configuration->list seat xorg-configuration))
-               seats))) "
+"
+,@(if (null? seats)
+      (lightdm-seat-configuration->list (lightdm-seat-configuration)
+                                        xorg-configuration)
+      (concatenate
+       (map (lambda (seat)
+              (lightdm-seat-configuration->list seat xorg-configuration))
+            seats)))
+"
 #Extra config
 " ,(string-join extra-config "\n")))))
 
@@ -337,8 +340,8 @@ remote-sessions-directory = " ,remote-sessions-directory "
                            (seats (append (assoc-ref extensions "seats")
                                           (lightdm-configuration-seats config))))))
                 (default-value (lightdm-configuration))
-                (description "Return a service that spawns the
- LightDM graphical login manager.")))
+                (description "Return a service that spawns the LightDM
+graphical login manager.")))
 
 ;; GREETERS
 
@@ -418,5 +421,5 @@ a11y-states = "         a11y-states                        "
                                      lightdm-gtk-greeter-profile-service)))
                 (default-value (lightdm-gtk-greeter-configuration))
                 (description
-                 "Set-up lightdm-gtk-greeter as well
-as its configuration file and extends LightDM with its seats.")))
+                 "Set-up lightdm-gtk-greeter as well as its configuration file
+and extend LightDM with its seats.")))

What do you think about these changes?  I felt that a list of
directories should be expressed as a list and not a colon-separated
string.  I realize that this clashes with the lightdm configuration
file, which speaks of “directory” even though it accepts a
colon-separated list of directories.

If that’s fine I’ll fold them into your patch that adds the service.

I built a VM and noticed that all icons are missing.  Should the service
arrange for a certain fallback icon theme to be installed?

I also haven’t actually been able to log in as root with an empty
password, which is what the VM generates by default.  Can this be
supported with lightdm?

--
Ricardo