unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#35305] [WIP] LightDM service
@ 2019-04-17 14:24 L p R n d n
  2019-04-18 11:20 ` Jonathan Brielmaier
                   ` (5 more replies)
  0 siblings, 6 replies; 30+ messages in thread
From: L p R n d n @ 2019-04-17 14:24 UTC (permalink / raw)
  To: 35305

[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]

Hello,

Wanted to work on Guix's website but fate led me to try my way on a
lightdm service...
So, here is what I got for now.
It fails to start a window manager but I don't think I'll be able to
debug the last mile with my sole knowledge.

Beside that, here is a list of possible improvements before merging:

* lightdm-greeter-gtk configuration is a part of lightdm's service.
It might be a good idea to give it its own service but it would
mean we need to write a service for each lightdm greeter.

* lightdm complains about the lack of
  org.freedesktop.DisplayManager.AccountsService interface.
  The lightdm package provides the relevent files but it seems
  accountsservice doesn't find them. I think it searches them in
  $XDG_DATA_DIRS/accountservices . See
  https://github.com/NixOS/nixpkgs/issues/45059

* lightdm-gtk-greeter's wrapper is handmade and ugly.

* General refining.

A thorough review would also be welcome as I'm not really sure I know
what I'm doing.

Thanks!

L  p R n  d n   


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-lightdm-Update-1.28.0.patch --]
[-- Type: text/x-patch, Size: 1547 bytes --]

From 826ca620f71f5b219f1402fe4ea582de621b061a Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:16:39 +0200
Subject: [PATCH 01/10] gnu: lightdm: Update 1.28.0.

* gnu/packages/display-managers.scm (lightdm): Update to 1.28.0.
---
 gnu/packages/display-managers.scm | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index afe5cc2b7b..243baebb3d 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -208,16 +208,15 @@ create smooth, animated user interfaces.")
 (define-public lightdm
   (package
     (name "lightdm")
-    (version "1.24.0")
+    (version "1.28.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append "https://launchpad.net/lightdm/"
-                                  (version-major+minor version) "/"
-                                  version "/+download/lightdm-"
-                                  version ".tar.xz"))
+              (uri (string-append
+                    "https://github.com/CanonicalLtd/lightdm/releases/download/"
+                    version "/lightdm-" version ".tar.xz"))
               (sha256
                (base32
-                "18j33bm54i8k7ncxcs69zqi4105s62n58jrydqn3ikrb71s9nl6d"))))
+                "01zsxim662n2w66j46rv291w9aqmwvlwccyzl9vhpybwinfmj3zj"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-lightdm-Add-vala-bindings.patch --]
[-- Type: text/x-patch, Size: 851 bytes --]

From c2ead5265c209315fa57cb07b84ead557e191175 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:21:55 +0200
Subject: [PATCH 02/10] gnu: lightdm: Add vala bindings.

* gnu/packages/display-managers.scm (lightdm) [native-inputs]: Add vala.
---
 gnu/packages/display-managers.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 243baebb3d..d1eb3f146e 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -263,6 +263,7 @@ create smooth, animated user interfaces.")
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
+       ("vala" ,vala)                   ;For vala bindings
        ;; For tests
        ("dbus" ,dbus)
        ("python" ,python-2)
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-gnu-lightdm-Re-enable-all-tests.patch --]
[-- Type: text/x-patch, Size: 1132 bytes --]

From 6e0bf56cd21964c868b6eaf2867dfbd412c4d279 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:26:22 +0200
Subject: [PATCH 03/10] gnu: lightdm: Re-enable all tests.

* gnu/packages/display-managers.scm (lightdm)[arguments]: Remove disable-broken-phase.
---
 gnu/packages/display-managers.scm | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index d1eb3f146e..7f5678f459 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -235,12 +235,6 @@ create smooth, animated user interfaces.")
              (substitute* "src/seat.c"
                (("/bin/sh") (which "sh")))
              #t))
-         (add-after 'unpack 'disable-broken-tests
-           (lambda _
-             (substitute* "tests/Makefile.in"
-               (("test-sessions-gobject ") "")
-               ((" test-sessions-python ") " "))
-             #t))
          (add-before 'check 'pre-check
            ;; Run test-suite under a dbus session.
            (lambda* (#:key inputs #:allow-other-keys)
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-gnu-lightdm-gtk-greeter-Update-to-2.0.6.patch --]
[-- Type: text/x-patch, Size: 1308 bytes --]

From c31f542d6c551ef2b7bef4d576ff7c2ad1e4a01a Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:40:38 +0200
Subject: [PATCH 04/10] gnu: lightdm-gtk-greeter: Update to 2.0.6.

* gnu/packages/display-manager.scm (lightdm-gtk-greeter): Update to 2.0.6.
---
 gnu/packages/display-managers.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 7f5678f459..be365df6a2 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -276,7 +276,7 @@ display manager which supports different greeters.")
 (define-public lightdm-gtk-greeter
   (package
     (name "lightdm-gtk-greeter")
-    (version "2.0.2")
+    (version "2.0.6")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -285,7 +285,7 @@ display manager which supports different greeters.")
                     "/+download/lightdm-gtk-greeter-" version ".tar.gz"))
               (sha256
                (base32
-                "1436sdm83xqhxyr1rzqxhsl8if2xmidlvb341xcv6dv83lyxkrlf"))))
+                "1pis5qyg95pg31dvnfqq34bzgj00hg4vs547r8h60lxjk81z8p15"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("exo" ,exo)
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-gnu-lightdm-gtk-greeter-Fix-at-spi-runtime-dependenc.patch --]
[-- Type: text/x-patch, Size: 1353 bytes --]

From 8b4354bd30dc44c47509f0bc0da9fe95e6b4db8d Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:50:58 +0200
Subject: [PATCH 05/10] gnu: lightdm-gtk-greeter: Fix at-spi runtime
 dependency.

* gnu/packages/display-manager.scm (lightdm): Fix at-spi runtime dependency.
[inputs]: Add at-spi2-core.
[arguments]: Add '--enable-at-spi-command' configure flag.
---
 gnu/packages/display-managers.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index be365df6a2..352ad19efa 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -293,7 +293,14 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
+    (arguments
+     `(#:configure-flags
+       (list "--localstatedir=/var"
+             (string-append "--enable-at-spi-command="
+                            (assoc-ref %build-inputs "at-spi2-core")
+                            "/libexec/at-spi-bus-launcher"))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-gnu-lightdm-gtk-greeter-Fix-.desktop-file.patch --]
[-- Type: text/x-patch, Size: 1693 bytes --]

From ef95fd1a611d24cb5a2f77f758a0495ab231a444 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:58:26 +0200
Subject: [PATCH 06/10] gnu: lightdm-gtk-greeter: Fix .desktop file.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix .desktop file
  path.
[arguments]: Add fix-.desktop-path phase.
---
 gnu/packages/display-managers.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 352ad19efa..4d22d28f02 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -300,7 +300,17 @@ display manager which supports different greeters.")
        (list "--localstatedir=/var"
              (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
-                            "/libexec/at-spi-bus-launcher"))))
+                            "/libexec/at-spi-bus-launcher"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'fix-.desktop-path
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (substitute* (string-append
+                             out "/share/xgreeters/lightdm-gtk-greeter.desktop")
+                 (("Exec=lightdm-gtk-greeter")
+                  (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
+               #t))))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-gnu-lightdm-gtk-greeter-Wrap-binary.patch --]
[-- Type: text/x-patch, Size: 2958 bytes --]

From 8ed5177d5a188f8722e4cfdede4967b3e73968f8 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 14:17:18 +0200
Subject: [PATCH 07/10] gnu: lightdm-gtk-greeter: Wrap binary.

* gnu/package/display-managers.scm (lightdm-gtk-greeter): Wrap binary.
[inputs]: Add hicolor-icon-theme.
[arguments]: Add wrap-program phase.
---
 gnu/packages/display-managers.scm | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 4d22d28f02..de2b45d4d6 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -294,6 +294,7 @@ display manager which supports different greeters.")
     (inputs
      `(("lightdm" ,lightdm)
        ("at-spi2-core" ,at-spi2-core)
+       ("hicolor-icon-theme" ,hicolor-icon-theme)
        ("gtk+" ,gtk+)))
     (arguments
      `(#:configure-flags
@@ -310,7 +311,27 @@ display manager which supports different greeters.")
                              out "/share/xgreeters/lightdm-gtk-greeter.desktop")
                  (("Exec=lightdm-gtk-greeter")
                   (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
-               #t))))))
+               #t)))
+         (add-after 'fix-.desktop-path 'wrap-program
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (wrap-program (string-append (assoc-ref outputs "out")
+                                          "/sbin/lightdm-gtk-greeter")
+               `("XDG_DATA_DIRS" ":" prefix (,(string-append (assoc-ref inputs "hicolor-icon-theme")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "glib")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "shared-mime-info")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "gtk+")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "exo")
+                                                             "/share")
+                                             ,(string-append (assoc-ref outputs "out")
+                                                             "/share")
+                                             "/run/current-system/profile/share"))
+               `("GTK_PATH" ":" prefix (,(assoc-ref inputs "gtk+")))
+               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+"))))
+             #t)))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #9: 0008-gnu-lightdm-Build-accountsservice-files.patch --]
[-- Type: text/x-patch, Size: 997 bytes --]

From 56c962ccc54f3c7f83ea288c9ac26524af19b5a0 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 19:46:44 +0200
Subject: [PATCH 08/10] gnu: lightdm: Build accountsservice files.

* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Add accountsservice.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index de2b45d4d6..a829e74604 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -253,7 +253,8 @@ create smooth, animated user interfaces.")
        ("libgcrypt" ,libgcrypt)
        ("libxcb" ,libxcb)))
     (native-inputs
-     `(("gobject-introspection" ,gobject-introspection)
+     `(("accountsservice" ,accountsservice)
+       ("gobject-introspection" ,gobject-introspection)
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #10: 0009-gnu-lightdm-gtk-greeter-Fix-some-warnings.patch --]
[-- Type: text/x-patch, Size: 1043 bytes --]

From 0d2fa80019cd9d95a0008576fc768fac8ac49c6c Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Wed, 17 Apr 2019 12:44:07 +0200
Subject: [PATCH 09/10] gnu: lightdm-gtk-greeter: Fix some warnings.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix some warnings.
[arguments]: Add '--disable-indicator-services-command' configure flags.
---
 gnu/packages/display-managers.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index a829e74604..67d6d9e5c6 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -300,6 +300,7 @@ display manager which supports different greeters.")
     (arguments
      `(#:configure-flags
        (list "--localstatedir=/var"
+             "--disable-indicator-services-command"
              (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
                             "/libexec/at-spi-bus-launcher"))
-- 
2.21.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #11: 0010-services-Add-lightDM-service.patch --]
[-- Type: text/x-patch, Size: 11354 bytes --]

From 3106b950f70aba2851091731bff4030087c6eca4 Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Wed, 17 Apr 2019 15:47:52 +0200
Subject: [PATCH 10/10] services: Add lightDM service.

* gnu/services/lightdm.scm: New file.
---
 gnu/services/lightdm.scm | 259 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 259 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..b280df49ae
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,259 @@
+(define-module (gnu services lightdm)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type))
+
+(define (lightdm-pam-service)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:allow-empty-passwords? #t)
+  ;; (pam-service
+  ;; (name "lightdm")
+  ;; (auth
+  ;; (list
+  ;; Block login if they are globally disabled
+  ;; (pam-entry (control "required") (module "pam_nologin.so"))
+  ;; Load environment from /etc/environment and ~/.pam_environment
+  ;; (pam-entry (control "required") (module "pam_env.so"))
+  ;; Use /etc/passwd and /etc/shadow for passwords
+  ;; (pam-entry (control "required") (module "pam_unix.so"))
+  ;; https://wiki.gentoo.org/wiki/LightDM#Unlock_GNOME_Keyring
+  ;; (pam-entry (control "optional") (module "pam_gnome_keyring.so"))
+  ;; ))
+  ;; Check account is active, change password if required
+  ;; (account
+  ;; (list
+  ;; (pam-entry (control "required") (module "pam_unix.so"))))
+  ;; Allow password to be changed
+  ;; (password
+  ;; (list
+  ;; (pam-entry (control "required") (module "pam_unix.so"))))
+  ;; Setup session
+  ;; (session
+  ;; (list
+  ;; (pam-entry (control "required") (module "pam_unix.so"))
+  ;; https://wiki.gentoo.org/wiki/LightDM#Unlock_GNOME_Keyring
+  ;; (pam-entry (control "optional") (module "pam_gnome_keyring.so")
+  ;; (arguments (list "auto_start")))
+  ;; )))
+  )
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))
+     (pam-entry (control "required") (module "pam_env.so"))))))
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+     ;; Load environment from /etc/environment and ~/.pam_environment
+     (pam-entry (control "required") (module "pam_env.so"))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (user lightdm-configuration-user
+        (default "lightdm"))
+  (greeters-directory lightdm-configuration-greeters-directory
+                      (default "/run/current-system/profile/share/xgreeters"))
+  (sessions-directory lightdm-configuration-sessions-directory
+                      (default (string-append
+                                "/run/current-system/profile/share/xsessions"
+                                ":/run/current-system/profile/share/wayland-sessions")))
+
+  ;; Seat configuration
+  (greeter-session lightdm-configuration-greeter-session
+                   (default "lightdm-gtk-greeter"))
+  (xserver-command lightdm-configuration-xserver-command
+                   (default (xorg-start-command)))
+  (pam-service lightdm-configuration-pam-service
+               (default (lightdm-pam-service)))
+  (pam-autologin-service lightdm-configuration-autologin-pam-service
+                         (default (lightdm-autologin-pam-service)))
+  (pam-greeter-service lightdm-configuration-greeter-pam-service
+                       (default (lightdm-greeter-pam-service)))
+  (autologin-user lightdm-configuration-autologin-user
+                  (default ""))
+  (default-session-name lightdm-configuration-default-session
+    (default ""))
+  (autologin-timeout lightdm-configuration-autologin-timeout
+                     (default ""))
+  ;; lightdm-gtk-greeter specifics
+  ;; Maybe it should have its own service
+  (gtk-greeter-theming-packages lightdm-configuration-gtk-greeter-theming-packages
+                                (default (list adwaita-icon-theme)))
+  (gtk-greeter-theme-name lightdm-configuration-gtk-greeter-theme-name
+                          (default ""))
+  (gtk-greeter-icon-theme-name
+   lightdm-configuration-gtk-greeter-icon-theme-name
+   (default "Adwaita"))
+  (gtk-greeter-cursor-theme-name
+   lightdm-configuration-gtk-greeter-cursor-theme-name
+   (default "Adwaita"))
+  (gtk-greeter-cursor-size lightdm-configuration-gtk-greeter-cursor-size
+                           (default 16))
+  (gtk-greeter-background lightdm-configuration-gtk-greeter-background
+                          (default "")))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LighDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define (lightdm-configuration-file config)
+  (mixed-text-file "lightdm.conf" "
+[LightDM]
+greeter-user = "          (lightdm-configuration-user config) "
+greeters-directory = "    (lightdm-configuration-greeters-directory config) "
+sessions-directory = "    (lightdm-configuration-sessions-directory config) "
+
+
+[Seat:*]
+xserver-command = "       (lightdm-configuration-xserver-command config) "
+greeter-session = "       (lightdm-configuration-greeter-session config) "
+user-session = "          (lightdm-configuration-default-session config) "
+autologin-user = "        (lightdm-configuration-autologin-user config) "
+autologin-session = "     (lightdm-configuration-default-session config) "
+autologin-user-timeout = " (lightdm-configuration-autologin-timeout config)))
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "        (lightdm-configuration-gtk-greeter-theme-name config) "
+icon-theme-name = "   (lightdm-configuration-gtk-greeter-icon-theme-name config) "
+cursor-theme-name = " (lightdm-configuration-gtk-greeter-cursor-theme-name config) "
+cursor-theme-size = " (number->string (lightdm-configuration-gtk-greeter-cursor-size config)) "
+background = "        (lightdm-configuration-gtk-greeter-background config)))
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list (string-append #$(lightdm-configuration-lightdm config) "/sbin/lightdm")))
+
+  (list (shepherd-service
+         (documentation "LightDM display manager.")
+         (requirement '(dbus-system user-processes host-name))
+         (provision '(display-manager))
+         (respawn? #f)
+         (start #~(lambda ()
+                    (fork+exec-command
+                     (list #$(file-append
+                              (lightdm-configuration-lightdm config)
+                              "/sbin/lightdm"))
+                     #:environment-variables
+                     (list
+                      (string-append
+                       "PATH=/run/current-system/profile/sbin"
+                       ":/run/current-system/profile/bin")))))
+         (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+          ,(lightdm-configuration-file config))
+        `("xdg/lightdm/lightdm-gtk-greeter.conf"
+          ,(lightdm-gtk-greeter-configuration-file config))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-configuration-pam-service config)
+        (lightdm-configuration-greeter-pam-service config)
+        (lightdm-configuration-autologin-pam-service config)))
+
+(define (lightdm-profile-service config)
+  (append (list lightdm-gtk-greeter lightdm)
+          (lightdm-configuration-gtk-greeter-theming-packages config)))
+
+(define (lightdm-activation-service config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (define %user
+          (getpw #$(lightdm-configuration-user config)))
+        (let ((directory "/var/lib/lightdm-data"))
+          (mkdir-p directory)
+          (chown directory (passwd:uid %user) (passwd:gid %user))))))
+
+(define lightdm-service-type
+  (service-type (name 'lightdm)
+                (extensions
+                 (list
+                  (service-extension shepherd-root-service-type
+                                     lightdm-shepherd-service)
+                  (service-extension activation-service-type
+                                     lightdm-activation-service)
+                  (service-extension pam-root-service-type
+                                     lightdm-pam-services)
+                  (service-extension etc-service-type
+                                     lightdm-etc-service)
+                  (service-extension dbus-root-service-type
+                                     (compose list lightdm-configuration-lightdm))
+                  (service-extension account-service-type
+                                     (const %lightdm-accounts))
+                  (service-extension profile-service-type
+                                     lightdm-profile-service)))
+                (default-value (lightdm-configuration))))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] [WIP] LightDM service
  2019-04-17 14:24 [bug#35305] [WIP] LightDM service L p R n d n
@ 2019-04-18 11:20 ` Jonathan Brielmaier
       [not found] ` <handler.35305.B.155550391014002.ack@debbugs.gnu.org>
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 30+ messages in thread
From: Jonathan Brielmaier @ 2019-04-18 11:20 UTC (permalink / raw)
  To: 35305

Please add gnu/services/lightdm.scm to gnu/local.mk

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] Acknowledgement ([WIP] LightDM service)
       [not found] ` <handler.35305.B.155550391014002.ack@debbugs.gnu.org>
@ 2019-04-18 13:20   ` L p R n d n
  2019-04-18 16:03     ` L p R n d n
  2019-08-26 15:58   ` L p R n d n
  1 sibling, 1 reply; 30+ messages in thread
From: L p R n d n @ 2019-04-18 13:20 UTC (permalink / raw)
  To: 35305

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

Hello,

After some work, here is a new patch replacing the last one from
previous mail. It now seems to work as it successfully starts a window
manager.

Have a nice day,

L  p R n  d n


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0010-services-Add-lightdm-service.patch --]
[-- Type: text/x-patch, Size: 10193 bytes --]

From 6598dc79625bda4a2511aaa317a17f0c0559daba Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Thu, 18 Apr 2019 15:10:55 +0200
Subject: [PATCH 10/10] services: Add lightdm service.

* gnu/services/lightdm.scm: New file.
---
 gnu/services/lightdm.scm | 235 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 235 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..6c410a9080
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,235 @@
+(define-module (gnu services lightdm)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type))
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (user lightdm-configuration-user
+        (default "lightdm"))
+  (greeters-directory lightdm-configuration-greeters-directory
+                      (default "/run/current-system/profile/share/xgreeters"))
+  (sessions-directory lightdm-configuration-sessions-directory
+                      (default (string-append
+                                "/run/current-system/profile/share/xsessions"
+                                ":/run/current-system/profile/share/wayland-sessions")))
+  (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
+                          (default #f))
+  ;; Seat configuration
+  (greeter-session lightdm-configuration-greeter-session
+                   (default "lightdm-gtk-greeter"))
+  (xserver-command lightdm-configuration-xserver-command
+                   (default (xorg-start-command)))
+  (session-wrapper lightdm-configuration-session-wrapper
+                   (default (xinitrc)))
+  (autologin-user lightdm-configuration-autologin-user
+                  (default ""))
+  (default-session-name lightdm-configuration-default-session
+    (default ""))
+  (autologin-timeout lightdm-configuration-autologin-timeout
+                     (default ""))
+  ;; lightdm-gtk-greeter specifics
+  ;; Maybe it should have its own service
+  (gtk-greeter-assets lightdm-configuration-gtk-greeter-assets
+                      (default (list adwaita-icon-theme
+                                     gnome-themes-standard)))
+  (gtk-greeter-theme-name lightdm-configuration-gtk-greeter-theme-name
+                          (default "Adwaita"))
+  (gtk-greeter-icon-theme-name
+   lightdm-configuration-gtk-greeter-icon-theme-name
+   (default "Adwaita"))
+  (gtk-greeter-cursor-theme-name
+   lightdm-configuration-gtk-greeter-cursor-theme-name
+   (default "Adwaita"))
+  (gtk-greeter-cursor-size lightdm-configuration-gtk-greeter-cursor-size
+                           (default 16))
+  (gtk-greeter-background lightdm-configuration-gtk-greeter-background
+                          (default "")))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LighDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define (lightdm-configuration-file config)
+  (mixed-text-file "lightdm.conf" "
+[LightDM]
+greeter-user = "          (lightdm-configuration-user config) "
+greeters-directory = "    (lightdm-configuration-greeters-directory config) "
+sessions-directory = "    (lightdm-configuration-sessions-directory config) "
+
+
+[Seat:*]
+xserver-command = "       (lightdm-configuration-xserver-command config) "
+greeter-session = "       (lightdm-configuration-greeter-session config) "
+user-session = "          (lightdm-configuration-default-session config) "
+autologin-user = "        (lightdm-configuration-autologin-user config) "
+autologin-session = "     (lightdm-configuration-default-session config) "
+autologin-user-timeout = " (lightdm-configuration-autologin-timeout config) "
+session-wrapper = " (lightdm-configuration-session-wrapper config)))
+
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "        (lightdm-configuration-gtk-greeter-theme-name config) "
+icon-theme-name = "   (lightdm-configuration-gtk-greeter-icon-theme-name config) "
+cursor-theme-name = " (lightdm-configuration-gtk-greeter-cursor-theme-name config) "
+cursor-theme-size = " (number->string
+                       (lightdm-configuration-gtk-greeter-cursor-size config)) "
+background = "        (lightdm-configuration-gtk-greeter-background config)))
+
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))
+     (pam-entry (control "required") (module "pam_env.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+     ;; Load environment from /etc/environment and ~/.pam_environment
+     (pam-entry (control "required") (module "pam_env.so"))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list (string-append #$(lightdm-configuration-lightdm config) "/sbin/lightdm")))
+
+  (list (shepherd-service
+         (documentation "LightDM display manager.")
+         (requirement '(dbus-system user-processes host-name))
+         (provision '(display-manager))
+         (respawn? #f)
+         (start #~(lambda ()
+                    (fork+exec-command
+                     (list #$(file-append
+                              (lightdm-configuration-lightdm config)
+                              "/sbin/lightdm"))
+                     #:environment-variables
+                     (list
+                      (string-append
+                       "PATH=/run/current-system/profile/sbin"
+                       ":/run/current-system/profile/bin")))))
+         (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+          ,(lightdm-configuration-file config))
+        `("xdg/lightdm/lightdm-gtk-greeter.conf"
+          ,(lightdm-gtk-greeter-configuration-file config))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-profile-service config)
+  (append (list lightdm-gtk-greeter lightdm)
+          (lightdm-configuration-gtk-greeter-assets config)))
+
+(define (lightdm-activation-service config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (define %user
+          (getpw #$(lightdm-configuration-user config)))
+        (let ((directory "/var/lib/lightdm-data"))
+          (mkdir-p directory)
+          (chown directory (passwd:uid %user) (passwd:gid %user))))))
+
+(define lightdm-service-type
+  (service-type (name 'lightdm)
+                (extensions
+                 (list
+                  (service-extension shepherd-root-service-type
+                                     lightdm-shepherd-service)
+                  (service-extension activation-service-type
+                                     lightdm-activation-service)
+                  (service-extension pam-root-service-type
+                                     lightdm-pam-services)
+                  (service-extension etc-service-type
+                                     lightdm-etc-service)
+                  (service-extension dbus-root-service-type
+                                     (compose list lightdm-configuration-lightdm))
+                  (service-extension account-service-type
+                                     (const %lightdm-accounts))
+                  (service-extension profile-service-type
+                                     lightdm-profile-service)))
+                (default-value (lightdm-configuration))))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] Acknowledgement ([WIP] LightDM service)
  2019-04-18 13:20   ` [bug#35305] Acknowledgement ([WIP] LightDM service) L p R n d n
@ 2019-04-18 16:03     ` L p R n d n
  0 siblings, 0 replies; 30+ messages in thread
From: L p R n d n @ 2019-04-18 16:03 UTC (permalink / raw)
  To: 35305

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]


New patch for addinf lightdm service replacing previous one.
Now with local.mk changes.

Have a nice day,

L  p R n  d n


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0010-services-Add-lightdm-service-type.patch --]
[-- Type: text/x-patch, Size: 10675 bytes --]

From 9472d86e06306a66cccbc5f3a0043071f0d9c540 Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Thu, 18 Apr 2019 17:58:56 +0200
Subject: [PATCH 10/10] services: Add lightdm-service-type.

* gnu/services/lightdm.scm: Add file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk             |   1 +
 gnu/services/lightdm.scm | 235 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 236 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index df96b98f07..9dafda9833 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -513,6 +513,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/authentication.scm		\
   %D%/services/games.scm			\
   %D%/services/kerberos.scm			\
+  %D%/services/lightdm.scm      		\
   %D%/services/lirc.scm				\
   %D%/services/virtualization.scm		\
   %D%/services/mail.scm				\
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..6c410a9080
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,235 @@
+(define-module (gnu services lightdm)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type))
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (user lightdm-configuration-user
+        (default "lightdm"))
+  (greeters-directory lightdm-configuration-greeters-directory
+                      (default "/run/current-system/profile/share/xgreeters"))
+  (sessions-directory lightdm-configuration-sessions-directory
+                      (default (string-append
+                                "/run/current-system/profile/share/xsessions"
+                                ":/run/current-system/profile/share/wayland-sessions")))
+  (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
+                          (default #f))
+  ;; Seat configuration
+  (greeter-session lightdm-configuration-greeter-session
+                   (default "lightdm-gtk-greeter"))
+  (xserver-command lightdm-configuration-xserver-command
+                   (default (xorg-start-command)))
+  (session-wrapper lightdm-configuration-session-wrapper
+                   (default (xinitrc)))
+  (autologin-user lightdm-configuration-autologin-user
+                  (default ""))
+  (default-session-name lightdm-configuration-default-session
+    (default ""))
+  (autologin-timeout lightdm-configuration-autologin-timeout
+                     (default ""))
+  ;; lightdm-gtk-greeter specifics
+  ;; Maybe it should have its own service
+  (gtk-greeter-assets lightdm-configuration-gtk-greeter-assets
+                      (default (list adwaita-icon-theme
+                                     gnome-themes-standard)))
+  (gtk-greeter-theme-name lightdm-configuration-gtk-greeter-theme-name
+                          (default "Adwaita"))
+  (gtk-greeter-icon-theme-name
+   lightdm-configuration-gtk-greeter-icon-theme-name
+   (default "Adwaita"))
+  (gtk-greeter-cursor-theme-name
+   lightdm-configuration-gtk-greeter-cursor-theme-name
+   (default "Adwaita"))
+  (gtk-greeter-cursor-size lightdm-configuration-gtk-greeter-cursor-size
+                           (default 16))
+  (gtk-greeter-background lightdm-configuration-gtk-greeter-background
+                          (default "")))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LighDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define (lightdm-configuration-file config)
+  (mixed-text-file "lightdm.conf" "
+[LightDM]
+greeter-user = "          (lightdm-configuration-user config) "
+greeters-directory = "    (lightdm-configuration-greeters-directory config) "
+sessions-directory = "    (lightdm-configuration-sessions-directory config) "
+
+
+[Seat:*]
+xserver-command = "       (lightdm-configuration-xserver-command config) "
+greeter-session = "       (lightdm-configuration-greeter-session config) "
+user-session = "          (lightdm-configuration-default-session config) "
+autologin-user = "        (lightdm-configuration-autologin-user config) "
+autologin-session = "     (lightdm-configuration-default-session config) "
+autologin-user-timeout = " (lightdm-configuration-autologin-timeout config) "
+session-wrapper = " (lightdm-configuration-session-wrapper config)))
+
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "        (lightdm-configuration-gtk-greeter-theme-name config) "
+icon-theme-name = "   (lightdm-configuration-gtk-greeter-icon-theme-name config) "
+cursor-theme-name = " (lightdm-configuration-gtk-greeter-cursor-theme-name config) "
+cursor-theme-size = " (number->string
+                       (lightdm-configuration-gtk-greeter-cursor-size config)) "
+background = "        (lightdm-configuration-gtk-greeter-background config)))
+
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))
+     (pam-entry (control "required") (module "pam_env.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+     ;; Load environment from /etc/environment and ~/.pam_environment
+     (pam-entry (control "required") (module "pam_env.so"))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list (string-append #$(lightdm-configuration-lightdm config) "/sbin/lightdm")))
+
+  (list (shepherd-service
+         (documentation "LightDM display manager.")
+         (requirement '(dbus-system user-processes host-name))
+         (provision '(display-manager))
+         (respawn? #f)
+         (start #~(lambda ()
+                    (fork+exec-command
+                     (list #$(file-append
+                              (lightdm-configuration-lightdm config)
+                              "/sbin/lightdm"))
+                     #:environment-variables
+                     (list
+                      (string-append
+                       "PATH=/run/current-system/profile/sbin"
+                       ":/run/current-system/profile/bin")))))
+         (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+          ,(lightdm-configuration-file config))
+        `("xdg/lightdm/lightdm-gtk-greeter.conf"
+          ,(lightdm-gtk-greeter-configuration-file config))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-profile-service config)
+  (append (list lightdm-gtk-greeter lightdm)
+          (lightdm-configuration-gtk-greeter-assets config)))
+
+(define (lightdm-activation-service config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (define %user
+          (getpw #$(lightdm-configuration-user config)))
+        (let ((directory "/var/lib/lightdm-data"))
+          (mkdir-p directory)
+          (chown directory (passwd:uid %user) (passwd:gid %user))))))
+
+(define lightdm-service-type
+  (service-type (name 'lightdm)
+                (extensions
+                 (list
+                  (service-extension shepherd-root-service-type
+                                     lightdm-shepherd-service)
+                  (service-extension activation-service-type
+                                     lightdm-activation-service)
+                  (service-extension pam-root-service-type
+                                     lightdm-pam-services)
+                  (service-extension etc-service-type
+                                     lightdm-etc-service)
+                  (service-extension dbus-root-service-type
+                                     (compose list lightdm-configuration-lightdm))
+                  (service-extension account-service-type
+                                     (const %lightdm-accounts))
+                  (service-extension profile-service-type
+                                     lightdm-profile-service)))
+                (default-value (lightdm-configuration))))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] [PATCH] LightDM service
  2019-04-17 14:24 [bug#35305] [WIP] LightDM service L p R n d n
  2019-04-18 11:20 ` Jonathan Brielmaier
       [not found] ` <handler.35305.B.155550391014002.ack@debbugs.gnu.org>
@ 2019-05-23 11:04 ` L p R n d n
  2020-04-07 17:06 ` [bug#35305] " Brice Waegeneire
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 30+ messages in thread
From: L p R n d n @ 2019-05-23 11:04 UTC (permalink / raw)
  To: 35305

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

Hello,

New patch for adding the lightDM service replacing the previous one.
Added some doc, simplified lightdm-configuration to look a little bit
more like other display manager's services and use xorg-configuration.
We can always add more options later if needed.
I also made an attempt at factoring out the lightdm-gtk-greeter
configuration. It should be easier to add configuration of other greeter
but there might be better ways.
I'm open to suggestions but otherwise it should be mergeable.
Thanks,

Have a nice day,

L  p R n  d n


[-- Attachment #2: 0010-services-Add-lightdm-service-type.patch --]
[-- Type: text/x-patch, Size: 16269 bytes --]

From 90d8f29625eedfce9acf62ad2589498eddf1679e Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Thu, 18 Apr 2019 17:58:56 +0200
Subject: [PATCH 10/10] services: Add lightdm-service-type.

* gnu/services/lightdm.scm: Add file.
* doc/guix.texi (@deftp, @deffn): Add documentation.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 doc/guix.texi            |  81 ++++++++++++
 gnu/local.mk             |   1 +
 gnu/services/lightdm.scm | 272 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 354 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index 3f50bf77fe..03f50718d9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13680,6 +13680,87 @@ type @code{<sddm-configuration>}.
 @end example
 @end deffn
 
+@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 of both lightdm
+and lightdm-gtk-greeter or even using a different greeter.
+@end defvr
+
+@deftp {Data Type} lightdm-configuration
+Data type representing the lightDM service configuration.
+
+@table @asis
+@item @code{session-directory} (default:"/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{allow-empty-passwords?} (default: @code{#f})
+Whether to allow logins with empty passwords.
+
+@item @code{greeter-name} (default: "lightdm-gtk-greeter")
+The name of the default greeter to be used by LightDM.
+
+@item @code{greeter-package} (default: @code{lightdm-gtk-greeter})
+The package containing the greeter described by @code{greeter-name}
+and that will be included in the system's profile.
+
+@item @code{greeter-assets} (default: @code{(list adwaita-icon-theme gnome-themes-standard)})
+A list of packages needed by the greeter: icons, themes, fonts etc.
+
+@item @code{greeter-configuration-file} (default: (lightdm-gtk-greeter-configuration-file (lightdm-gtk-greeter-configuration)))
+The file that will be place in @code{/etc/xdg/lightdm/} directory.
+A @code{computed-file} is expected.
+
+@item @code{xorg-configuration} (default: @code{(xorg-configuration)})
+Configuration of the Xorg graphical server.
+
+@item @code{session-wrapper} (default: @code{(xinitrc)})
+The command to run for a session. It is run as the user and needs
+to exec the command passed in the arguments to complete running the session.
+
+@item @code{default-session-name} (default: @code{#f})
+The name of the default @code{.desktop} file describing as session.
+If @code {autologin-user} and @code{autologin-timeout} are defined,
+LightDM logs in directly using the session described by @code{default-session-name}.
+
+@item @code{autologin-user} (default: @code{#f})
+If @code {default-session-name} and @code{autologin-timeout} are defined,
+LightDM logs in directly as @code{autologin-user}.
+
+@item @code{autologin-timeout} (default: @code{#f})
+If @code {default-session-name} and @code{autologin-user} are defined,
+LightDM logs in automatically after @code{autologin-timeout} seconds.
+Any user activity during that time will cancel autologin
+and allow usual login through authentification.
+
+@item @code{lightdm} (default: @code{lightdm})
+The LightDM package to use.
+
+@end table
+@end deftp
+
+@deftp {Data Type} lightdm-gtk-greeter-configuration
+This data type represents the configuration for ligtdm-gtk-greeter.
+
+@table @asis
+@item @code{theme-name} (default: "Adwaita")
+The name of the GTK+ theme to be used.
+
+@item @code{icon-theme-name} (default: "Adwaita")
+The name of the icon theme to be used for displaying icons.
+
+@item @code{cursor-theme-name} (default: "Adwaita")
+The name of the theme to be used for the cursor.
+
+@item @code{cursor-size} (default: @code{16})
+The size of the cursor.
+
+@item @code{background} (default: "")
+Path to the background image to be used.
+
+@end table
+@end ftp
+
 @cindex Xorg, configuration
 @deftp {Data Type} xorg-configuration
 This data type represents the configuration of the Xorg graphical display
diff --git a/gnu/local.mk b/gnu/local.mk
index 133293aad3..782e71f0df 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -514,6 +514,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/authentication.scm		\
   %D%/services/games.scm			\
   %D%/services/kerberos.scm			\
+  %D%/services/lightdm.scm      		\
   %D%/services/lirc.scm				\
   %D%/services/virtualization.scm		\
   %D%/services/mail.scm				\
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..d0d6c20c2f
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,272 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 L  p R n  d n   <guix@lprndn.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gnu services lightdm)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type
+            lightdm-gtk-greeter-configuration
+            lightdm-gtk-greeter-configuration-file))
+
+
+(define-record-type* <lightdm-gtk-greeter-configuration>
+  lightdm-gtk-greeter-configuration make-lightdm-gtk-greeter-configuration
+  lightdm-gtk-greeter-configuration?
+  (theme-name lightdm-gtk-greeter-configuration-theme-name
+              (default "Adwaita"))
+  (icon-theme-name
+   lightdm-gtk-greeter-configuration-icon-theme-name
+   (default "Adwaita"))
+  (cursor-theme-name
+   lightdm-gtk-greeter-configuration-cursor-theme-name
+   (default "Adwaita"))
+  (cursor-size lightdm-gtk-greeter-configuration-cursor-size
+               (default 16))
+  (background lightdm-gtk-greeter-configuration-background
+              (default "")))
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "        (lightdm-gtk-greeter-configuration-theme-name config) "
+icon-theme-name = "   (lightdm-gtk-greeter-configuration-icon-theme-name config) "
+cursor-theme-name = " (lightdm-gtk-greeter-configuration-cursor-theme-name config) "
+cursor-theme-size = " (number->string
+                       (lightdm-gtk-greeter-configuration-cursor-size config)) "
+background = "        (lightdm-gtk-greeter-configuration-background config)))
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (sessions-directory lightdm-configuration-sessions-directory
+                      (default (string-append
+                                "/run/current-system/profile/share/xsessions"
+                                ":/run/current-system/profile/share/wayland-sessions")))
+  (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
+                          (default #f))
+  ;; [Seat]
+  (xorg-configuration lightdm-configuration-xorg
+                      (default (xorg-configuration)))
+  (session-wrapper lightdm-configuration-session-wrapper
+                   (default (xinitrc)))
+  (default-session-name lightdm-configuration-default-session
+    (default ""))
+
+  ;; [Autologin]
+  (autologin-user lightdm-configuration-autologin-user
+                  (default #f))
+  (autologin-timeout lightdm-configuration-autologin-timeout
+                     (default #f))
+  ;; [Greeter]
+  (greeter-name lightdm-configuration-greeter-name
+                (default "lightdm-gtk-greeter"))
+  (greeter-package lightdm-configuration-greeter-package
+                   (default lightdm-gtk-greeter))
+  (greeter-assets lightdm-configuration-greeter-assets
+                  (default (list adwaita-icon-theme
+                                 gnome-themes-standard)))
+  (greeter-configuration-file lightdm-configuration-greeter-configuration
+                              (default (lightdm-gtk-greeter-configuration-file
+                                        (lightdm-gtk-greeter-configuration)))))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LighDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+
+(define (lightdm-configuration-file config)
+  (mixed-text-file "lightdm.conf" "
+[LightDM]
+greeter-user = lightdm
+greeters-directory = /run/current-system/profile/share/xgreeters
+sessions-directory = "  (lightdm-configuration-sessions-directory config) "
+
+
+[Seat:*]
+xserver-command = "  (xorg-start-command (lightdm-configuration-xorg config)) "
+greeter-session = "       (lightdm-configuration-greeter-name config) "
+user-session = "          (lightdm-configuration-default-session config)
+(if (lightdm-configuration-autologin-user config) (string-append "
+autologin-user = " (lightdm-configuration-autologin-user config)) "")
+(if (string-null? (lightdm-configuration-default-session config)) ""
+    (string-append "
+autologin-session = " (lightdm-configuration-default-session config)))
+(if (lightdm-configuration-autologin-timeout config) (string-append "
+autologin-user-timeout = " (lightdm-configuration-autologin-timeout config)) "") "
+session-wrapper = " (lightdm-configuration-session-wrapper config)))
+
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))
+     (pam-entry (control "required") (module "pam_env.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+     ;; Load environment from /etc/environment and ~/.pam_environment
+     (pam-entry (control "required") (module "pam_env.so"))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list (string-append #$(lightdm-configuration-lightdm config) "/sbin/lightdm")))
+
+  (list (shepherd-service
+         (documentation "LightDM display manager.")
+         (requirement '(dbus-system user-processes host-name))
+         (provision '(display-manager))
+         (respawn? #f)
+         (start #~(lambda ()
+                    (fork+exec-command
+                     (list #$(file-append
+                              (lightdm-configuration-lightdm config)
+                              "/sbin/lightdm"))
+                     #:environment-variables
+                     (list
+                      (string-append
+                       "PATH=/run/current-system/profile/sbin"
+                       ":/run/current-system/profile/bin")))))
+         (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+          ,(lightdm-configuration-file config))
+        `(,(string-append "xdg/lightdm/"
+                          (computed-file-name
+                           (lightdm-configuration-greeter-configuration config)))
+          ,(lightdm-configuration-greeter-configuration config))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-profile-service config)
+  (append (list lightdm
+                (lightdm-configuration-greeter-package config))
+          (lightdm-configuration-greeter-assets config)))
+
+(define (lightdm-activation-service config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (define %user
+          (getpw "lightdm"))
+        (let ((directory "/var/lib/lightdm-data"))
+          (mkdir-p directory)
+          (chown directory (passwd:uid %user) (passwd:gid %user))))))
+
+(define lightdm-service-type
+  (service-type (name 'lightdm)
+                (extensions
+                 (list
+                  (service-extension shepherd-root-service-type
+                                     lightdm-shepherd-service)
+                  (service-extension activation-service-type
+                                     lightdm-activation-service)
+                  (service-extension pam-root-service-type
+                                     lightdm-pam-services)
+                  (service-extension etc-service-type
+                                     lightdm-etc-service)
+                  (service-extension dbus-root-service-type
+                                     (compose list lightdm-configuration-lightdm))
+                  (service-extension account-service-type
+                                     (const %lightdm-accounts))
+                  (service-extension profile-service-type
+                                     lightdm-profile-service)))
+                (default-value (lightdm-configuration))
+                (description "Return a service that spawns the LightDM graphical login
+ manager.")))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] Acknowledgement ([WIP] LightDM service)
       [not found] ` <handler.35305.B.155550391014002.ack@debbugs.gnu.org>
  2019-04-18 13:20   ` [bug#35305] Acknowledgement ([WIP] LightDM service) L p R n d n
@ 2019-08-26 15:58   ` L p R n d n
  2020-03-15 21:50     ` Nicolò Balzarotti
  1 sibling, 1 reply; 30+ messages in thread
From: L p R n d n @ 2019-08-26 15:58 UTC (permalink / raw)
  To: 35305

ping

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] Acknowledgement ([WIP] LightDM service)
  2019-08-26 15:58   ` L p R n d n
@ 2020-03-15 21:50     ` Nicolò Balzarotti
  2020-03-16  7:34       ` Efraim Flashner
  2020-03-19 11:54       ` [bug#35305] LightDM service L p R n d n
  0 siblings, 2 replies; 30+ messages in thread
From: Nicolò Balzarotti @ 2020-03-15 21:50 UTC (permalink / raw)
  To: L p R n d n, 35305

Cool, I was wondering why the lightdm package was available but no
service was provided for it.  Anything blocking this patch?

Thanks, Nicolò

L  p R n  d n    <guix@lprndn.info> writes:

> ping

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] Acknowledgement ([WIP] LightDM service)
  2020-03-15 21:50     ` Nicolò Balzarotti
@ 2020-03-16  7:34       ` Efraim Flashner
  2020-03-16  8:36         ` L p R n d n
  2020-03-19 11:54       ` [bug#35305] LightDM service L p R n d n
  1 sibling, 1 reply; 30+ messages in thread
From: Efraim Flashner @ 2020-03-16  7:34 UTC (permalink / raw)
  To: Nicolò Balzarotti; +Cc: 35305, L p R n d n

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

On Sun, Mar 15, 2020 at 10:50:07PM +0100, Nicolò Balzarotti wrote:
> Cool, I was wondering why the lightdm package was available but no
> service was provided for it.  Anything blocking this patch?
> 
> Thanks, Nicolò
> 
> L  p R n  d n    <guix@lprndn.info> writes:
> 
> > ping

I don't think anyone got around to reviewing it :/

-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] Acknowledgement ([WIP] LightDM service)
  2020-03-16  7:34       ` Efraim Flashner
@ 2020-03-16  8:36         ` L p R n d n
  0 siblings, 0 replies; 30+ messages in thread
From: L p R n d n @ 2020-03-16  8:36 UTC (permalink / raw)
  To: Efraim Flashner; +Cc: 35305, Nicolò Balzarotti


Hello,

Also a rebase on latest master might be necessary. I was waiting for
staging to be merged so if I got time, I'll probably take care of this
during the week. ;)

Have a nice day,

L  p R n  d n   

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-03-15 21:50     ` Nicolò Balzarotti
  2020-03-16  7:34       ` Efraim Flashner
@ 2020-03-19 11:54       ` L p R n d n
  1 sibling, 0 replies; 30+ messages in thread
From: L p R n d n @ 2020-03-19 11:54 UTC (permalink / raw)
  To: 35305

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

Hello,

Here is the new set of reworked patches. I tested it quickly in a
vm with xfce and gnome (login, logout, switch user) and it seems ok.
I also attach a little scm file with a simple system definition with
lightdm and xfce for those willing to test it.
(also the password is "q" without quotes).

Have a nice day,


L  p R n  d n


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-lightdm-Update-1.30.0.patch --]
[-- Type: text/x-patch, Size: 1547 bytes --]

From 461b4c27816d4340a37209ca5389d7ec9f373581 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:16:39 +0200
Subject: [PATCH 01/10] gnu: lightdm: Update 1.30.0.

* gnu/packages/display-managers.scm (lightdm): Update to 1.30.0.
---
 gnu/packages/display-managers.scm | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index bfe1a8f6dd..2f81f10140 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -125,16 +125,15 @@ create smooth, animated user interfaces.")
 (define-public lightdm
   (package
     (name "lightdm")
-    (version "1.24.0")
+    (version "1.30.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append "https://launchpad.net/lightdm/"
-                                  (version-major+minor version) "/"
-                                  version "/+download/lightdm-"
-                                  version ".tar.xz"))
+              (uri (string-append
+                    "https://github.com/CanonicalLtd/lightdm/releases/download/"
+                    version "/lightdm-" version ".tar.xz"))
               (sha256
                (base32
-                "18j33bm54i8k7ncxcs69zqi4105s62n58jrydqn3ikrb71s9nl6d"))))
+                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-lightdm-Add-vala-bindings.patch --]
[-- Type: text/x-patch, Size: 851 bytes --]

From a2d8e9027e12dabb0acebd3c32aff555727c4129 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:21:55 +0200
Subject: [PATCH 02/10] gnu: lightdm: Add vala bindings.

* gnu/packages/display-managers.scm (lightdm) [native-inputs]: Add vala.
---
 gnu/packages/display-managers.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 2f81f10140..1f4842bff3 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -180,6 +180,7 @@ create smooth, animated user interfaces.")
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
+       ("vala" ,vala)                   ;For vala bindings
        ;; For tests
        ("dbus" ,dbus)
        ("python" ,python-2)
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-gnu-lightdm-Disable-python-tests-only.patch --]
[-- Type: text/x-patch, Size: 5881 bytes --]

From 356da33c8cf358757fdf39393d6edde1b702b408 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:26:22 +0200
Subject: [PATCH 03/10] gnu: lightdm: Disable python tests only.

* gnu/packages/patches/lightdm-disable-python-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/display-managers.scm (lightdm)[source]: Use patch.
* gnu/packages/display-managers.scm (lightdm)[arguments]: Remove
test-python-greeter wrapping.
* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Remove python
and python-gobject.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/display-managers.scm             | 30 +++++---------
 .../lightdm-disable-python-tests.patch        | 40 +++++++++++++++++++
 3 files changed, 50 insertions(+), 21 deletions(-)
 create mode 100644 gnu/packages/patches/lightdm-disable-python-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index caa73d44d4..fc9030b7f9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1144,6 +1144,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/lierolibre-newer-libconfig.patch		\
   %D%/packages/patches/lierolibre-remove-arch-warning.patch	\
   %D%/packages/patches/lierolibre-try-building-other-arch.patch	\
+  %D%/packages/patches/lightdm-disable-python-tests.patch	\
   %D%/packages/patches/linkchecker-tests-require-network.patch	\
   %D%/packages/patches/linux-pam-no-setfsuid.patch		\
   %D%/packages/patches/lirc-localstatedir.patch			\
diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 1f4842bff3..56725f8302 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -127,13 +127,14 @@ create smooth, animated user interfaces.")
     (name "lightdm")
     (version "1.30.0")
     (source (origin
-              (method url-fetch)
-              (uri (string-append
-                    "https://github.com/CanonicalLtd/lightdm/releases/download/"
-                    version "/lightdm-" version ".tar.xz"))
-              (sha256
-               (base32
-                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))))
+             (method url-fetch)
+             (uri (string-append
+                   "https://github.com/CanonicalLtd/lightdm/releases/download/"
+                   version "/lightdm-" version ".tar.xz"))
+             (sha256
+              (base32
+               "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))
+             (patches (search-patches "lightdm-disable-python-tests.patch"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
@@ -152,19 +153,8 @@ create smooth, animated user interfaces.")
              (substitute* "src/seat.c"
                (("/bin/sh") (which "sh")))
              #t))
-         (add-after 'unpack 'disable-broken-tests
-           (lambda _
-             (substitute* "tests/Makefile.in"
-               (("test-sessions-gobject ") "")
-               ((" test-sessions-python ") " "))
-             #t))
          (add-before 'check 'pre-check
-           ;; Run test-suite under a dbus session.
            (lambda* (#:key inputs #:allow-other-keys)
-             (wrap-program "tests/src/test-python-greeter"
-               `("PYTHONPATH"      ":" prefix (,(getenv "PYTHONPATH")))
-               `("GI_TYPELIB_PATH" ":" prefix (,(getenv "GI_TYPELIB_PATH"))))
-
              ;; Avoid printing locale warnings, which trip up the text
              ;; matching tests.
              (unsetenv "LC_ALL")
@@ -182,9 +172,7 @@ create smooth, animated user interfaces.")
        ("intltool" ,intltool)
        ("vala" ,vala)                   ;For vala bindings
        ;; For tests
-       ("dbus" ,dbus)
-       ("python" ,python-2)
-       ("python-pygobject" ,python2-pygobject)))
+       ("dbus" ,dbus)))
     ;; Required by liblightdm-gobject-1.pc.
     (propagated-inputs
      `(("glib" ,glib)
diff --git a/gnu/packages/patches/lightdm-disable-python-tests.patch b/gnu/packages/patches/lightdm-disable-python-tests.patch
new file mode 100644
index 0000000000..b1850f279c
--- /dev/null
+++ b/gnu/packages/patches/lightdm-disable-python-tests.patch
@@ -0,0 +1,40 @@
+ tests/Makefile.in | 23 -----------------------
+ 1 file changed, 23 deletions(-)
+
+diff --git a/tests/Makefile.in b/tests/Makefile.in
+index 9451a6f..46c027c 100644
+--- a/tests/Makefile.in
++++ b/tests/Makefile.in
+@@ -810,29 +810,6 @@ TESTS = test-xserver-fail-start test-greeter-fail-start \
+ 	test-wayland-autologin test-wayland-greeter \
+ 	test-wayland-session test-invalid-seat \
+ 	test-seatdefaults-still-supported \
+-	test-autologin-timeout-python \
+-	test-autologin-guest-timeout-python \
+-	test-autologin-session-timeout-python \
+-	test-cancel-authentication-python test-sessions-python \
+-	test-users-python test-login-python test-login-manual-python \
+-	test-login-manual-previous-session-python \
+-	test-login-no-password-python test-login-long-username-python \
+-	test-login-long-password-python test-login-two-factor-python \
+-	test-login-new-authtok-python test-login-info-prompt-python \
+-	test-login-multi-info-prompt-python \
+-	test-login-previous-session-python \
+-	test-login-wrong-password-python \
+-	test-login-invalid-user-python \
+-	test-login-invalid-session-python test-login-logout-python \
+-	test-login-pick-session-python \
+-	test-login-remember-session-python \
+-	test-login-manual-remember-session-python \
+-	test-login-guest-python test-login-guest-pick-session-python \
+-	test-login-guest-disabled-python \
+-	test-login-guest-no-setup-script-python \
+-	test-login-guest-fail-setup-script-python \
+-	test-login-guest-logout-python \
+-	test-login-remote-session-python test-power-python \
+ 	$(am__append_1) $(am__append_2)
+ EXTRA_DIST = \
+ 	$(TESTS) \
+-- 
+2.25.1
+
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-gnu-lightdm-gtk-greeter-Update-to-2.0.7.patch --]
[-- Type: text/x-patch, Size: 1308 bytes --]

From b7026a6b9cfb43ae3f7a2105b1681cc73281854d Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:40:38 +0200
Subject: [PATCH 04/10] gnu: lightdm-gtk-greeter: Update to 2.0.7.

* gnu/packages/display-manager.scm (lightdm-gtk-greeter): Update to 2.0.7.
---
 gnu/packages/display-managers.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 56725f8302..9e02eaed33 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -187,7 +187,7 @@ display manager which supports different greeters.")
 (define-public lightdm-gtk-greeter
   (package
     (name "lightdm-gtk-greeter")
-    (version "2.0.2")
+    (version "2.0.7")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -196,7 +196,7 @@ display manager which supports different greeters.")
                     "/+download/lightdm-gtk-greeter-" version ".tar.gz"))
               (sha256
                (base32
-                "1436sdm83xqhxyr1rzqxhsl8if2xmidlvb341xcv6dv83lyxkrlf"))))
+                "1g7wc3d3vqfa7mrdhx1w9ywydgjbffla6rbrxq9k3sc62br97qms"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("exo" ,exo)
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-gnu-lightdm-gtk-greeter-Fix-at-spi-runtime-dependenc.patch --]
[-- Type: text/x-patch, Size: 1315 bytes --]

From 172167821db646e82c1fceef5dced9f2dcf49fd8 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:50:58 +0200
Subject: [PATCH 05/10] gnu: lightdm-gtk-greeter: Fix at-spi runtime
 dependency.

* gnu/packages/display-manager.scm (lightdm): Fix at-spi runtime dependency.
[inputs]: Add at-spi2-core.
[arguments]: Add '--enable-at-spi-command' configure flag.
---
 gnu/packages/display-managers.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 9e02eaed33..29f91ad1fc 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -204,7 +204,13 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
+    (arguments
+     `(#:configure-flags
+       (list (string-append "--enable-at-spi-command="
+                            (assoc-ref %build-inputs "at-spi2-core")
+                            "/libexec/at-spi-bus-launcher"))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-gnu-lightdm-gtk-greeter-Fix-.desktop-file.patch --]
[-- Type: text/x-patch, Size: 1682 bytes --]

From 5e77afbfeb70892c7065927ac3223941679e5f59 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:58:26 +0200
Subject: [PATCH 06/10] gnu: lightdm-gtk-greeter: Fix .desktop file.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix .desktop file
  path.
[arguments]: Add fix-.desktop-path phase.
---
 gnu/packages/display-managers.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 29f91ad1fc..ec0f685063 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,7 +210,17 @@ display manager which supports different greeters.")
      `(#:configure-flags
        (list (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
-                            "/libexec/at-spi-bus-launcher"))))
+                            "/libexec/at-spi-bus-launcher"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'fix-.desktop-path
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (substitute* (string-append
+                             out "/share/xgreeters/lightdm-gtk-greeter.desktop")
+                 (("Exec=lightdm-gtk-greeter")
+                  (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
+               #t))))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-gnu-lightdm-gtk-greeter-Wrap-binary.patch --]
[-- Type: text/x-patch, Size: 2958 bytes --]

From 11ab812bca3d9c2a1a53355d4ea2710861377275 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 14:17:18 +0200
Subject: [PATCH 07/10] gnu: lightdm-gtk-greeter: Wrap binary.

* gnu/package/display-managers.scm (lightdm-gtk-greeter): Wrap binary.
[inputs]: Add hicolor-icon-theme.
[arguments]: Add wrap-program phase.
---
 gnu/packages/display-managers.scm | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index ec0f685063..4c2391951b 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -205,6 +205,7 @@ display manager which supports different greeters.")
     (inputs
      `(("lightdm" ,lightdm)
        ("at-spi2-core" ,at-spi2-core)
+       ("hicolor-icon-theme" ,hicolor-icon-theme)
        ("gtk+" ,gtk+)))
     (arguments
      `(#:configure-flags
@@ -220,7 +221,27 @@ display manager which supports different greeters.")
                              out "/share/xgreeters/lightdm-gtk-greeter.desktop")
                  (("Exec=lightdm-gtk-greeter")
                   (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
-               #t))))))
+               #t)))
+         (add-after 'fix-.desktop-path 'wrap-program
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (wrap-program (string-append (assoc-ref outputs "out")
+                                          "/sbin/lightdm-gtk-greeter")
+               `("XDG_DATA_DIRS" ":" prefix (,(string-append (assoc-ref inputs "hicolor-icon-theme")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "glib")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "shared-mime-info")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "gtk+")
+                                                             "/share")
+                                             ,(string-append (assoc-ref inputs "exo")
+                                                             "/share")
+                                             ,(string-append (assoc-ref outputs "out")
+                                                             "/share")
+                                             "/run/current-system/profile/share"))
+               `("GTK_PATH" ":" prefix (,(assoc-ref inputs "gtk+")))
+               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+"))))
+             #t)))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #9: 0008-gnu-lightdm-Build-accountsservice-files.patch --]
[-- Type: text/x-patch, Size: 997 bytes --]

From d83b7241279cf8d672241cb28bd7f719619e6a61 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Tue, 16 Apr 2019 19:46:44 +0200
Subject: [PATCH 08/10] gnu: lightdm: Build accountsservice files.

* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Add accountsservice.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 4c2391951b..50a43c125f 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -166,7 +166,8 @@ create smooth, animated user interfaces.")
        ("libgcrypt" ,libgcrypt)
        ("libxcb" ,libxcb)))
     (native-inputs
-     `(("gobject-introspection" ,gobject-introspection)
+     `(("accountsservice" ,accountsservice)
+       ("gobject-introspection" ,gobject-introspection)
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #10: 0009-gnu-lightdm-gtk-greeter-Fix-some-warnings.patch --]
[-- Type: text/x-patch, Size: 1122 bytes --]

From 1d3f159d3b3205c118325266f1867f439d0d9a46 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Wed, 17 Apr 2019 12:44:07 +0200
Subject: [PATCH 09/10] gnu: lightdm-gtk-greeter: Fix some warnings.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix some warnings.
[arguments]: Add '--disable-indicator-services-command' configure flags.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 50a43c125f..62387b14a5 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,7 +210,8 @@ display manager which supports different greeters.")
        ("gtk+" ,gtk+)))
     (arguments
      `(#:configure-flags
-       (list (string-append "--enable-at-spi-command="
+       (list "--disable-indicator-services-command"
+             (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
                             "/libexec/at-spi-bus-launcher"))
        #:phases
-- 
2.25.1


[-- Attachment #11: 0010-services-Add-lightdm-service-type.patch --]
[-- Type: text/x-patch, Size: 16242 bytes --]

From 66fadb0425815c9802f06ff96f99349687313cd0 Mon Sep 17 00:00:00 2001
From: Lprndn <guix@lprndn.info>
Date: Thu, 18 Apr 2019 17:58:56 +0200
Subject: [PATCH 10/10] services: Add lightdm-service-type.

* gnu/services/lightdm.scm: Add file.
* doc/guix.texi (@deftp, @deffn): Add documentation.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 doc/guix.texi            |  81 ++++++++++++
 gnu/local.mk             |   1 +
 gnu/services/lightdm.scm | 272 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 354 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index a0920adc1c..d66cba28d1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14664,6 +14664,87 @@ auto-login session.
 @end table
 @end deftp
 
+@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 of both lightdm
+and lightdm-gtk-greeter or even using a different greeter.
+@end defvr
+
+@deftp {Data Type} lightdm-configuration
+Data type representing the lightDM service configuration.
+
+@table @asis
+@item @code{session-directory} (default:"/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{allow-empty-passwords?} (default: @code{#f})
+Whether to allow logins with empty passwords.
+
+@item @code{greeter-name} (default: "lightdm-gtk-greeter")
+The name of the default greeter to be used by LightDM.
+
+@item @code{greeter-package} (default: @code{lightdm-gtk-greeter})
+The package containing the greeter described by @code{greeter-name}
+and that will be included in the system's profile.
+
+@item @code{greeter-assets} (default: @code{(list adwaita-icon-theme gnome-themes-standard)})
+A list of packages needed by the greeter: icons, themes, fonts etc.
+
+@item @code{greeter-configuration-file} (default: (lightdm-gtk-greeter-configuration-file (lightdm-gtk-greeter-configuration)))
+The file that will be place in @code{/etc/xdg/lightdm/} directory.
+A @code{computed-file} is expected.
+
+@item @code{xorg-configuration} (default: @code{(xorg-configuration)})
+Configuration of the Xorg graphical server.
+
+@item @code{session-wrapper} (default: @code{(xinitrc)})
+The command to run for a session. It is run as the user and needs
+to exec the command passed in the arguments to complete running the session.
+
+@item @code{default-session-name} (default: @code{#f})
+The name of the default @code{.desktop} file describing as session.
+If @code {autologin-user} and @code{autologin-timeout} are defined,
+LightDM logs in directly using the session described by @code{default-session-name}.
+
+@item @code{autologin-user} (default: @code{#f})
+If @code {default-session-name} and @code{autologin-timeout} are defined,
+LightDM logs in directly as @code{autologin-user}.
+
+@item @code{autologin-timeout} (default: @code{#f})
+If @code {default-session-name} and @code{autologin-user} are defined,
+LightDM logs in automatically after @code{autologin-timeout} seconds.
+Any user activity during that time will cancel autologin
+and allow usual login through authentification.
+
+@item @code{lightdm} (default: @code{lightdm})
+The LightDM package to use.
+
+@end table
+@end deftp
+
+@deftp {Data Type} lightdm-gtk-greeter-configuration
+This data type represents the configuration for ligtdm-gtk-greeter.
+
+@table @asis
+@item @code{theme-name} (default: "Adwaita")
+The name of the GTK+ theme to be used.
+
+@item @code{icon-theme-name} (default: "Adwaita")
+The name of the icon theme to be used for displaying icons.
+
+@item @code{cursor-theme-name} (default: "Adwaita")
+The name of the theme to be used for the cursor.
+
+@item @code{cursor-size} (default: @code{16})
+The size of the cursor.
+
+@item @code{background} (default: "")
+Path to the background image to be used.
+
+@end table
+@end deftp
+
 @cindex Xorg, configuration
 @deftp {Data Type} xorg-configuration
 This data type represents the configuration of the Xorg graphical display
diff --git a/gnu/local.mk b/gnu/local.mk
index fc9030b7f9..5ab96c121e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -561,6 +561,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/getmail.scm				\
   %D%/services/guix.scm			\
   %D%/services/kerberos.scm			\
+  %D%/services/lightdm.scm      		\
   %D%/services/lirc.scm				\
   %D%/services/virtualization.scm		\
   %D%/services/mail.scm				\
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..d0d6c20c2f
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,272 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 L  p R n  d n   <guix@lprndn.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gnu services lightdm)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type
+            lightdm-gtk-greeter-configuration
+            lightdm-gtk-greeter-configuration-file))
+
+
+(define-record-type* <lightdm-gtk-greeter-configuration>
+  lightdm-gtk-greeter-configuration make-lightdm-gtk-greeter-configuration
+  lightdm-gtk-greeter-configuration?
+  (theme-name lightdm-gtk-greeter-configuration-theme-name
+              (default "Adwaita"))
+  (icon-theme-name
+   lightdm-gtk-greeter-configuration-icon-theme-name
+   (default "Adwaita"))
+  (cursor-theme-name
+   lightdm-gtk-greeter-configuration-cursor-theme-name
+   (default "Adwaita"))
+  (cursor-size lightdm-gtk-greeter-configuration-cursor-size
+               (default 16))
+  (background lightdm-gtk-greeter-configuration-background
+              (default "")))
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "        (lightdm-gtk-greeter-configuration-theme-name config) "
+icon-theme-name = "   (lightdm-gtk-greeter-configuration-icon-theme-name config) "
+cursor-theme-name = " (lightdm-gtk-greeter-configuration-cursor-theme-name config) "
+cursor-theme-size = " (number->string
+                       (lightdm-gtk-greeter-configuration-cursor-size config)) "
+background = "        (lightdm-gtk-greeter-configuration-background config)))
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (sessions-directory lightdm-configuration-sessions-directory
+                      (default (string-append
+                                "/run/current-system/profile/share/xsessions"
+                                ":/run/current-system/profile/share/wayland-sessions")))
+  (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
+                          (default #f))
+  ;; [Seat]
+  (xorg-configuration lightdm-configuration-xorg
+                      (default (xorg-configuration)))
+  (session-wrapper lightdm-configuration-session-wrapper
+                   (default (xinitrc)))
+  (default-session-name lightdm-configuration-default-session
+    (default ""))
+
+  ;; [Autologin]
+  (autologin-user lightdm-configuration-autologin-user
+                  (default #f))
+  (autologin-timeout lightdm-configuration-autologin-timeout
+                     (default #f))
+  ;; [Greeter]
+  (greeter-name lightdm-configuration-greeter-name
+                (default "lightdm-gtk-greeter"))
+  (greeter-package lightdm-configuration-greeter-package
+                   (default lightdm-gtk-greeter))
+  (greeter-assets lightdm-configuration-greeter-assets
+                  (default (list adwaita-icon-theme
+                                 gnome-themes-standard)))
+  (greeter-configuration-file lightdm-configuration-greeter-configuration
+                              (default (lightdm-gtk-greeter-configuration-file
+                                        (lightdm-gtk-greeter-configuration)))))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LighDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+
+(define (lightdm-configuration-file config)
+  (mixed-text-file "lightdm.conf" "
+[LightDM]
+greeter-user = lightdm
+greeters-directory = /run/current-system/profile/share/xgreeters
+sessions-directory = "  (lightdm-configuration-sessions-directory config) "
+
+
+[Seat:*]
+xserver-command = "  (xorg-start-command (lightdm-configuration-xorg config)) "
+greeter-session = "       (lightdm-configuration-greeter-name config) "
+user-session = "          (lightdm-configuration-default-session config)
+(if (lightdm-configuration-autologin-user config) (string-append "
+autologin-user = " (lightdm-configuration-autologin-user config)) "")
+(if (string-null? (lightdm-configuration-default-session config)) ""
+    (string-append "
+autologin-session = " (lightdm-configuration-default-session config)))
+(if (lightdm-configuration-autologin-timeout config) (string-append "
+autologin-user-timeout = " (lightdm-configuration-autologin-timeout config)) "") "
+session-wrapper = " (lightdm-configuration-session-wrapper config)))
+
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))
+     (pam-entry (control "required") (module "pam_env.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+     ;; Load environment from /etc/environment and ~/.pam_environment
+     (pam-entry (control "required") (module "pam_env.so"))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list (string-append #$(lightdm-configuration-lightdm config) "/sbin/lightdm")))
+
+  (list (shepherd-service
+         (documentation "LightDM display manager.")
+         (requirement '(dbus-system user-processes host-name))
+         (provision '(display-manager))
+         (respawn? #f)
+         (start #~(lambda ()
+                    (fork+exec-command
+                     (list #$(file-append
+                              (lightdm-configuration-lightdm config)
+                              "/sbin/lightdm"))
+                     #:environment-variables
+                     (list
+                      (string-append
+                       "PATH=/run/current-system/profile/sbin"
+                       ":/run/current-system/profile/bin")))))
+         (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+          ,(lightdm-configuration-file config))
+        `(,(string-append "xdg/lightdm/"
+                          (computed-file-name
+                           (lightdm-configuration-greeter-configuration config)))
+          ,(lightdm-configuration-greeter-configuration config))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-profile-service config)
+  (append (list lightdm
+                (lightdm-configuration-greeter-package config))
+          (lightdm-configuration-greeter-assets config)))
+
+(define (lightdm-activation-service config)
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+        (define %user
+          (getpw "lightdm"))
+        (let ((directory "/var/lib/lightdm-data"))
+          (mkdir-p directory)
+          (chown directory (passwd:uid %user) (passwd:gid %user))))))
+
+(define lightdm-service-type
+  (service-type (name 'lightdm)
+                (extensions
+                 (list
+                  (service-extension shepherd-root-service-type
+                                     lightdm-shepherd-service)
+                  (service-extension activation-service-type
+                                     lightdm-activation-service)
+                  (service-extension pam-root-service-type
+                                     lightdm-pam-services)
+                  (service-extension etc-service-type
+                                     lightdm-etc-service)
+                  (service-extension dbus-root-service-type
+                                     (compose list lightdm-configuration-lightdm))
+                  (service-extension account-service-type
+                                     (const %lightdm-accounts))
+                  (service-extension profile-service-type
+                                     lightdm-profile-service)))
+                (default-value (lightdm-configuration))
+                (description "Return a service that spawns the LightDM graphical login
+ manager.")))
-- 
2.25.1


[-- Attachment #12: lightdm-desktop-test.scm --]
[-- Type: text/plain, Size: 2261 bytes --]

;; This is an operating system configuration template
;; for a "desktop" setup without full-blown desktop
;; environments.

(use-modules (gnu) (gnu system nss) (srfi srfi-1))
(use-service-modules desktop lightdm xorg)
(use-package-modules bootloaders certs)

(operating-system
  (host-name "antelope")
  (timezone "Europe/Paris")
  (locale "en_US.utf8")

  ;; Use the UEFI variant of GRUB with the EFI System
  ;; Partition mounted on /boot/efi.
  (bootloader (bootloader-configuration
                (bootloader grub-efi-bootloader)
                (target "/boot/efi")))

  ;; Assume the target root file system is labelled "my-root",
  ;; and the EFI System Partition has UUID 1234-ABCD.
  (file-systems (append
                 (list (file-system
                         (device (file-system-label "my-root"))
                         (mount-point "/")
                         (type "ext4"))
                       (file-system
                         (device (uuid "1234-ABCD" 'fat))
                         (mount-point "/boot/efi")
                         (type "vfat")))
                 %base-file-systems))

  (users (cons (user-account
                (name "alice")
                (comment "Bob's sister")
                ;; Password is "q" (without quotes)
                (password "a2l/LaE8AKHIY")
                (group "users")
                (supplementary-groups '("wheel" "netdev"
                                        "audio" "video")))
               %base-user-accounts))

  ;; Add a bunch of window managers; we can choose one at
  ;; the log-in screen with F1.
  (packages (append (list
                     ;; for HTTPS access
                     nss-certs)
                    %base-packages))

  ;; Use the "desktop" services, which include the X11
  ;; log-in service, networking with NetworkManager, and more.
  (services (cons*
             (service lightdm-service-type)
             (service xfce-desktop-service-type)
             (modify-services
                 (remove (lambda (service)
                           (eq? (service-kind service) gdm-service-type))
                         %desktop-services))))

  ;; Allow resolution of '.local' host names with mDNS.
  (name-service-switch %mdns-host-lookup-nss))

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2019-04-17 14:24 [bug#35305] [WIP] LightDM service L p R n d n
                   ` (2 preceding siblings ...)
  2019-05-23 11:04 ` [bug#35305] [PATCH] " L p R n d n
@ 2020-04-07 17:06 ` Brice Waegeneire
  2020-04-09 16:02   ` L p R n d n
  2020-05-06 14:05 ` L p R n d n
  2022-08-31  7:13 ` bug#35305: " Ricardo Wurmus
  5 siblings, 1 reply; 30+ messages in thread
From: Brice Waegeneire @ 2020-04-07 17:06 UTC (permalink / raw)
  To: guix; +Cc: 35305

Hello L p R n d n,

I never did a review before but I would like to see this patch merged, 
so
bear with me.

The indentation of lightdm's origin should probably be done in the 
commit
01 not 03.

> `("XDG_DATA_DIRS" ":" prefix (,(string-append (assoc-ref inputs 
> "hicolor-icon-theme")
>                                               "/share")
>                               ,(string-append (assoc-ref inputs "glib")
>                                               "/share")
>                               ,(string-append (assoc-ref inputs 
> "shared-mime-info")
>                                               "/share")
>                               ,(string-append (assoc-ref inputs "gtk+")
>                                               "/share")
>                               ,(string-append (assoc-ref inputs "exo")
>                                               "/share")
>                               ,(string-append (assoc-ref outputs "out")
>                                               "/share")
>                               "/run/current-system/profile/share"))
This part can use a map procedure.

It would be nice if “lightdm-service-type” support 
“set-xorg-configuration”
like the other login manager now does by using 
“handle-xorg-configuration”
see 50be0da7bfd5c108697679effeb2a893d2f37598 for how it's done in GDM, 
SLIM
and co.

> +         (comment "LighDM user")
                           ^ a “t” is missing here

> +(define (lightdm-shepherd-service config)
> +  "Return a <lightdm-service> for LightDM with CONFIG."
> +
> +  (define lightdm-command
> +    #~(list (string-append #$(lightdm-configuration-lightdm config) 
> "/sbin/lightdm")))
[…]
> + (fork+exec-command
> + (list #$(file-append
> + (lightdm-configuration-lightdm config)
> + "/sbin/lightdm"))

“lightdm-command” isn't used, I get the hint it ought to be the argument 
of
“fork+exec-command.”


> +(define (lightdm-etc-service config)
> +  (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
> +          ,(lightdm-configuration-file config))
> +        `(,(string-append "xdg/lightdm/"
> +                          (computed-file-name
> +                           
> (lightdm-configuration-greeter-configuration config)))
> +          ,(lightdm-configuration-greeter-configuration config))))

I've been told, in Guix, it's better to avoid putting configuration in
“/etc” since it cause edge case during rollback and such, specifying the
configuration by passing the “--config” argument to “lightdm” would be 
more
appropriate.

> +        (define %user
> +          (getpw "lightdm"))
> +        (let ((directory "/var/lib/lightdm-data"))
> +          (mkdir-p directory)
> +          (chown directory (passwd:uid %user) (passwd:gid %user))))))

“%user” could go in the “let”. BTW can't lightdm use its user home
directory instead of “/var/lib/lightdm-data” or the reverse; IOW does it
need to have to own two directories in “/var/lib”?

Several lines in “gnu/services/lightdm.scm” exceed the maximal line 
length.


Thank you very much for this patch series. I'm impatient seeing it in 
Guix
proper.

- Brice

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-04-07 17:06 ` [bug#35305] " Brice Waegeneire
@ 2020-04-09 16:02   ` L p R n d n
  2020-04-12  9:53     ` Brice Waegeneire
  0 siblings, 1 reply; 30+ messages in thread
From: L p R n d n @ 2020-04-09 16:02 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 35305

[-- Attachment #1: Type: text/plain, Size: 4610 bytes --]

Hello,

Brice Waegeneire <brice@waegenei.re> writes:

> Hello L p R n d n,
>
> I never did a review before but I would like to see this patch merged, so
> bear with me.

Thank you for the review! It's my first service for guix so we're
probably even here. ;)

> The indentation of lightdm's origin should probably be done in the commit
> 01 not 03.

Done.

>> `("XDG_DATA_DIRS" ":" prefix (,(string-append (assoc-ref inputs
>> "hicolor-icon-theme")
>>                                               "/share")
>>                               ,(string-append (assoc-ref inputs "glib")
>>                                               "/share")
>>                               ,(string-append (assoc-ref inputs
>> "shared-mime-info")
>>                                               "/share")
>>                               ,(string-append (assoc-ref inputs "gtk+")
>>                                               "/share")
>>                               ,(string-append (assoc-ref inputs "exo")
>>                                               "/share")
>>                               ,(string-append (assoc-ref outputs "out")
>>                                               "/share")
>>                               "/run/current-system/profile/share"))
> This part can use a map procedure.

Done. + cleaned some things that weren't necessary.

> It would be nice if “lightdm-service-type” support “set-xorg-configuration”
> like the other login manager now does by using “handle-xorg-configuration”
> see 50be0da7bfd5c108697679effeb2a893d2f37598 for how it's done in GDM, SLIM
> and co.
>
>> +         (comment "LighDM user")
>                           ^ a “t” is missing here

Huh.. Done (I think...) and done!

>> +(define (lightdm-shepherd-service config)
>> +  "Return a <lightdm-service> for LightDM with CONFIG."
>> +
>> +  (define lightdm-command
>> +    #~(list (string-append #$(lightdm-configuration-lightdm config)
>> "/sbin/lightdm")))
> […]
>> + (fork+exec-command
>> + (list #$(file-append
>> + (lightdm-configuration-lightdm config)
>> + "/sbin/lightdm"))
>
> “lightdm-command” isn't used, I get the hint it ought to be the argument of
> “fork+exec-command.”

Done.

>
>> +(define (lightdm-etc-service config)
>> +  (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
>> +          ,(lightdm-configuration-file config))
>> +        `(,(string-append "xdg/lightdm/"
>> +                          (computed-file-name
>> +                           (lightdm-configuration-greeter-configuration
>> config)))
>> +          ,(lightdm-configuration-greeter-configuration config))))
>
> I've been told, in Guix, it's better to avoid putting configuration in
> “/etc” since it cause edge case during rollback and such, specifying the
> configuration by passing the “--config” argument to “lightdm” would be more
> appropriate.

Need some advices here as even if "--config" works for LightDM, greeters
also search their config in /etc. They're all different so they might or
might not provide a convenient way to do it... :/
In the meantime, kept the etc-service-extension + prevented errors in
case a file wasn't provided.

>> +        (define %user
>> +          (getpw "lightdm"))
>> +        (let ((directory "/var/lib/lightdm-data"))
>> +          (mkdir-p directory)
>> +          (chown directory (passwd:uid %user) (passwd:gid %user))))))
>
> “%user” could go in the “let”. BTW can't lightdm use its user home
> directory instead of “/var/lib/lightdm-data” or the reverse; IOW does it
> need to have to own two directories in “/var/lib”?

Reworked everything a little bit to match what is done for gdm.
I think we can use a CFLAG to change "/var/lib/lightdm-data" to
"/var/lib/lightdm/lightdm-data" for example. However, I think lightdm
sometime cleans or delete stuff in "/var/lib/lightdm" so it might
explain why there are two directories. I don't know what
"/var/lib/lightdm-data" is used for but LightDM does complain if it
doesn't exist. Advices needed here too.

> Several lines in “gnu/services/lightdm.scm” exceed the maximal line length.
>

Tried to keep them below 80. Is it ok?

>
> Thank you very much for this patch series. I'm impatient seeing it in Guix
> proper.
>
> - Brice


+ Corrected some typos in the documentation and added an extra-config
field to lightd and lightdm-gtk-greeter's configuration.

Hope it's better now, new patches are attached below.

Have a nice day,

L  p R n  d n

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-lightdm-Update-1.30.0.patch --]
[-- Type: text/x-patch, Size: 1547 bytes --]

From 461b4c27816d4340a37209ca5389d7ec9f373581 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:16:39 +0200
Subject: [PATCH 01/10] gnu: lightdm: Update 1.30.0.

* gnu/packages/display-managers.scm (lightdm): Update to 1.30.0.
---
 gnu/packages/display-managers.scm | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index bfe1a8f6dd..2f81f10140 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -125,16 +125,15 @@ create smooth, animated user interfaces.")
 (define-public lightdm
   (package
     (name "lightdm")
-    (version "1.24.0")
+    (version "1.30.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append "https://launchpad.net/lightdm/"
-                                  (version-major+minor version) "/"
-                                  version "/+download/lightdm-"
-                                  version ".tar.xz"))
+              (uri (string-append
+                    "https://github.com/CanonicalLtd/lightdm/releases/download/"
+                    version "/lightdm-" version ".tar.xz"))
               (sha256
                (base32
-                "18j33bm54i8k7ncxcs69zqi4105s62n58jrydqn3ikrb71s9nl6d"))))
+                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-lightdm-Add-vala-bindings.patch --]
[-- Type: text/x-patch, Size: 851 bytes --]

From a2d8e9027e12dabb0acebd3c32aff555727c4129 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:21:55 +0200
Subject: [PATCH 02/10] gnu: lightdm: Add vala bindings.

* gnu/packages/display-managers.scm (lightdm) [native-inputs]: Add vala.
---
 gnu/packages/display-managers.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 2f81f10140..1f4842bff3 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -180,6 +180,7 @@ create smooth, animated user interfaces.")
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
+       ("vala" ,vala)                   ;For vala bindings
        ;; For tests
        ("dbus" ,dbus)
        ("python" ,python-2)
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-gnu-lightdm-Disable-python-tests-only.patch --]
[-- Type: text/x-patch, Size: 5405 bytes --]

From 524bf60a51f0775d165347a1f2bf5e82a842261d Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:26:22 +0200
Subject: [PATCH 03/10] gnu: lightdm: Disable python tests only.

* gnu/packages/patches/lightdm-disable-python-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/display-managers.scm (lightdm)[source]: Use patch.
* gnu/packages/display-managers.scm (lightdm)[arguments]: Remove
test-python-greeter wrapping.
* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Remove python
and python-gobject.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/display-managers.scm             | 18 ++-------
 .../lightdm-disable-python-tests.patch        | 40 +++++++++++++++++++
 3 files changed, 44 insertions(+), 15 deletions(-)
 create mode 100644 gnu/packages/patches/lightdm-disable-python-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index caa73d44d4..fc9030b7f9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1144,6 +1144,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/lierolibre-newer-libconfig.patch		\
   %D%/packages/patches/lierolibre-remove-arch-warning.patch	\
   %D%/packages/patches/lierolibre-try-building-other-arch.patch	\
+  %D%/packages/patches/lightdm-disable-python-tests.patch	\
   %D%/packages/patches/linkchecker-tests-require-network.patch	\
   %D%/packages/patches/linux-pam-no-setfsuid.patch		\
   %D%/packages/patches/lirc-localstatedir.patch			\
diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 1f4842bff3..eee7c6d841 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -133,7 +133,8 @@ create smooth, animated user interfaces.")
                     version "/lightdm-" version ".tar.xz"))
               (sha256
                (base32
-                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))))
+                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))
+              (patches (search-patches "lightdm-disable-python-tests.patch"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
@@ -152,19 +153,8 @@ create smooth, animated user interfaces.")
              (substitute* "src/seat.c"
                (("/bin/sh") (which "sh")))
              #t))
-         (add-after 'unpack 'disable-broken-tests
-           (lambda _
-             (substitute* "tests/Makefile.in"
-               (("test-sessions-gobject ") "")
-               ((" test-sessions-python ") " "))
-             #t))
          (add-before 'check 'pre-check
-           ;; Run test-suite under a dbus session.
            (lambda* (#:key inputs #:allow-other-keys)
-             (wrap-program "tests/src/test-python-greeter"
-               `("PYTHONPATH"      ":" prefix (,(getenv "PYTHONPATH")))
-               `("GI_TYPELIB_PATH" ":" prefix (,(getenv "GI_TYPELIB_PATH"))))
-
              ;; Avoid printing locale warnings, which trip up the text
              ;; matching tests.
              (unsetenv "LC_ALL")
@@ -182,9 +172,7 @@ create smooth, animated user interfaces.")
        ("intltool" ,intltool)
        ("vala" ,vala)                   ;For vala bindings
        ;; For tests
-       ("dbus" ,dbus)
-       ("python" ,python-2)
-       ("python-pygobject" ,python2-pygobject)))
+       ("dbus" ,dbus)))
     ;; Required by liblightdm-gobject-1.pc.
     (propagated-inputs
      `(("glib" ,glib)
diff --git a/gnu/packages/patches/lightdm-disable-python-tests.patch b/gnu/packages/patches/lightdm-disable-python-tests.patch
new file mode 100644
index 0000000000..b1850f279c
--- /dev/null
+++ b/gnu/packages/patches/lightdm-disable-python-tests.patch
@@ -0,0 +1,40 @@
+ tests/Makefile.in | 23 -----------------------
+ 1 file changed, 23 deletions(-)
+
+diff --git a/tests/Makefile.in b/tests/Makefile.in
+index 9451a6f..46c027c 100644
+--- a/tests/Makefile.in
++++ b/tests/Makefile.in
+@@ -810,29 +810,6 @@ TESTS = test-xserver-fail-start test-greeter-fail-start \
+ 	test-wayland-autologin test-wayland-greeter \
+ 	test-wayland-session test-invalid-seat \
+ 	test-seatdefaults-still-supported \
+-	test-autologin-timeout-python \
+-	test-autologin-guest-timeout-python \
+-	test-autologin-session-timeout-python \
+-	test-cancel-authentication-python test-sessions-python \
+-	test-users-python test-login-python test-login-manual-python \
+-	test-login-manual-previous-session-python \
+-	test-login-no-password-python test-login-long-username-python \
+-	test-login-long-password-python test-login-two-factor-python \
+-	test-login-new-authtok-python test-login-info-prompt-python \
+-	test-login-multi-info-prompt-python \
+-	test-login-previous-session-python \
+-	test-login-wrong-password-python \
+-	test-login-invalid-user-python \
+-	test-login-invalid-session-python test-login-logout-python \
+-	test-login-pick-session-python \
+-	test-login-remember-session-python \
+-	test-login-manual-remember-session-python \
+-	test-login-guest-python test-login-guest-pick-session-python \
+-	test-login-guest-disabled-python \
+-	test-login-guest-no-setup-script-python \
+-	test-login-guest-fail-setup-script-python \
+-	test-login-guest-logout-python \
+-	test-login-remote-session-python test-power-python \
+ 	$(am__append_1) $(am__append_2)
+ EXTRA_DIST = \
+ 	$(TESTS) \
+-- 
+2.25.1
+
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-gnu-lightdm-gtk-greeter-Update-to-2.0.7.patch --]
[-- Type: text/x-patch, Size: 1308 bytes --]

From 0f3bc9f7b17b4a099a9622c92b7b2fdb4076ba24 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:40:38 +0200
Subject: [PATCH 04/10] gnu: lightdm-gtk-greeter: Update to 2.0.7.

* gnu/packages/display-manager.scm (lightdm-gtk-greeter): Update to 2.0.7.
---
 gnu/packages/display-managers.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index eee7c6d841..49739a0064 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -187,7 +187,7 @@ display manager which supports different greeters.")
 (define-public lightdm-gtk-greeter
   (package
     (name "lightdm-gtk-greeter")
-    (version "2.0.2")
+    (version "2.0.7")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -196,7 +196,7 @@ display manager which supports different greeters.")
                     "/+download/lightdm-gtk-greeter-" version ".tar.gz"))
               (sha256
                (base32
-                "1436sdm83xqhxyr1rzqxhsl8if2xmidlvb341xcv6dv83lyxkrlf"))))
+                "1g7wc3d3vqfa7mrdhx1w9ywydgjbffla6rbrxq9k3sc62br97qms"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("exo" ,exo)
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-gnu-lightdm-gtk-greeter-Fix-at-spi-runtime-dependenc.patch --]
[-- Type: text/x-patch, Size: 1315 bytes --]

From b394a0e2019c9780b669a3258fe8e9afb5dfb76d Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:50:58 +0200
Subject: [PATCH 05/10] gnu: lightdm-gtk-greeter: Fix at-spi runtime
 dependency.

* gnu/packages/display-manager.scm (lightdm): Fix at-spi runtime dependency.
[inputs]: Add at-spi2-core.
[arguments]: Add '--enable-at-spi-command' configure flag.
---
 gnu/packages/display-managers.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 49739a0064..7b280fee6b 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -204,7 +204,13 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
+    (arguments
+     `(#:configure-flags
+       (list (string-append "--enable-at-spi-command="
+                            (assoc-ref %build-inputs "at-spi2-core")
+                            "/libexec/at-spi-bus-launcher"))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-gnu-lightdm-gtk-greeter-Fix-.desktop-file.patch --]
[-- Type: text/x-patch, Size: 1682 bytes --]

From f695692a52e5768e9d40a485140c148e88c51593 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 13:58:26 +0200
Subject: [PATCH 06/10] gnu: lightdm-gtk-greeter: Fix .desktop file.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix .desktop file
  path.
[arguments]: Add fix-.desktop-path phase.
---
 gnu/packages/display-managers.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 7b280fee6b..a97730ab1a 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,7 +210,17 @@ display manager which supports different greeters.")
      `(#:configure-flags
        (list (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
-                            "/libexec/at-spi-bus-launcher"))))
+                            "/libexec/at-spi-bus-launcher"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'fix-.desktop-path
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (substitute* (string-append
+                             out "/share/xgreeters/lightdm-gtk-greeter.desktop")
+                 (("Exec=lightdm-gtk-greeter")
+                  (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
+               #t))))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-gnu-lightdm-gtk-greeter-Wrap-binary.patch --]
[-- Type: text/x-patch, Size: 2275 bytes --]

From eaa49a238ab60f6a905506a750914ad3269c6e15 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 14:17:18 +0200
Subject: [PATCH 07/10] gnu: lightdm-gtk-greeter: Wrap binary.

* gnu/package/display-managers.scm (lightdm-gtk-greeter): Wrap binary.
[inputs]: Add shared-mime-info.
[arguments]: Add wrap-program phase.
---
 gnu/packages/display-managers.scm | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index a97730ab1a..8636d713b0 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -204,6 +204,7 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("shared-mime-info" ,shared-mime-info)
        ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
     (arguments
@@ -220,7 +221,21 @@ display manager which supports different greeters.")
                              out "/share/xgreeters/lightdm-gtk-greeter.desktop")
                  (("Exec=lightdm-gtk-greeter")
                   (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
-               #t))))))
+               #t)))
+         (add-after 'fix-.desktop-path 'wrap-program
+           ;; try to mimic glib-or-gtk build system
+           ;; which doesn't wrap files in /sbin
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (wrap-program (string-append (assoc-ref outputs "out")
+                                          "/sbin/lightdm-gtk-greeter")
+               `("XDG_DATA_DIRS" ":" prefix
+                 ,(cons "/run/current-system/profile/share"
+                   (map (lambda (pkg)
+                          (string-append (assoc-ref inputs pkg) "/share"))
+                        '("gtk+" "shared-mime-info" "glib"))))
+               `("GTK_PATH" ":" prefix (,(assoc-ref inputs "gtk+")))
+               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+"))))
+             #t)))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #9: 0008-gnu-lightdm-Build-accountsservice-files.patch --]
[-- Type: text/x-patch, Size: 997 bytes --]

From 967da134843193aaaded8a681d44734a9702e247 Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Tue, 16 Apr 2019 19:46:44 +0200
Subject: [PATCH 08/10] gnu: lightdm: Build accountsservice files.

* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Add accountsservice.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 8636d713b0..fe45165b90 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -166,7 +166,8 @@ create smooth, animated user interfaces.")
        ("libgcrypt" ,libgcrypt)
        ("libxcb" ,libxcb)))
     (native-inputs
-     `(("gobject-introspection" ,gobject-introspection)
+     `(("accountsservice" ,accountsservice)
+       ("gobject-introspection" ,gobject-introspection)
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
-- 
2.25.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #10: 0009-gnu-lightdm-gtk-greeter-Fix-some-warnings.patch --]
[-- Type: text/x-patch, Size: 1122 bytes --]

From f5f2da7c91530ca4ad7aae38aa083cff81c1e9bc Mon Sep 17 00:00:00 2001
From: Lprndn <lprndn@gmail.com>
Date: Wed, 17 Apr 2019 12:44:07 +0200
Subject: [PATCH 09/10] gnu: lightdm-gtk-greeter: Fix some warnings.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix some warnings.
[arguments]: Add '--disable-indicator-services-command' configure flags.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index fe45165b90..e13266ed03 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,7 +210,8 @@ display manager which supports different greeters.")
        ("gtk+" ,gtk+)))
     (arguments
      `(#:configure-flags
-       (list (string-append "--enable-at-spi-command="
+       (list "--disable-indicator-services-command"
+             (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
                             "/libexec/at-spi-bus-launcher"))
        #:phases
-- 
2.25.1


[-- Attachment #11: 0010-services-Add-lightdm-service-type.patch --]
[-- Type: text/x-patch, Size: 17924 bytes --]

From 5be647a2c7e1994f7cf970fa79fe693ffd4415b8 Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Thu, 18 Apr 2019 17:58:56 +0200
Subject: [PATCH 10/10] services: Add lightdm-service-type.

* gnu/services/lightdm.scm: Add file.
* doc/guix.texi (@deftp, @deffn): Add documentation.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 doc/guix.texi            |  88 +++++++++++
 gnu/local.mk             |   1 +
 gnu/services/lightdm.scm | 313 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 402 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index a0920adc1c..2d0230d5e6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14664,6 +14664,94 @@ auto-login session.
 @end table
 @end deftp
 
+@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 of both lightdm
+and lightdm-gtk-greeter or even using a different greeter.
+@end defvr
+
+@deftp {Data Type} lightdm-configuration
+Data type representing the lightDM service configuration.
+
+@table @asis
+@item @code{session-directory} (default:"/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{allow-empty-passwords?} (default: @code{#f})
+Whether to allow logins with empty passwords.
+
+@item @code{greeter-name} (default: "lightdm-gtk-greeter")
+The name of the default greeter to be used by LightDM.
+
+@item @code{greeter-package} (default: @code{lightdm-gtk-greeter})
+The package containing the greeter described by @code{greeter-name}
+and that will be included in the system's profile.
+
+@item @code{greeter-assets} (default: @code{(list adwaita-icon-theme gnome-themes-standard)})
+A list of packages needed by the greeter: icons, themes, fonts etc.
+
+@item @code{greeter-configuration-file} (default: (lightdm-gtk-greeter-configuration-file (lightdm-gtk-greeter-configuration)))
+This file will be placed in @code{/etc/xdg/lightdm/} directory.
+A @code{computed-file} is expected.
+
+@item @code{xorg-configuration} (default: @code{(xorg-configuration)})
+Configuration of the Xorg graphical server.
+
+@item @code{session-wrapper} (default: @code{(xinitrc)})
+Script to run before starting a X session.
+
+@item @code{default-session-name} (default: "")
+The name of the default @code{.desktop} file describing a session.
+If @code {autologin-user} and @code{autologin-timeout} are defined,
+LightDM logs in directly using the session described by @code{default-session-name}.
+
+@item @code{autologin-user} (default: "")
+If @code {default-session-name} and @code{autologin-timeout} are defined,
+LightDM logs in directly as @code{autologin-user}.
+
+@item @code{autologin-timeout} (default: @code{#f})
+If @code {default-session-name} and @code{autologin-user} are defined,
+LightDM logs in automatically after @code{autologin-timeout} seconds.
+Any user activity during that time will cancel autologin
+and allow usual login through authentification.
+
+@item @code{lightdm} (default: @code{lightdm})
+The LightDM package to use.
+
+@item @code{extra-config} (default: "")
+String to append to the LightDM configuration file.
+
+@end table
+@end deftp
+
+@deftp {Data Type} lightdm-gtk-greeter-configuration
+This data type represents the configuration for ligtdm-gtk-greeter.
+Use it as an argument of lightdm-gtk-greeter-configuration-file to
+get the corresponding file.
+
+@table @asis
+@item @code{theme-name} (default: "Adwaita")
+The name of the GTK+ theme to be used.
+
+@item @code{icon-theme-name} (default: "Adwaita")
+The name of the icon theme to be used for displaying icons.
+
+@item @code{cursor-theme-name} (default: "Adwaita")
+The name of the theme to be used for the cursor.
+
+@item @code{cursor-size} (default: @code{16})
+The size of the cursor.
+
+@item @code{background} (default: "")
+Path to the background image to be used.
+
+@item @code{extra-config} (default: "")
+String to append to the @code{lightdm-gtk-greeter.conf}.
+
+@end table
+@end deftp
+
 @cindex Xorg, configuration
 @deftp {Data Type} xorg-configuration
 This data type represents the configuration of the Xorg graphical display
diff --git a/gnu/local.mk b/gnu/local.mk
index fc9030b7f9..5ab96c121e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -561,6 +561,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/getmail.scm				\
   %D%/services/guix.scm			\
   %D%/services/kerberos.scm			\
+  %D%/services/lightdm.scm      		\
   %D%/services/lirc.scm				\
   %D%/services/virtualization.scm		\
   %D%/services/mail.scm				\
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..4d69daaa49
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,313 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019,2020 L  p R n  d n   <guix@lprndn.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gnu services lightdm)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type
+            lightdm-gtk-greeter-configuration
+            lightdm-gtk-greeter-configuration-file))
+
+;; GREETERS
+
+(define-record-type* <lightdm-gtk-greeter-configuration>
+  lightdm-gtk-greeter-configuration make-lightdm-gtk-greeter-configuration
+  lightdm-gtk-greeter-configuration?
+  (theme-name lightdm-gtk-greeter-configuration-theme-name
+              (default "Adwaita"))
+  (icon-theme-name
+   lightdm-gtk-greeter-configuration-icon-theme-name
+   (default "Adwaita"))
+  (cursor-theme-name
+   lightdm-gtk-greeter-configuration-cursor-theme-name
+   (default "Adwaita"))
+  (cursor-size lightdm-gtk-greeter-configuration-cursor-size
+               (default 16))
+  (background lightdm-gtk-greeter-configuration-background
+              (default ""))
+  (extra-config lightdm-gtk-greeter-configuration-extra-config
+                 (default "")))
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = " (lightdm-gtk-greeter-configuration-theme-name config) "
+icon-theme-name = "
+(lightdm-gtk-greeter-configuration-icon-theme-name config) "
+cursor-theme-name = "
+(lightdm-gtk-greeter-configuration-cursor-theme-name config) "
+cursor-theme-size = " (number->string
+                       (lightdm-gtk-greeter-configuration-cursor-size config))
+(if (string-null? (lightdm-gtk-greeter-configuration-background config)) ""
+    (string-append "
+background = " (lightdm-gtk-greeter-configuration-background config))) "
+" (lightdm-gtk-greeter-configuration-extra-config config)))
+
+;; LIGHTDM
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (sessions-directory
+   lightdm-configuration-sessions-directory
+   (default (string-append
+             "/run/current-system/profile/share/xsessions"
+             ":/run/current-system/profile/share/wayland-sessions")))
+  (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
+                          (default #f))
+  ;; [Seat]
+  (xorg-configuration lightdm-configuration-xorg
+                      (default (xorg-configuration)))
+  (session-wrapper lightdm-configuration-session-wrapper
+                   (default (xinitrc)))
+  (default-session-name lightdm-configuration-default-session
+    (default ""))
+
+  ;; [Autologin]
+  (autologin-user lightdm-configuration-autologin-user
+                  (default ""))
+  (autologin-timeout lightdm-configuration-autologin-timeout
+                     (default #f))
+  ;; [Greeter]
+  (greeter-name lightdm-configuration-greeter-name
+                (default "lightdm-gtk-greeter"))
+  (greeter-package lightdm-configuration-greeter-package
+                   (default lightdm-gtk-greeter))
+  (greeter-assets lightdm-configuration-greeter-assets
+                  (default (list adwaita-icon-theme
+                                 gnome-themes-standard)))
+  (greeter-configuration-file lightdm-configuration-greeter-configuration-file
+                              (default (lightdm-gtk-greeter-configuration-file
+                                        (lightdm-gtk-greeter-configuration))))
+  (extra-config lightdm-configuration-extra-config
+                 (default "")))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LightDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define %lightdm-activation
+  ;; Ensure /var/lib/lightdm is owned by the "lightdm" user.
+  ;; Mimics what is done for gdm
+  ;; see a43e9157ef479e94c19951cc9d228cf153bf78ee
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+
+        (define (ensure-ownership directory)
+          (let* ((lightdm (getpwnam "lightdm"))
+                 (uid (passwd:uid lightdm))
+                 (gid (passwd:gid lightdm))
+                 (st  (stat directory #f)))
+            ;; Recurse into directory only if it has wrong ownership.
+            (when (and st
+                       (or (not (= uid (stat:uid st)))
+                           (not (= gid (stat:gid st)))))
+              (for-each (lambda (file)
+                          (chown file uid gid))
+                        (find-files "directory"
+                                    #:directories? #t)))))
+
+        (when (not (stat "/var/lib/lightdm-data" #f))
+          (mkdir-p "/var/lib/lightdm-data"))
+        (for-each ensure-ownership
+                  '("/var/lib/lightdm"
+                    "/var/lib/lightdm-data")))))
+
+(define (lightdm-configuration-file config)
+  (mixed-text-file "lightdm.conf" "
+[LightDM]
+greeter-user = lightdm
+greeters-directory = /run/current-system/profile/share/xgreeters
+sessions-directory = "  (lightdm-configuration-sessions-directory config) "
+
+
+[Seat:*]
+xserver-command = "  (xorg-start-command (lightdm-configuration-xorg config)) "
+greeter-session = "       (lightdm-configuration-greeter-name config) "
+user-session = "          (lightdm-configuration-default-session config)
+(if (string-null? (lightdm-configuration-autologin-user config)) ""
+    (string-append "
+autologin-user = " (lightdm-configuration-autologin-user config)))
+(if (string-null? (lightdm-configuration-default-session config)) ""
+    (string-append "
+autologin-session = " (lightdm-configuration-default-session config)))
+(if (lightdm-configuration-autologin-timeout config)
+    (string-append "
+autologin-user-timeout = " (number->string
+                            (lightdm-configuration-autologin-timeout config)))
+    "") "
+session-wrapper = " (lightdm-configuration-session-wrapper config) "
+" (lightdm-configuration-extra-config config)))
+
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))
+     (pam-entry (control "required") (module "pam_env.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+     ;; Load environment from /etc/environment and ~/.pam_environment
+     (pam-entry (control "required") (module "pam_env.so"))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list #$(file-append (lightdm-configuration-lightdm config)
+                           "/sbin/lightdm")))
+ 
+  (list (shepherd-service
+         (documentation "LightDM display manager.")
+         (requirement '(dbus-system user-processes host-name))
+         (provision '(display-manager))
+         (respawn? #f)
+         (start #~(lambda ()
+                    (fork+exec-command
+                     #$lightdm-command
+                     #:environment-variables
+                     (list
+                      (string-append
+                       "PATH=/run/current-system/profile/sbin"
+                       ":/run/current-system/profile/bin")))))
+         (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  (let ((lightdm-conf-file
+         (lightdm-configuration-file config))
+        (greeter-conf-file
+         (lightdm-configuration-greeter-configuration-file config)))
+    (if greeter-conf-file
+        (list `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+                ,lightdm-conf-file)
+              `(,(string-append
+                  "xdg/lightdm/" (computed-file-name greeter-conf-file))
+                ,greeter-conf-file))
+        (list  `("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+                ,lightdm-conf-file)))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-profile-service config)
+  (append (list lightdm
+                (lightdm-configuration-greeter-package config))
+          (lightdm-configuration-greeter-assets config)))
+
+(define lightdm-service-type
+  (handle-xorg-configuration lightdm-configuration
+   (service-type (name 'lightdm)
+                 (extensions
+                  (list
+                   (service-extension shepherd-root-service-type
+                                      lightdm-shepherd-service)
+                   (service-extension activation-service-type
+                                      (const %lightdm-activation))
+                   (service-extension etc-service-type
+                                      lightdm-etc-service)
+                   (service-extension pam-root-service-type
+                                      lightdm-pam-services)
+                   (service-extension dbus-root-service-type
+                                      (compose list
+                                               lightdm-configuration-lightdm))
+                   (service-extension account-service-type
+                                      (const %lightdm-accounts))
+                   (service-extension profile-service-type
+                                      lightdm-profile-service)))
+                 (default-value (lightdm-configuration))
+                 (description "Return a service that spawns the
+ LightDM graphical login manager."))))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-04-09 16:02   ` L p R n d n
@ 2020-04-12  9:53     ` Brice Waegeneire
  2020-04-14  9:38       ` L p R n d n
  2020-04-22 15:26       ` L p R n d n
  0 siblings, 2 replies; 30+ messages in thread
From: Brice Waegeneire @ 2020-04-12  9:53 UTC (permalink / raw)
  To: L p R n d n; +Cc: 35305

Hello L p R n d n,

Using `set-xorg-configuration` with `lightdm-service-type` seems to be
working.

There is an error on vt1 at startup about some dbus stuff related to
“accountservice”. The cursor theme isn't set as well as the icon theme, 
it
seems; it may come from some missing environment variable as NixOS set a
few of them in their service[0].

After digging in the new service file I keep wondering if it's the right
way to go about implementing it. I tried to set a simple setting
for `lightdm-gtk-greeter` and I ended up with the following which 
doesn't
look intuitive:

--8<---------------cut here---------------start------------->8---
(service lightdm-service-type
          (lightdm-configuration
           (greeter-configuration-file
            (lightdm-gtk-greeter-configuration-file
             (lightdm-gtk-greeter-configuration
              (extra-config "hide-user-image=true"))))))
--8<---------------cut here---------------end--------------->8---

Furthermore `lightdm-service-type` only set a single seat while lightdm 
can
have many of them. So maybe there should be a lightdm-seat` record used 
as
a list of seats in `lightdm-service-type`. Each greater will be able to
expand `lightdm-service-type` by appending a seat to it. Then the
configuration could look like this:

--8<---------------cut here---------------start------------->8---
(service lightdm-service-type)
(service lightdm-gtk-greeter-service-type
          (lightdm-gtk-greeter-configuration
           (assets (list guix-artwork))
           (theme-name "Guix")
           (extra-config "hide-user-image=true")))
--8<---------------cut here---------------end--------------->8---

Using this approch would also avoid populating “/etc”, at least for
`lightdm-grk-greeter`, since each greeter would be defined as a service 
and
could expand “/etc” if it really needs it. For `lightdm-gtk-greeter`
specifically avoiding putting config in “/etc/” can be done by compiling 
it
with `-DCONFIG_FILE` pointing to `/run/current-system` And `lightdm` can 
be
started with `--config`.

Here is an example in how to make a conjuration file procedure more
readable while keeping under the line length limit by using 
`match-record`:

--8<---------------cut here---------------start------------->8---
(define (lightdm-gtk-greeter-configuration-file config)
   (match-record config <lightdm-gtk-greeter-configuration>
     (theme-name icon-theme-name cursor-theme-name cursor-size background
                 extra-config)
    (mixed-text-file "lightdm-gtk-greeter.conf" "
[greeter]
theme-name = "           theme-name                   "
icon-theme-name = "      icon-theme-name              "
cursor-theme-name = "    cursor-theme-name            "
cursor-theme-size = "    (number->string cursor-size) "
background = "           background                   "
" extra-config                                        "
")))
--8<---------------cut here---------------end--------------->8---

BTW the default background could use one from Guix artwork repo like
“(file-append %artwork-repository "/grub/GuixSD-fully-black-16-9.svg")”.

WDYT? I may be completely off on the `lightdm-seat` part.

[0]: 
https://github.com/NixOS/nixpkgs/blob/release-19.09/nixos/modules/services/x11/display-managers/lightdm-greeters/gtk.nix#L18

Cheers,
- Brice

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-04-12  9:53     ` Brice Waegeneire
@ 2020-04-14  9:38       ` L p R n d n
  2020-04-14 13:17         ` L p R n d n
  2020-04-22 15:26       ` L p R n d n
  1 sibling, 1 reply; 30+ messages in thread
From: L p R n d n @ 2020-04-14  9:38 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 35305

Hello,

Thanks again for the feedbacks.

Brice Waegeneire <brice@waegenei.re> writes:

[...]
> There is an error on vt1 at startup about some dbus stuff related to
> “accountservice”. The cursor theme isn't set as well as the icon theme, 
> it
> seems; it may come from some missing environment variable as NixOS set a
> few of them in their service[0].

For the cursor, setting "XCURSOR_PATH" seems to solve the problem.
Preparing a patch.

As for dbus, from what I found at NixOS[0][1], it's a accountsservice
bug. I'll send a bug report. In the meantime, it doesn't appear to
affect LightDM too much so it might be ok...?

> After digging in the new service file I keep wondering if it's the right
> way to go about implementing it. I tried to set a simple setting
> for `lightdm-gtk-greeter` and I ended up with the following which 
> doesn't
> look intuitive:
>
> (service lightdm-service-type
>           (lightdm-configuration
>            (greeter-configuration-file
>             (lightdm-gtk-greeter-configuration-file
>              (lightdm-gtk-greeter-configuration
>               (extra-config "hide-user-image=true"))))))

Yeah, far from elegant. Did it that way in case someone wanted to
provide its own file but dropping
lightdm-gtk-greeter-configuration-file gives one level less of nesting.

> Furthermore `lightdm-service-type` only set a single seat while lightdm 
> can
> have many of them. So maybe there should be a lightdm-seat` record used 
> as
> a list of seats in `lightdm-service-type`. Each greater will be able to
> expand `lightdm-service-type` by appending a seat to it. Then the
> configuration could look like this:
>
> (service lightdm-service-type)
> (service lightdm-gtk-greeter-service-type
>           (lightdm-gtk-greeter-configuration
>            (assets (list guix-artwork))
>            (theme-name "Guix")
>            (extra-config "hide-user-image=true")))

I didn't know one could use a different greeter for each seat. Indeed,
it would be nice to have that feature!
The only thing that bothers me is that you don't get a working
default LightDM service by default. I feel that just adding (service
lightdm-service-type) to your configuration should get you a fully
working LightDM, specially for newcomers. Here one would lack a greeter.
:/

I believe there is a solution that would give us the best of both
worlds. If someone has a clue, an idea or even a patch, please share it!
:)

Also, merging as is and improving the service later is possible too.

>
> Using this approch would also avoid populating “/etc”, at least for
> `lightdm-grk-greeter`, since each greeter would be defined as a service 
> and
> could expand “/etc” if it really needs it. For `lightdm-gtk-greeter`
> specifically avoiding putting config in “/etc/” can be done by compiling 
> it
> with `-DCONFIG_FILE` pointing to `/run/current-system` And `lightdm` can 
> be
> started with `--config`.

I will make a patch to use --config for lightdm.
For lightdm-gtk-greeter, how would one put the config file in
"/run/current-system"? Do we need to make a package out of it?

> Here is an example in how to make a conjuration file procedure more
> readable while keeping under the line length limit by using 
> `match-record`:
>
> (define (lightdm-gtk-greeter-configuration-file config)
>    (match-record config <lightdm-gtk-greeter-configuration>
>      (theme-name icon-theme-name cursor-theme-name cursor-size background
>                  extra-config)
>     (mixed-text-file "lightdm-gtk-greeter.conf" "
> [greeter]
> theme-name = "           theme-name                   "
> icon-theme-name = "      icon-theme-name              "
> cursor-theme-name = "    cursor-theme-name            "
> cursor-theme-size = "    (number->string cursor-size) "
> background = "           background                   "
> " extra-config                                        "
> ")))

Way better! Preparing a patch for that.

> BTW the default background could use one from Guix artwork repo like
> “(file-append %artwork-repository "/grub/GuixSD-fully-black-16-9.svg")”.

Yeap!

> WDYT? I may be completely off on the `lightdm-seat` part.
>
> [0]: 
> https://github.com/NixOS/nixpkgs/blob/release-19.09/nixos/modules/services/x11/display-managers/lightdm-greeters/gtk.nix#L18
>
> Cheers,
> - Brice

Have a nice day!

L  p R n  d n

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-04-14  9:38       ` L p R n d n
@ 2020-04-14 13:17         ` L p R n d n
  0 siblings, 0 replies; 30+ messages in thread
From: L p R n d n @ 2020-04-14 13:17 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 35305

Hey!

Le 14.04.2020 11:38, L  p R n  d n a écrit :
> Hello,
> 
> Thanks again for the feedbacks.
> 
> Brice Waegeneire <brice@waegenei.re> writes:
> 
> [...]
>> There is an error on vt1 at startup about some dbus stuff related to
>> “accountservice”. The cursor theme isn't set as well as the icon 
>> theme,
>> it
>> seems; it may come from some missing environment variable as NixOS set 
>> a
>> few of them in their service[0].
> 
> For the cursor, setting "XCURSOR_PATH" seems to solve the problem.
> Preparing a patch.
> 
> As for dbus, from what I found at NixOS[0][1], it's a accountsservice
> bug. I'll send a bug report. In the meantime, it doesn't appear to
> affect LightDM too much so it might be ok...?

Better with actual links:

[0]: https://github.com/NixOS/nixpkgs/pull/45107
[1]: https://github.com/NixOS/nixpkgs/issues/72396

Have a nice day,

L  p R n  d n

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-04-12  9:53     ` Brice Waegeneire
  2020-04-14  9:38       ` L p R n d n
@ 2020-04-22 15:26       ` L p R n d n
  1 sibling, 0 replies; 30+ messages in thread
From: L p R n d n @ 2020-04-22 15:26 UTC (permalink / raw)
  To: 35305

[-- Attachment #1: Type: text/plain, Size: 1837 bytes --]

Hello,

Here is the new set of patches with quite a few modifications for the
service, everything rebased on 1.1.0.
After a discussion with bricewge on irc, a new design has been adopted
allowing use of multiple seats.
To use the service, you can instantiate a lightdm-service-type, a
lightdm-gtk-greeter-service-type or both. The service should always find
a way to start a working instance of LightDM. :) 
A non exhaustive list of changes that might need further review:

* lightdm-gtk-greeter has its own service extending lightdm-service and
  others.
  
* Seats configuration use now the lightdm-seat-record-type and can be
  defined both in the lightdm-service and lightdm-gtk-greeter-service.
  The greeter now extends the LightDM's service by providing a list of
  seats.

* The `compose` and `extend` field of the lightdm-service-type have seen
  work for this purpose while keeping compatibility with
  `set-xorg-configuration`.

* extra-config fields are list of strings to avoid weird indentation in
  the user's config.

* Fixed customization of lightdm-gtk-greeter's cursor.

* Added some fields to deal with accessibility for
  lightdm-gtk-greeter-configuration.

* Takes default background from guix-artwork.

Also a review of PAM services might be nice as I'm not versed in security.

However, I didn't get rid of etc-service-type's extension as LightDM's
seems to ignore `sessions-directory` when configuration is passed
through `--config`. Patches to fix that are welcome but can wait a
future patch submission, I think.

Otherwise, tested in a WM: default configurations, autologin, sway,
changing greeter appearance and everything worked fine. For passwordless
login, had to actually delete user's password manually to make it work.
I don't know if it's expected.

Have a nice day and good review :)


L  p R n  d n

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-lightdm-Update-1.30.0.patch --]
[-- Type: text/x-patch, Size: 1552 bytes --]

From fc80fd5c5a4e3ffa1de0f96d2e157e230a6d7afd Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:16:39 +0200
Subject: [PATCH 01/10] gnu: lightdm: Update 1.30.0.

* gnu/packages/display-managers.scm (lightdm): Update to 1.30.0.
---
 gnu/packages/display-managers.scm | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 51605e09aa..f23dc7f573 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -125,16 +125,15 @@ create smooth, animated user interfaces.")
 (define-public lightdm
   (package
     (name "lightdm")
-    (version "1.24.0")
+    (version "1.30.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append "https://launchpad.net/lightdm/"
-                                  (version-major+minor version) "/"
-                                  version "/+download/lightdm-"
-                                  version ".tar.xz"))
+              (uri (string-append
+                    "https://github.com/CanonicalLtd/lightdm/releases/download/"
+                    version "/lightdm-" version ".tar.xz"))
               (sha256
                (base32
-                "18j33bm54i8k7ncxcs69zqi4105s62n58jrydqn3ikrb71s9nl6d"))))
+                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-lightdm-Add-vala-bindings.patch --]
[-- Type: text/x-patch, Size: 856 bytes --]

From 79e893dd86ff913bb840ba36fe2d9aa36a4e82f0 Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:21:55 +0200
Subject: [PATCH 02/10] gnu: lightdm: Add vala bindings.

* gnu/packages/display-managers.scm (lightdm) [native-inputs]: Add vala.
---
 gnu/packages/display-managers.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index f23dc7f573..065b1c0000 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -180,6 +180,7 @@ create smooth, animated user interfaces.")
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
+       ("vala" ,vala)                   ;For vala bindings
        ;; For tests
        ("dbus" ,dbus)
        ("python" ,python-2)
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-gnu-lightdm-Disable-python-tests-only.patch --]
[-- Type: text/x-patch, Size: 5426 bytes --]

From ac36258c83329462f7b7730ea9a753cd4fe61a66 Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:26:22 +0200
Subject: [PATCH 03/10] gnu: lightdm: Disable python tests only.

* gnu/packages/patches/lightdm-disable-python-tests.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/display-managers.scm (lightdm)[source]: Use patch.
* gnu/packages/display-managers.scm (lightdm)[arguments]: Remove
test-python-greeter wrapping.
* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Remove python
and python-gobject.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/display-managers.scm             | 18 ++-------
 .../lightdm-disable-python-tests.patch        | 40 +++++++++++++++++++
 3 files changed, 44 insertions(+), 15 deletions(-)
 create mode 100644 gnu/packages/patches/lightdm-disable-python-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 952fc55df4..880adcd457 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1169,6 +1169,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/lierolibre-newer-libconfig.patch		\
   %D%/packages/patches/lierolibre-remove-arch-warning.patch	\
   %D%/packages/patches/lierolibre-try-building-other-arch.patch	\
+  %D%/packages/patches/lightdm-disable-python-tests.patch	\
   %D%/packages/patches/linkchecker-tests-require-network.patch	\
   %D%/packages/patches/linux-libre-support-for-Pinebook-Pro.patch \
   %D%/packages/patches/linux-pam-no-setfsuid.patch		\
diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 065b1c0000..e8fae583f1 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -133,7 +133,8 @@ create smooth, animated user interfaces.")
                     version "/lightdm-" version ".tar.xz"))
               (sha256
                (base32
-                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))))
+                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))
+              (patches (search-patches "lightdm-disable-python-tests.patch"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
@@ -152,19 +153,8 @@ create smooth, animated user interfaces.")
              (substitute* "src/seat.c"
                (("/bin/sh") (which "sh")))
              #t))
-         (add-after 'unpack 'disable-broken-tests
-           (lambda _
-             (substitute* "tests/Makefile.in"
-               (("test-sessions-gobject ") "")
-               ((" test-sessions-python ") " "))
-             #t))
          (add-before 'check 'pre-check
-           ;; Run test-suite under a dbus session.
            (lambda* (#:key inputs #:allow-other-keys)
-             (wrap-program "tests/src/test-python-greeter"
-               `("PYTHONPATH"      ":" prefix (,(getenv "PYTHONPATH")))
-               `("GI_TYPELIB_PATH" ":" prefix (,(getenv "GI_TYPELIB_PATH"))))
-
              ;; Avoid printing locale warnings, which trip up the text
              ;; matching tests.
              (unsetenv "LC_ALL")
@@ -182,9 +172,7 @@ create smooth, animated user interfaces.")
        ("intltool" ,intltool)
        ("vala" ,vala)                   ;For vala bindings
        ;; For tests
-       ("dbus" ,dbus)
-       ("python" ,python-2)
-       ("python-pygobject" ,python2-pygobject)))
+       ("dbus" ,dbus)))
     ;; Required by liblightdm-gobject-1.pc.
     (propagated-inputs
      `(("glib" ,glib)
diff --git a/gnu/packages/patches/lightdm-disable-python-tests.patch b/gnu/packages/patches/lightdm-disable-python-tests.patch
new file mode 100644
index 0000000000..b1850f279c
--- /dev/null
+++ b/gnu/packages/patches/lightdm-disable-python-tests.patch
@@ -0,0 +1,40 @@
+ tests/Makefile.in | 23 -----------------------
+ 1 file changed, 23 deletions(-)
+
+diff --git a/tests/Makefile.in b/tests/Makefile.in
+index 9451a6f..46c027c 100644
+--- a/tests/Makefile.in
++++ b/tests/Makefile.in
+@@ -810,29 +810,6 @@ TESTS = test-xserver-fail-start test-greeter-fail-start \
+ 	test-wayland-autologin test-wayland-greeter \
+ 	test-wayland-session test-invalid-seat \
+ 	test-seatdefaults-still-supported \
+-	test-autologin-timeout-python \
+-	test-autologin-guest-timeout-python \
+-	test-autologin-session-timeout-python \
+-	test-cancel-authentication-python test-sessions-python \
+-	test-users-python test-login-python test-login-manual-python \
+-	test-login-manual-previous-session-python \
+-	test-login-no-password-python test-login-long-username-python \
+-	test-login-long-password-python test-login-two-factor-python \
+-	test-login-new-authtok-python test-login-info-prompt-python \
+-	test-login-multi-info-prompt-python \
+-	test-login-previous-session-python \
+-	test-login-wrong-password-python \
+-	test-login-invalid-user-python \
+-	test-login-invalid-session-python test-login-logout-python \
+-	test-login-pick-session-python \
+-	test-login-remember-session-python \
+-	test-login-manual-remember-session-python \
+-	test-login-guest-python test-login-guest-pick-session-python \
+-	test-login-guest-disabled-python \
+-	test-login-guest-no-setup-script-python \
+-	test-login-guest-fail-setup-script-python \
+-	test-login-guest-logout-python \
+-	test-login-remote-session-python test-power-python \
+ 	$(am__append_1) $(am__append_2)
+ EXTRA_DIST = \
+ 	$(TESTS) \
+-- 
+2.25.1
+
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-gnu-lightdm-gtk-greeter-Fix-at-spi-runtime-dependenc.patch --]
[-- Type: text/x-patch, Size: 1320 bytes --]

From 3474c4025451a3554ef33ab0712bb40f5626ef6e Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:50:58 +0200
Subject: [PATCH 04/10] gnu: lightdm-gtk-greeter: Fix at-spi runtime
 dependency.

* gnu/packages/display-manager.scm (lightdm): Fix at-spi runtime dependency.
[inputs]: Add at-spi2-core.
[arguments]: Add '--enable-at-spi-command' configure flag.
---
 gnu/packages/display-managers.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index e8fae583f1..65f7d6ed79 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -204,7 +204,13 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
+    (arguments
+     `(#:configure-flags
+       (list (string-append "--enable-at-spi-command="
+                            (assoc-ref %build-inputs "at-spi2-core")
+                            "/libexec/at-spi-bus-launcher"))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-gnu-lightdm-gtk-greeter-Fix-.desktop-file.patch --]
[-- Type: text/x-patch, Size: 1687 bytes --]

From 86af8348bd21d24856ba48aa067322e08f791551 Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:58:26 +0200
Subject: [PATCH 05/10] gnu: lightdm-gtk-greeter: Fix .desktop file.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix .desktop file
  path.
[arguments]: Add fix-.desktop-path phase.
---
 gnu/packages/display-managers.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 65f7d6ed79..fa9b47e2f2 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,7 +210,17 @@ display manager which supports different greeters.")
      `(#:configure-flags
        (list (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
-                            "/libexec/at-spi-bus-launcher"))))
+                            "/libexec/at-spi-bus-launcher"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'fix-.desktop-path
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (substitute* (string-append
+                             out "/share/xgreeters/lightdm-gtk-greeter.desktop")
+                 (("Exec=lightdm-gtk-greeter")
+                  (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
+               #t))))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-gnu-lightdm-gtk-greeter-Wrap-binary.patch --]
[-- Type: text/x-patch, Size: 2280 bytes --]

From d007dad08e28a613ff787a8cd2f2461d965605ba Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 14:17:18 +0200
Subject: [PATCH 06/10] gnu: lightdm-gtk-greeter: Wrap binary.

* gnu/package/display-managers.scm (lightdm-gtk-greeter): Wrap binary.
[inputs]: Add shared-mime-info.
[arguments]: Add wrap-program phase.
---
 gnu/packages/display-managers.scm | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index fa9b47e2f2..ecc006ae3c 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -204,6 +204,7 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("shared-mime-info" ,shared-mime-info)
        ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
     (arguments
@@ -220,7 +221,21 @@ display manager which supports different greeters.")
                              out "/share/xgreeters/lightdm-gtk-greeter.desktop")
                  (("Exec=lightdm-gtk-greeter")
                   (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
-               #t))))))
+               #t)))
+         (add-after 'fix-.desktop-path 'wrap-program
+           ;; try to mimic glib-or-gtk build system
+           ;; which doesn't wrap files in /sbin
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (wrap-program (string-append (assoc-ref outputs "out")
+                                          "/sbin/lightdm-gtk-greeter")
+               `("XDG_DATA_DIRS" ":" prefix
+                 ,(cons "/run/current-system/profile/share"
+                   (map (lambda (pkg)
+                          (string-append (assoc-ref inputs pkg) "/share"))
+                        '("gtk+" "shared-mime-info" "glib"))))
+               `("GTK_PATH" ":" prefix (,(assoc-ref inputs "gtk+")))
+               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+"))))
+             #t)))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-gnu-lightdm-Build-accountsservice-files.patch --]
[-- Type: text/x-patch, Size: 1002 bytes --]

From c2ed7ecd53808284386bbaea8dff9f4450653612 Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 19:46:44 +0200
Subject: [PATCH 07/10] gnu: lightdm: Build accountsservice files.

* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Add accountsservice.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index ecc006ae3c..f855b17e3f 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -166,7 +166,8 @@ create smooth, animated user interfaces.")
        ("libgcrypt" ,libgcrypt)
        ("libxcb" ,libxcb)))
     (native-inputs
-     `(("gobject-introspection" ,gobject-introspection)
+     `(("accountsservice" ,accountsservice)
+       ("gobject-introspection" ,gobject-introspection)
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #9: 0008-gnu-lightdm-gtk-greeter-Fix-some-warnings.patch --]
[-- Type: text/x-patch, Size: 1127 bytes --]

From 396efb44d1976fd9d5b398782f999e4da8f58ecb Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Wed, 17 Apr 2019 12:44:07 +0200
Subject: [PATCH 08/10] gnu: lightdm-gtk-greeter: Fix some warnings.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix some warnings.
[arguments]: Add '--disable-indicator-services-command' configure flags.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index f855b17e3f..0a9ae8ee61 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,7 +210,8 @@ display manager which supports different greeters.")
        ("gtk+" ,gtk+)))
     (arguments
      `(#:configure-flags
-       (list (string-append "--enable-at-spi-command="
+       (list "--disable-indicator-services-command"
+             (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
                             "/libexec/at-spi-bus-launcher"))
        #:phases
-- 
2.26.1


[-- Attachment #10: 0009-services-Add-lightdm-service-type.patch --]
[-- Type: text/x-patch, Size: 25356 bytes --]

From 0ec82b2ec999d0e28d16912eae1e2848bb0b3cfe Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Thu, 18 Apr 2019 17:58:56 +0200
Subject: [PATCH 09/10] services: Add lightdm-service-type.

* gnu/services/lightdm.scm: Add file
(<lightdm-configuration>, <lightdm-seat-configuration>,
<lightdm-gtk-greeter-configuration>): New record types.
(lightdm-seat-configuration->list, lightdm-configuration-file,
lightdm-pam-services, lightdm-pam-service, lightdm-etc-service,
lightdm-shepherd-service, lightdm-profile-service,
lightdm-gtk-greeter-configuration-file, lightdm-gtk-greeter-profile-service,
lightdm-gtk-greeter-lightdm-service, lightdm-gtk-greeter-etc-service): New
procedures.
(%lightdm-accounts, %lightdm-activation, lightdm-greeter-pam-service,
lightdm-autologin-pam-service, lightdm-service-type,
lightdm-gtk-greeter-service-type): New variables.
* doc/guix.texi (X Window): Add documentation.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 doc/guix.texi            | 129 ++++++++++++
 gnu/local.mk             |   1 +
 gnu/services/lightdm.scm | 430 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 560 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index ef5f68db24..c244203dd9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14726,6 +14726,135 @@ auto-login session.
 @end table
 @end deftp
 
+@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'
+services for their specific configuration.
+@end defvr
+
+@deftp {Data Type} lightdm-configuration
+Data type representing the lightDM service configuration.
+
+@table @asis
+@item @code{lightdm} (default: @code{lightdm})
+The LightDM package to use.
+
+@item @code{allow-empty-passwords?} (default: @code{#f})
+Whether to allow logins with empty passwords.
+
+@item @code{xorg-configuration} (default: @code{(xorg-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")
+Directories where LightDM will search for sessions' @code{.desktop} files.
+
+@item @code{remote-sessions-directory} (default:"/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.
+
+@item @code{extra-config} (default: @code{'()})
+A list of strings each describing a custom setting to append to the LightDM
+configuration.
+
+@end table
+@end deftp
+
+@deftp {Data Type} lightdm-seat-configuration
+Record representing a seat configuration for LightDM.
+
+@table @asis
+@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{xorg-configuration} (default: @code{#f})
+Configuration of the Xorg graphical server.
+
+@item @code{session-wrapper} (default: @code{(xinitrc)})
+Script to run before starting a X session.
+
+@item @code{greeter-session} (default: "lightdm-gtk-greeter")
+The name of the greeter to be used for this seat.
+
+@item @code{default-user-session} (default: "")
+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
+@code{autologin} group.
+
+@item @code{extra-config} (default: @code{'()})
+A list of strings each describing a custom setting to append to the seat
+configuration.
+
+@end table
+@end deftp
+
+@defvr {Scheme Variable} lightdm-gtk-greeter-service-type
+Service type for the lightdm-gtk-greeter for LightDM.
+See @code{lightdm-gtk-greeter-configuration} below for configuration.
+@end defvr
+
+@deftp {Data Type} lightdm-gtk-greeter-configuration
+This data type represents the configuration for ligtdm-gtk-greeter.
+Use it as an argument of lightdm-gtk-greeter-configuration-file to
+get the corresponding file.
+
+@table @asis
+@item @code{lightdm-gtk-greeter} (default: @code{lightdm-gtk-greeter})
+lightdm-gtk-greeter package to use.
+
+@item @code{assets} (default: @code{(list adwaita-icon-theme gnome-themes-standard)})
+A list of packages needed by the greeter: icons, themes, fonts etc.
+
+@item @code{theme-name} (default: "Adwaita")
+The name of the GTK+ theme to be used.
+
+@item @code{icon-theme-name} (default: "Adwaita")
+The name of the icon theme to be used for displaying icons.
+
+@item @code{cursor-theme-name} (default: "Adwaita")
+The name of the theme to be used for the cursor.
+
+@item @code{cursor-size} (default: @code{16})
+The size of the cursor.
+
+@item @code{background} (default: @code{(file-append %artwork-repository "/grub/GuixSD-fully-black-16-9.svg")})
+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
+on exit, @code{"-name"} disables at start and @code{"+name"} enables it.
+
+@item @code{reader} (default: "")
+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"}
+
+@item @code{extra-config} (default: @code{'()})
+A list of string each describing a custom setting to append to the greeter
+configuration.
+
+@end table
+@end deftp
+
 @cindex Xorg, configuration
 @deftp {Data Type} xorg-configuration
 This data type represents the configuration of the Xorg graphical display
diff --git a/gnu/local.mk b/gnu/local.mk
index 880adcd457..8ade7e4b01 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -568,6 +568,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/getmail.scm				\
   %D%/services/guix.scm			\
   %D%/services/kerberos.scm			\
+  %D%/services/lightdm.scm      		\
   %D%/services/linux.scm			\
   %D%/services/lirc.scm				\
   %D%/services/virtualization.scm		\
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..52f71f5437
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,430 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019,2020 L  p R n  d n   <guix@lprndn.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gnu services lightdm)
+  #:use-module (srfi srfi-1)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 receive)
+
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu artwork)
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-seat-configuration
+
+            lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type
+
+            lightdm-gtk-greeter-configuration
+            lightdm-gtk-greeter-configuration?
+            lightdm-gtk-greeter-service-type))
+
+
+;; LIGHTDM
+
+(define-record-type* <lightdm-seat-configuration>
+  lightdm-seat-configuration make-lightdm-seat-configuration
+  lightdm-seat-configuration?
+  (name-glob lightdm-seat-configuration-name-glob
+             (default "*"))
+  (type lightdm-seat-configuration-type
+        (default "local"))
+  (xorg-configuration lightdm-seat-configuration-xorg-configuration
+                      (default #f))
+  (session-wrapper lightdm-seat-configuration-session-wrapper
+                   (default (xinitrc)))
+  (greeter-session lightdm-seat-configuration-greeter-session
+                   (default "lightdm-gtk-greeter"))
+  (default-user-session lightdm-seat-configuration-default-user-session
+    (default ""))
+  (autologin-user lightdm-seat-configuration-autologin-user
+                  (default ""))
+  (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."
+  (match-record seat <lightdm-seat-configuration>
+                (name-glob
+                 type xorg-configuration session-wrapper
+                 greeter-session default-user-session
+                 autologin-user extra-config)
+                (list "
+   [Seat:"              name-glob                              "]
+  type = "              type
+  ;; If no xorg-configuration is set by the seat use the one provided
+  ;; by the lightdm service
+  "
+  xserver-command = "    (xorg-start-command
+                          (or xorg-configuration
+                              default-xorg-configuration))
+  "
+  session-wrapper = "   session-wrapper                         "
+  greeter-session = "   greeter-session
+  (if (string-null? default-user-session) ""
+      (string-append "
+  user-session = "      default-user-session))                  "
+  "
+  ;; Turn autologin ON if autologin-user is set
+  (if (string-null? autologin-user) ""
+      (string-append "
+  autologin-user = "    autologin-user                          "
+  autologin-session = " default-user-session))                  "
+  " (if (null? extra-config) ""
+        (string-join extra-config "\n")) "
+  ")))
+
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+  ;; General configuration
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
+                          (default #f))
+  (sessions-directory
+   lightdm-configuration-sessions-directory
+   (default (string-append
+             "/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 (string-append
+                                       "/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
+                      (default (xorg-configuration)))
+  (seats lightdm-configuration-seats
+         (default '()))
+  (extra-config lightdm-configuration-extra-config
+                (default '())))
+
+(define (lightdm-configuration-file config)
+  (match-record config <lightdm-configuration>
+                (allow-empty-passwords?
+                 sessions-directory greeters-directory
+                 remote-sessions-directory xorg-configuration
+                 seats extra-config)
+                ;; Little trick to allow unquote-splicing of seats
+                (apply mixed-text-file `("lightdm.conf" "
+[LightDM]
+greeter-user = lightdm
+greeters-directory = " ,greeters-directory "
+sessions-directory = " ,sessions-directory "
+remote-sessions-directory = " ,remote-sessions-directory "
+
+#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
+" ,(if (null? extra-config) ""
+       (string-join extra-config "\n"))
+"
+"))))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LightDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define %lightdm-activation
+  ;; Ensure /var/lib/lightdm is owned by the "lightdm" user.
+  ;; Mimics what is done for gdm
+  ;; see a43e9157ef479e94c19951cc9d228cf153bf78ee
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+
+        (define (ensure-ownership directory)
+          (let* ((lightdm (getpwnam "lightdm"))
+                 (uid (passwd:uid lightdm))
+                 (gid (passwd:gid lightdm))
+                 (st  (stat directory #f)))
+            ;; Recurse into directory only if it has wrong ownership.
+            (when (and st
+                       (or (not (= uid (stat:uid st)))
+                           (not (= gid (stat:gid st)))))
+              (for-each (lambda (file)
+                          (chown file uid gid))
+                        (find-files "directory"
+                                    #:directories? #t)))))
+
+        (when (not (stat "/var/lib/lightdm-data" #f))
+          (mkdir-p "/var/lib/lightdm-data"))
+        (for-each ensure-ownership
+                  '("/var/lib/lightdm"
+                    "/var/lib/lightdm-data")))))
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:login-uid? #t
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+
+     (pam-entry (control "required") (module "pam_succeed_if.so")
+                (arguments (list "uid >= 1000")))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list #$(file-append (lightdm-configuration-lightdm config)
+                           "/sbin/lightdm")))
+
+  (list (shepherd-service
+         (documentation "LightDM display manager.")
+         (requirement '(dbus-system user-processes host-name))
+         (provision '(display-manager xorg-server))
+         (respawn? #f)
+         (start #~(lambda ()
+                    (fork+exec-command
+                     #$lightdm-command
+                     #:environment-variables
+                     (list
+                      (string-append
+                       "PATH=/run/current-system/profile/sbin"
+                       ":/run/current-system/profile/bin")))))
+         (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  `(("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+     ,(lightdm-configuration-file config))))
+
+(define (lightdm-profile-service config)
+  ;; In case no seats are provided, we fall back on a default one
+  ;; with lightdm-gtk-greeter. Add necessary packages.
+  (let ((seats (lightdm-configuration-seats config))
+        (lightdm (lightdm-configuration-lightdm config)))
+    (if (null? seats)
+        (list lightdm lightdm-gtk-greeter)
+        (list lightdm))))
+
+(define lightdm-service-type
+  ;; (handle-xorg-configuration lightdm-configuration)
+  (service-type (name 'lightdm)
+                (extensions
+                 (list
+                  (service-extension shepherd-root-service-type
+                                     lightdm-shepherd-service)
+                  (service-extension activation-service-type
+                                     (const %lightdm-activation))
+                  (service-extension pam-root-service-type
+                                     lightdm-pam-services)
+                  (service-extension dbus-root-service-type
+                                     (compose list
+                                              lightdm-configuration-lightdm))
+                  (service-extension account-service-type
+                                     (const %lightdm-accounts))
+                  (service-extension etc-service-type
+                                     lightdm-etc-service)
+                  (service-extension profile-service-type
+                                     lightdm-profile-service)))
+                ;; LightDM is extended with lists of seats
+                ;; or with a xorg-configuration by set-xorg-configuration
+                ;; Deal with both cases.
+                (compose
+                 (lambda (extensions)
+                   (receive (xorg-configuration-extensions
+                             seats-extensions)
+                       (partition xorg-configuration? extensions)
+                     (list `("xorg-configuration" .
+                             ;; Mimic handle-xorg-configuration
+                             ,(match xorg-configuration-extensions
+                                (() #f)
+                                ((config . _) config)))
+                           `("seats" . ,(concatenate seats-extensions))))))
+                (extend (lambda (config extensions)
+                          (lightdm-configuration
+                           (inherit config)
+                           (xorg-configuration
+                            (or (assoc-ref extensions "xorg-configuration")
+                                (lightdm-configuration-xorg-configuration config)))
+                           (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.")))
+
+;; GREETERS
+
+(define-record-type* <lightdm-gtk-greeter-configuration>
+  lightdm-gtk-greeter-configuration make-lightdm-gtk-greeter-configuration
+  lightdm-gtk-greeter-configuration?
+
+  (lightdm-gtk-greeter lightdm-gtk-greeter-configuration-lightdm-gtk-greeter
+                       (default lightdm-gtk-greeter))
+  (assets lightdm-gtk-greeter-configuration-assets
+          (default (list adwaita-icon-theme
+                         gnome-themes-standard)))
+  (theme-name lightdm-gtk-greeter-configuration-theme-name
+              (default "Adwaita"))
+  (icon-theme-name
+   lightdm-gtk-greeter-configuration-icon-theme-name
+   (default "Adwaita"))
+  (cursor-theme-name
+   lightdm-gtk-greeter-configuration-cursor-theme-name
+   (default "Adwaita"))
+  (cursor-theme-size lightdm-gtk-greeter-configuration-cursor-theme-size
+                     (default 16))
+  (background lightdm-gtk-greeter-configuration-background
+              (default (file-append %artwork-repository
+                                    "/grub/GuixSD-fully-black-16-9.svg")))
+  (a11y-states lightdm-gtk-greeter-a11y-states
+              (default "contrast; font; keyboard; reader"))
+  (reader lightdm-gtk-greeter-reader
+          (default #f))
+  (seats lightdm-gtk-greeter-configuration-seats
+         (default (list (lightdm-seat-configuration))))
+  (extra-config lightdm-gtk-greeter-configuration-extra-config
+                (default '())))
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (match-record config <lightdm-gtk-greeter-configuration>
+                (theme-name icon-theme-name cursor-theme-name
+                            cursor-theme-size background a11y-states
+                            reader extra-config)
+                (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "          theme-name                         "
+icon-theme-name = "     icon-theme-name                    "
+cursor-theme-name = "   cursor-theme-name                  "
+cursor-theme-size = "   (number->string cursor-theme-size) "
+background = "          background                         "
+a11y-states = "         a11y-states                        "
+" (if reader (string-append "reader = " reader)
+      "") "
+"  (if (null? extra-config) ""
+       (string-join extra-config "\n")))))
+
+(define (lightdm-gtk-greeter-lightdm-service config)
+  ;; Enforce greeter-session field to lightdm-gtk-greeter
+  (map
+   (lambda (seat)
+     (lightdm-seat-configuration
+      (inherit seat)
+      (greeter-session "lightdm-gtk-greeter")))
+   (lightdm-gtk-greeter-configuration-seats config)))
+
+(define (lightdm-gtk-greeter-etc-service config)
+  `(("xdg/lightdm/lightdm-gtk-greeter.conf"
+     ,(lightdm-gtk-greeter-configuration-file config))))
+
+(define (lightdm-gtk-greeter-profile-service config)
+  (cons (lightdm-gtk-greeter-configuration-lightdm-gtk-greeter config)
+        (lightdm-gtk-greeter-configuration-assets config)))
+
+(define lightdm-gtk-greeter-service-type
+  (service-type (name 'lightdm-gtk-greeter)
+                (extensions
+                 (list
+                  (service-extension lightdm-service-type
+                                     lightdm-gtk-greeter-lightdm-service)
+                  (service-extension etc-service-type
+                                     lightdm-gtk-greeter-etc-service)
+                  (service-extension profile-service-type
+                                     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.")))
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #11: 0010-gnu-lightdm-gtk-greeter-Set-XCURSOR_PATH-in-wrapper.patch --]
[-- Type: text/x-patch, Size: 1727 bytes --]

From bbdb165bd0a0d91b0ef961fec81060a0f376c25f Mon Sep 17 00:00:00 2001
From: L p R n d n <guix@lprndn.info>
Date: Fri, 17 Apr 2020 11:53:51 +0200
Subject: [PATCH 10/10] gnu: lightdm-gtk-greeter: Set XCURSOR_PATH in wrapper.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter)[arguments]:
Modify wrap-program phase to add XCURSOR_PATH.
---
 gnu/packages/display-managers.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 0a9ae8ee61..43ca05bee4 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -232,11 +232,12 @@ display manager which supports different greeters.")
                                           "/sbin/lightdm-gtk-greeter")
                `("XDG_DATA_DIRS" ":" prefix
                  ,(cons "/run/current-system/profile/share"
-                   (map (lambda (pkg)
-                          (string-append (assoc-ref inputs pkg) "/share"))
-                        '("gtk+" "shared-mime-info" "glib"))))
+                        (map (lambda (pkg)
+                               (string-append (assoc-ref inputs pkg) "/share"))
+                             '("gtk+" "shared-mime-info" "glib"))))
                `("GTK_PATH" ":" prefix (,(assoc-ref inputs "gtk+")))
-               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+"))))
+               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+")))
+               `("XCURSOR_PATH" ":" prefix ("/run/current-system/profile/share/icons")))
              #t)))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
-- 
2.26.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2019-04-17 14:24 [bug#35305] [WIP] LightDM service L p R n d n
                   ` (3 preceding siblings ...)
  2020-04-07 17:06 ` [bug#35305] " Brice Waegeneire
@ 2020-05-06 14:05 ` L p R n d n
  2020-05-08 22:18   ` Ricardo Wurmus
  2022-08-04  2:19   ` [bug#35305] [WIP] " Maxim Cournoyer
  2022-08-31  7:13 ` bug#35305: " Ricardo Wurmus
  5 siblings, 2 replies; 30+ messages in thread
From: L p R n d n @ 2020-05-06 14:05 UTC (permalink / raw)
  To: 35305

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

Hello,

New set of patches with some modifications according to the feedbacks
from rekado.

One notable change is that all tests are now enabled for LightDM's
package. The package builds but there might be some non deterministic
tests failures sometimes (not necessarily those that have been re-enabled). 

Have a nice day,

L  p R n  d n

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-lightdm-Update-1.30.0.patch --]
[-- Type: text/x-patch, Size: 2183 bytes --]

From d55481e2cfbe83567c1950531cd4780b46371255 Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:16:39 +0200
Subject: [PATCH 1/9] gnu: lightdm: Update 1.30.0.

* gnu/packages/display-managers.scm (lightdm): Update to 1.30.0.
[arguments]: Re-enable all tests by removing 'disable-broken-tests phase.
---
 gnu/packages/display-managers.scm | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 51605e09aa..49e9264f8f 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -125,16 +125,15 @@ create smooth, animated user interfaces.")
 (define-public lightdm
   (package
     (name "lightdm")
-    (version "1.24.0")
+    (version "1.30.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append "https://launchpad.net/lightdm/"
-                                  (version-major+minor version) "/"
-                                  version "/+download/lightdm-"
-                                  version ".tar.xz"))
+              (uri (string-append
+                    "https://github.com/CanonicalLtd/lightdm/releases/download/"
+                    version "/lightdm-" version ".tar.xz"))
               (sha256
                (base32
-                "18j33bm54i8k7ncxcs69zqi4105s62n58jrydqn3ikrb71s9nl6d"))))
+                "158zb2d0v1309a8v19hh32y4yj3v6yg4yg6m0l7v59d3a2b7f651"))))
     (build-system gnu-build-system)
     (arguments
      '(#:parallel-tests? #f ; fails when run in parallel
@@ -153,13 +152,6 @@ create smooth, animated user interfaces.")
              (substitute* "src/seat.c"
                (("/bin/sh") (which "sh")))
              #t))
-         (add-after 'unpack 'disable-broken-tests
-           (lambda _
-             (substitute* "tests/Makefile.in"
-               (("test-sessions-gobject ") "")
-               ((" test-sessions-python ") " "))
-             #t))
          (add-before 'check 'pre-check
            ;; Run test-suite under a dbus session.
            (lambda* (#:key inputs #:allow-other-keys)
--
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gnu-lightdm-Add-vala-bindings.patch --]
[-- Type: text/x-patch, Size: 855 bytes --]

From fd891d52cd184e197dcb07fb3855492c28911815 Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:21:55 +0200
Subject: [PATCH 2/9] gnu: lightdm: Add vala bindings.

* gnu/packages/display-managers.scm (lightdm) [native-inputs]: Add vala.
---
 gnu/packages/display-managers.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 49e9264f8f..7f812d3b54 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -174,7 +174,7 @@ create smooth, animated user interfaces.")
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
+       ("vala" ,vala)                   ;For vala bindings
        ;; For tests
        ("dbus" ,dbus)
        ("python" ,python-2)
--
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-gnu-lightdm-gtk-greeter-Fix-at-spi-runtime-dependenc.patch --]
[-- Type: text/x-patch, Size: 1318 bytes --]

From ef53a04c308fc8b00b77a833b4018d11247924cb Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:50:58 +0200
Subject: [PATCH 3/9] gnu: lightdm-gtk-greeter: Fix at-spi runtime dependency.

* gnu/packages/display-manager.scm (lightdm): Fix at-spi runtime dependency.
[inputs]: Add at-spi2-core.
[arguments]: Add '--enable-at-spi-command' configure flag.
---
 gnu/packages/display-managers.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 7f812d3b54..ed12a4605b 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,8 +210,13 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
+    (arguments
+     `(#:configure-flags
+       (list (string-append "--enable-at-spi-command="
+                            (assoc-ref %build-inputs "at-spi2-core")
+                            "/libexec/at-spi-bus-launcher"))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
--
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-gnu-lightdm-gtk-greeter-Fix-.desktop-file.patch --]
[-- Type: text/x-patch, Size: 1686 bytes --]

From d73ff1af07bc2bd9ec7029577877cfbf87b98d60 Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 13:58:26 +0200
Subject: [PATCH 4/9] gnu: lightdm-gtk-greeter: Fix .desktop file.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix .desktop file
  path.
[arguments]: Add fix-.desktop-path phase.
---
 gnu/packages/display-managers.scm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index ed12a4605b..18ec0f10d6 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -216,8 +216,17 @@ display manager which supports different greeters.")
      `(#:configure-flags
        (list (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
-                            "/libexec/at-spi-bus-launcher"))))
+                            "/libexec/at-spi-bus-launcher"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'fix-.desktop-path
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (substitute* (string-append
+                             out "/share/xgreeters/lightdm-gtk-greeter.desktop")
+                 (("Exec=lightdm-gtk-greeter")
+                  (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
+               #t))))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
--
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-gnu-lightdm-gtk-greeter-Wrap-binary.patch --]
[-- Type: text/x-patch, Size: 2279 bytes --]

From 4a7ce94753e0d8180d5581387cc18a585a28eadc Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 14:17:18 +0200
Subject: [PATCH 5/9] gnu: lightdm-gtk-greeter: Wrap binary.

* gnu/package/display-managers.scm (lightdm-gtk-greeter): Wrap binary.
[inputs]: Add shared-mime-info.
[arguments]: Add wrap-program phase.
---
 gnu/packages/display-managers.scm | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 18ec0f10d6..be17f055d1 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -210,6 +210,7 @@ display manager which supports different greeters.")
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("lightdm" ,lightdm)
+       ("shared-mime-info" ,shared-mime-info)
        ("at-spi2-core" ,at-spi2-core)
        ("gtk+" ,gtk+)))
     (arguments
@@ -226,8 +227,21 @@ display manager which supports different greeters.")
                              out "/share/xgreeters/lightdm-gtk-greeter.desktop")
                  (("Exec=lightdm-gtk-greeter")
                   (string-append "Exec=" out "/sbin/lightdm-gtk-greeter")))
-               #t))))))
+               #t)))
+         (add-after 'fix-.desktop-path 'wrap-program
+           ;; try to mimic glib-or-gtk build system
+           ;; which doesn't wrap files in /sbin
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (wrap-program (string-append (assoc-ref outputs "out")
+                                          "/sbin/lightdm-gtk-greeter")
+               `("XDG_DATA_DIRS" ":" prefix
+                 ,(cons "/run/current-system/profile/share"
+                   (map (lambda (pkg)
+                          (string-append (assoc-ref inputs pkg) "/share"))
+                        '("gtk+" "shared-mime-info" "glib"))))
+               `("GTK_PATH" ":" prefix (,(assoc-ref inputs "gtk+")))
+               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+"))))
+             #t)))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
     (description "This package provides a LightDM greeter implementation using
--
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-gnu-lightdm-Build-accountsservice-files.patch --]
[-- Type: text/x-patch, Size: 1001 bytes --]

From 1250601cbad58a5d6cea588fdcc1258b2c8861db Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Tue, 16 Apr 2019 19:46:44 +0200
Subject: [PATCH 6/9] gnu: lightdm: Build accountsservice files.

* gnu/packages/display-managers.scm (lightdm)[native-inputs]: Add accountsservice.
---
 gnu/packages/display-managers.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index be17f055d1..42245f19e2 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -170,8 +170,8 @@ create smooth, animated user interfaces.")
        ("libgcrypt" ,libgcrypt)
        ("libxcb" ,libxcb)))
     (native-inputs
-     `(("gobject-introspection" ,gobject-introspection)
+     `(("accountsservice" ,accountsservice)
+       ("gobject-introspection" ,gobject-introspection)
        ("pkg-config" ,pkg-config)
        ("itstool" ,itstool)
        ("intltool" ,intltool)
--
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-gnu-lightdm-gtk-greeter-Disable-indicator-services.patch --]
[-- Type: text/x-patch, Size: 1178 bytes --]

From 18e22bf05def2c1102a66cce2b2bbb42d3faeded Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Wed, 17 Apr 2019 12:44:07 +0200
Subject: [PATCH 7/9] gnu: lightdm-gtk-greeter: Disable indicator services.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter): Fix some warnings.
[arguments]: Add '--disable-indicator-services-command' configure flags.
---
 gnu/packages/display-managers.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 42245f19e2..3d0a118e27 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -216,8 +216,9 @@ display manager which supports different greeters.")
        ("gtk+" ,gtk+)))
     (arguments
      `(#:configure-flags
-       (list (string-append "--enable-at-spi-command="
+       ;; indicator services use upstart
+       (list "--disable-indicator-services-command"
+             (string-append "--enable-at-spi-command="
                             (assoc-ref %build-inputs "at-spi2-core")
                             "/libexec/at-spi-bus-launcher"))
        #:phases
--
2.26.1


[-- Attachment #9: 0008-services-Add-lightdm-service-type.patch --]
[-- Type: text/x-patch, Size: 24975 bytes --]

From f300718619cd4279ff9504a333cf6e53cd29fc8b Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Thu, 18 Apr 2019 17:58:56 +0200
Subject: [PATCH 8/9] services: Add lightdm-service-type.

* gnu/services/lightdm.scm: Add file
(<lightdm-configuration>, <lightdm-seat-configuration>,
<lightdm-gtk-greeter-configuration>): New record types.
(lightdm-seat-configuration->list, lightdm-configuration-file,
lightdm-pam-services, lightdm-pam-service, lightdm-etc-service,
lightdm-shepherd-service, lightdm-profile-service,
lightdm-gtk-greeter-configuration-file, lightdm-gtk-greeter-profile-service,
lightdm-gtk-greeter-lightdm-service, lightdm-gtk-greeter-etc-service): New
procedures.
(%lightdm-accounts, %lightdm-activation, lightdm-greeter-pam-service,
lightdm-autologin-pam-service, lightdm-service-type,
lightdm-gtk-greeter-service-type): New variables.
* doc/guix.texi (X Window): Add documentation.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 doc/guix.texi            | 129 ++++++++++++
 gnu/local.mk             |   1 +
 gnu/services/lightdm.scm | 422 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 552 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index ef5f68db24..54eba225d3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14726,6 +14726,135 @@ auto-login session.
 @end table
 @end deftp
 
+@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'
+services for their specific configuration.
+@end defvr
+
+@deftp {Data Type} lightdm-configuration
+Data type representing the LightDM service configuration.
+
+@table @asis
+@item @code{lightdm} (default: @code{lightdm})
+The LightDM package to use.
+
+@item @code{allow-empty-passwords?} (default: @code{#f})
+Whether to allow logins with empty passwords.
+
+@item @code{xorg-configuration} (default: @code{(xorg-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")
+Directories where LightDM will search for sessions' @code{.desktop} files.
+
+@item @code{remote-sessions-directory} (default:"/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.
+
+@item @code{extra-config} (default: @code{'()})
+A list of strings each describing a custom setting to append to the LightDM
+configuration.
+
+@end table
+@end deftp
+
+@deftp {Data Type} lightdm-seat-configuration
+Record representing a seat configuration for LightDM.
+
+@table @asis
+@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{xorg-configuration} (default: @code{#f})
+Configuration of the Xorg graphical server.
+
+@item @code{session-wrapper} (default: @code{(xinitrc)})
+Script to run before starting a X session.
+
+@item @code{greeter-session} (default: "lightdm-gtk-greeter")
+The name of the greeter to be used for this seat.
+
+@item @code{default-user-session} (default: "")
+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
+@code{autologin} group.
+
+@item @code{extra-config} (default: @code{'()})
+A list of strings each describing a custom setting to append to the seat
+configuration.
+
+@end table
+@end deftp
+
+@defvr {Scheme Variable} lightdm-gtk-greeter-service-type
+Service type for the @code{lightdm-gtk-greeter} for LightDM.
+See @code{lightdm-gtk-greeter-configuration} below for configuration.
+@end defvr
+
+@deftp {Data Type} lightdm-gtk-greeter-configuration
+This data type represents the configuration for @code{lightdm-gtk-greeter}.
+Use it as an argument of @code{lightdm-gtk-greeter-configuration-file} to
+get the corresponding file.
+
+@table @asis
+@item @code{lightdm-gtk-greeter} (default: @code{lightdm-gtk-greeter})
+lightdm-gtk-greeter package to use.
+
+@item @code{assets} (default: @code{(list adwaita-icon-theme gnome-themes-standard)})
+A list of packages needed by the greeter: icons, themes, fonts etc.
+
+@item @code{theme-name} (default: "Adwaita")
+The name of the GTK+ theme to be used.
+
+@item @code{icon-theme-name} (default: "Adwaita")
+The name of the icon theme to be used for displaying icons.
+
+@item @code{cursor-theme-name} (default: "Adwaita")
+The name of the theme to be used for the cursor.
+
+@item @code{cursor-size} (default: @code{16})
+The size of the cursor.
+
+@item @code{background} (default: @code{(file-append %artwork-repository "/grub/GuixSD-fully-black-16-9.svg")})
+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
+on exit, @code{"-name"} disables at start and @code{"+name"} enables it.
+
+@item @code{reader} (default: "")
+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"}
+
+@item @code{extra-config} (default: @code{'()})
+A list of string each describing a custom setting to append to the greeter
+configuration.
+
+@end table
+@end deftp
+
 @cindex Xorg, configuration
 @deftp {Data Type} xorg-configuration
 This data type represents the configuration of the Xorg graphical display
diff --git a/gnu/local.mk b/gnu/local.mk
index 952fc55df4..66ceb59777 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -568,6 +568,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/getmail.scm				\
   %D%/services/guix.scm			\
   %D%/services/kerberos.scm			\
+  %D%/services/lightdm.scm      		\
   %D%/services/linux.scm			\
   %D%/services/lirc.scm				\
   %D%/services/virtualization.scm		\
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..fa5330aade
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,422 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019,2020 L  p R n  d n   <guix@lprndn.info>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gnu services lightdm)
+  #:use-module (srfi srfi-1)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 receive)
+
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu artwork)
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-seat-configuration
+
+            lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type
+
+            lightdm-gtk-greeter-configuration
+            lightdm-gtk-greeter-configuration?
+            lightdm-gtk-greeter-service-type))
+
+
+;; LIGHTDM
+
+(define-record-type* <lightdm-seat-configuration>
+  lightdm-seat-configuration make-lightdm-seat-configuration
+  lightdm-seat-configuration?
+  (name-glob lightdm-seat-configuration-name-glob
+             (default "*"))
+  (type lightdm-seat-configuration-type
+        (default "local"))
+  (xorg-configuration lightdm-seat-configuration-xorg-configuration
+                      (default #f))
+  (session-wrapper lightdm-seat-configuration-session-wrapper
+                   (default (xinitrc)))
+  (greeter-session lightdm-seat-configuration-greeter-session
+                   (default "lightdm-gtk-greeter"))
+  (default-user-session lightdm-seat-configuration-default-user-session
+    (default ""))
+  (autologin-user lightdm-seat-configuration-autologin-user
+                  (default ""))
+  (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."
+  (match-record seat <lightdm-seat-configuration>
+                (name-glob
+                 type xorg-configuration session-wrapper
+                 greeter-session default-user-session
+                 autologin-user extra-config)
+                (list "
+  [Seat:"               name-glob                              "]
+  type = "              type
+  ;; If no xorg-configuration is set by the seat use the one provided
+  ;; by the lightdm service
+  "
+  xserver-command = "   (xorg-start-command
+                         (or xorg-configuration
+                             default-xorg-configuration))
+  "
+  session-wrapper = "   session-wrapper                         "
+  greeter-session = "   greeter-session
+  (if (string-null? default-user-session) ""
+      (string-append "
+  user-session = "      default-user-session))                  "
+  "
+  ;; Turn autologin ON if autologin-user is set
+  (if (string-null? autologin-user) ""
+      (string-append "
+  autologin-user = "    autologin-user                          "
+  autologin-session = " default-user-session))                  "
+  " (string-join extra-config "\n"))))
+
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+  ;; General configuration
+  (lightdm lightdm-configuration-lightdm
+           (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"))
+  (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"))
+  ;; Having a xorg-configuration field here allows us
+  ;; to benefit from set-xorg-configuration.
+  (xorg-configuration lightdm-configuration-xorg-configuration
+                      (default (xorg-configuration)))
+  (seats lightdm-configuration-seats
+         (default '()))
+  (extra-config lightdm-configuration-extra-config
+                (default '())))
+
+(define (lightdm-configuration-file config)
+  (match-record config <lightdm-configuration>
+                (allow-empty-passwords?
+                 sessions-directory greeters-directory
+                 remote-sessions-directory xorg-configuration
+                 seats extra-config)
+                ;; Little trick to allow unquote-splicing of seats
+                (apply mixed-text-file `("lightdm.conf" "
+[LightDM]
+greeter-user = lightdm
+greeters-directory = " ,greeters-directory "
+sessions-directory = " ,sessions-directory "
+remote-sessions-directory = " ,remote-sessions-directory "
+
+#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")))))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LightDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define %lightdm-activation
+  ;; Ensure /var/lib/lightdm is owned by the "lightdm" user.
+  ;; Mimics what is done for gdm
+  ;; see a43e9157ef479e94c19951cc9d228cf153bf78ee
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+
+        (define (ensure-ownership directory)
+          (let* ((lightdm (getpwnam "lightdm"))
+                 (uid (passwd:uid lightdm))
+                 (gid (passwd:gid lightdm))
+                 (st  (stat directory #f)))
+            ;; Recurse into directory only if it has wrong ownership.
+            (when (and st
+                       (or (not (= uid (stat:uid st)))
+                           (not (= gid (stat:gid st)))))
+              (for-each (lambda (file)
+                          (chown file uid gid))
+                        (find-files "directory"
+                                    #:directories? #t)))))
+
+        (when (not (stat "/var/lib/lightdm-data" #f))
+          (mkdir-p "/var/lib/lightdm-data"))
+        (for-each ensure-ownership
+                  '("/var/lib/lightdm"
+                    "/var/lib/lightdm-data")))))
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:login-uid? #t
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+
+     (pam-entry (control "required") (module "pam_succeed_if.so")
+                (arguments (list "uid >= 1000")))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list #$(file-append (lightdm-configuration-lightdm config)
+                           "/sbin/lightdm")))
+
+  (list
+   (shepherd-service
+    (documentation "LightDM display manager.")
+    (requirement '(dbus-system user-processes host-name))
+    (provision '(display-manager xorg-server))
+    (respawn? #f)
+    (start
+     #~(lambda ()
+         (fork+exec-command
+          #$lightdm-command
+          #:environment-variables
+          (list
+           "PATH=/run/current-system/profile/sbin:/run/current-system/profile/bin"))))
+    (stop #~(make-kill-destructor)))))
+
+(define (lightdm-etc-service config)
+  `(("xdg/lightdm/lightdm.conf.d/lightdm.conf"
+     ,(lightdm-configuration-file config))))
+
+(define (lightdm-profile-service config)
+  ;; In case no seats are provided, we fall back on a default one
+  ;; with lightdm-gtk-greeter. Add necessary packages.
+  (let ((seats (lightdm-configuration-seats config))
+        (lightdm (lightdm-configuration-lightdm config)))
+    (if (null? seats)
+        (list lightdm lightdm-gtk-greeter)
+        (list lightdm))))
+
+(define lightdm-service-type
+  ;; (handle-xorg-configuration lightdm-configuration)
+  (service-type (name 'lightdm)
+                (extensions
+                 (list
+                  (service-extension shepherd-root-service-type
+                                     lightdm-shepherd-service)
+                  (service-extension activation-service-type
+                                     (const %lightdm-activation))
+                  (service-extension pam-root-service-type
+                                     lightdm-pam-services)
+                  (service-extension dbus-root-service-type
+                                     (compose list
+                                              lightdm-configuration-lightdm))
+                  (service-extension account-service-type
+                                     (const %lightdm-accounts))
+                  (service-extension etc-service-type
+                                     lightdm-etc-service)
+                  (service-extension profile-service-type
+                                     lightdm-profile-service)))
+                ;; LightDM is extended with lists of seats
+                ;; or with a xorg-configuration by set-xorg-configuration
+                ;; Deal with both cases.
+                (compose
+                 (lambda (extensions)
+                   (receive (xorg-configuration-extensions
+                             seats-extensions)
+                       (partition xorg-configuration? extensions)
+                     (list `("xorg-configuration" .
+                             ;; Mimic handle-xorg-configuration
+                             ,(match xorg-configuration-extensions
+                                (() #f)
+                                ((config . _) config)))
+                           `("seats" . ,(concatenate seats-extensions))))))
+                (extend (lambda (config extensions)
+                          (lightdm-configuration
+                           (inherit config)
+                           (xorg-configuration
+                            (or (assoc-ref extensions "xorg-configuration")
+                                (lightdm-configuration-xorg-configuration config)))
+                           (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.")))
+
+;; GREETERS
+
+(define-record-type* <lightdm-gtk-greeter-configuration>
+  lightdm-gtk-greeter-configuration make-lightdm-gtk-greeter-configuration
+  lightdm-gtk-greeter-configuration?
+
+  (lightdm-gtk-greeter lightdm-gtk-greeter-configuration-lightdm-gtk-greeter
+                       (default lightdm-gtk-greeter))
+  (assets lightdm-gtk-greeter-configuration-assets
+          (default (list adwaita-icon-theme
+                         gnome-themes-standard)))
+  (theme-name lightdm-gtk-greeter-configuration-theme-name
+              (default "Adwaita"))
+  (icon-theme-name
+   lightdm-gtk-greeter-configuration-icon-theme-name
+   (default "Adwaita"))
+  (cursor-theme-name
+   lightdm-gtk-greeter-configuration-cursor-theme-name
+   (default "Adwaita"))
+  (cursor-theme-size lightdm-gtk-greeter-configuration-cursor-theme-size
+                     (default 16))
+  (background lightdm-gtk-greeter-configuration-background
+              (default (file-append %artwork-repository
+                                    "/grub/GuixSD-fully-black-16-9.svg")))
+  (a11y-states lightdm-gtk-greeter-a11y-states
+              (default "contrast; font; keyboard; reader"))
+  (reader lightdm-gtk-greeter-reader
+          (default #f))
+  (seats lightdm-gtk-greeter-configuration-seats
+         (default (list (lightdm-seat-configuration))))
+  (extra-config lightdm-gtk-greeter-configuration-extra-config
+                (default '())))
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (match-record config <lightdm-gtk-greeter-configuration>
+                (theme-name icon-theme-name cursor-theme-name
+                            cursor-theme-size background a11y-states
+                            reader extra-config)
+                (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "          theme-name                         "
+icon-theme-name = "     icon-theme-name                    "
+cursor-theme-name = "   cursor-theme-name                  "
+cursor-theme-size = "   (number->string cursor-theme-size) "
+background = "          background                         "
+a11y-states = "         a11y-states                        "
+" (if reader (string-append "reader = " reader) "") "
+" (string-join extra-config "\n"))))
+
+(define (lightdm-gtk-greeter-lightdm-service config)
+  ;; Enforce greeter-session field to lightdm-gtk-greeter
+  (map
+   (lambda (seat)
+     (lightdm-seat-configuration
+      (inherit seat)
+      (greeter-session "lightdm-gtk-greeter")))
+   (lightdm-gtk-greeter-configuration-seats config)))
+
+(define (lightdm-gtk-greeter-etc-service config)
+  `(("xdg/lightdm/lightdm-gtk-greeter.conf"
+     ,(lightdm-gtk-greeter-configuration-file config))))
+
+(define (lightdm-gtk-greeter-profile-service config)
+  (cons (lightdm-gtk-greeter-configuration-lightdm-gtk-greeter config)
+        (lightdm-gtk-greeter-configuration-assets config)))
+
+(define lightdm-gtk-greeter-service-type
+  (service-type (name 'lightdm-gtk-greeter)
+                (extensions
+                 (list
+                  (service-extension lightdm-service-type
+                                     lightdm-gtk-greeter-lightdm-service)
+                  (service-extension etc-service-type
+                                     lightdm-gtk-greeter-etc-service)
+                  (service-extension profile-service-type
+                                     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.")))
-- 
2.26.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #10: 0009-gnu-lightdm-gtk-greeter-Set-XCURSOR_PATH-in-wrapper.patch --]
[-- Type: text/x-patch, Size: 1727 bytes --]

From 879cced7b0205035407dfa680966e5672e77da9c Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Fri, 17 Apr 2020 11:53:51 +0200
Subject: [PATCH 9/9] gnu: lightdm-gtk-greeter: Set XCURSOR_PATH in wrapper.

* gnu/packages/display-managers.scm (lightdm-gtk-greeter)[arguments]:
Modify wrap-program phase to add XCURSOR_PATH.
---
 gnu/packages/display-managers.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 3d0a118e27..1f82ccc065 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -239,11 +239,12 @@ display manager which supports different greeters.")
                                           "/sbin/lightdm-gtk-greeter")
                `("XDG_DATA_DIRS" ":" prefix
                  ,(cons "/run/current-system/profile/share"
-                   (map (lambda (pkg)
-                          (string-append (assoc-ref inputs pkg) "/share"))
-                        '("gtk+" "shared-mime-info" "glib"))))
+                        (map (lambda (pkg)
+                               (string-append (assoc-ref inputs pkg) "/share"))
+                             '("gtk+" "shared-mime-info" "glib"))))
                `("GTK_PATH" ":" prefix (,(assoc-ref inputs "gtk+")))
-               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+"))))
+               `("GIO_EXTRA_MODULES" ":" prefix (,(assoc-ref inputs "gtk+")))
+               `("XCURSOR_PATH" ":" prefix ("/run/current-system/profile/share/icons")))
              #t)))))
     (synopsis "GTK+ greeter for LightDM")
     (home-page "https://launchpad.net/lightdm-gtk-greeter")
-- 
2.26.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-06 14:05 ` L p R n d n
@ 2020-05-08 22:18   ` Ricardo Wurmus
  2020-05-09 15:09     ` L p R n d n
  2022-08-04  2:19   ` [bug#35305] [WIP] " Maxim Cournoyer
  1 sibling, 1 reply; 30+ messages in thread
From: Ricardo Wurmus @ 2020-05-08 22:18 UTC (permalink / raw)
  To: L p R n d n; +Cc: 35305

[-- Attachment #1: Type: text/plain, Size: 123 bytes --]


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


[-- Attachment #2: lightdm.diff --]
[-- Type: text/x-patch, Size: 10820 bytes --]

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   <guix@lprndn.info>
+;;; Copyright © 2019, 2020 L  p R n  d n   <guix@lprndn.info>
+;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; 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.")))

[-- Attachment #3: Type: text/plain, Size: 695 bytes --]


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

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-08 22:18   ` Ricardo Wurmus
@ 2020-05-09 15:09     ` L p R n d n
  2020-05-10 19:21       ` Ricardo Wurmus
  0 siblings, 1 reply; 30+ messages in thread
From: L p R n d n @ 2020-05-09 15:09 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 35305

[-- Attachment #1: Type: text/plain, Size: 851 bytes --]

Hello,


Ricardo Wurmus <rekado@elephly.net> writes:

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

Thanks for the review!

[...]
>  
>  @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.

My bad but here, the `autologin group thing is not applicable in
Guix at least for now. + adding a user to this group outputs an error
So I tried to make a quick fix of the documentation with this patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: no-autologin.diff --]
[-- Type: text/x-patch, Size: 801 bytes --]

diff --git a/doc/guix.texi b/doc/guix.texi
index 54eba225d3..3dd5fe216a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14792,10 +14792,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
-@code{autologin} group.
+If @code{autologin-user} is set, LightDM logs in directly as
+@code{autologin-user} to the session defined in
+@code{default-user-session}.
 
 @item @code{extra-config} (default: @code{'()})
 A list of strings each describing a custom setting to append to the seat

[-- Attachment #3: Type: text/plain, Size: 2149 bytes --]


However it might be interesting to set this up in Guix as it seems to be
used in other linux distribution and looks like a relatively good security
feature. I'm not versed in security but we would at least need to create
this group and modify the pam services. Should I open an issue for that?

[...]

>
> 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.

Everything is looking fine! And the directories as lists is indeed way better.

> 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?

If you only added (service-type lightdm-service-type) without any
greeter, it's expected.
LightDM without autologin needs a greeter. So in this case you just get
a "fallback" session to avoid unnecesseraly breaking the user's
system. I choose not to bring lightdm-gtk-greeter's assets to give the
user a little push toward adding a greeter service. It's very arguable
so if you think we should bring in assets too, let's do it. I can
prepare a patch if you want. The documentation might also be lacking
here. So adding a little comment in the lightdm-service description
might also be enough. What do you think?

> 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?

Didn't succeed either but it should be possible... :/
Looking on the web, on passwordless login, the lightdm-autologin pam is
often cited so this line:

(pam-entry (control "required") (module "pam_succeed_if.so")
           (arguments (list "uid >= 1000")))

might be related. But I'm really not knowledgeable enough on this matter
to give a proper answer.

> --
> Ricardo

Have a nice day,

L  p R n  d n   

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-09 15:09     ` L p R n d n
@ 2020-05-10 19:21       ` Ricardo Wurmus
  2020-05-11 10:14         ` L p R n d n
  2020-05-12  9:59         ` L p R n d n
  0 siblings, 2 replies; 30+ messages in thread
From: Ricardo Wurmus @ 2020-05-10 19:21 UTC (permalink / raw)
  To: L p R n d n; +Cc: 35305


L p R n d n <guix@lprndn.info> writes:

>> I built a VM and noticed that all icons are missing.  Should the service
>> arrange for a certain fallback icon theme to be installed?
>
> If you only added (service-type lightdm-service-type) without any
> greeter, it's expected.
> LightDM without autologin needs a greeter. So in this case you just get
> a "fallback" session to avoid unnecesseraly breaking the user's
> system. I choose not to bring lightdm-gtk-greeter's assets to give the
> user a little push toward adding a greeter service.

Ah, now I understand the comment in lightdm-profile-service.

I think the default configuration should take care of all this.  It
seems problematic to me that users specify “greeter-session” as a mere
string, but the corresponding greeter may not even be installed.  That’s
also what’s bothering me about the greeter search directories.

Would it make sense to let “greeter-session” be a *package* instead of a
string?  Then we could specify the lightdm-gtk-greeter package as the
default and use its output directory as the lookup directory for
greeters — instead of the global system profile.

I think this would be more elegant and reduce potential for
misconfiguration.  What do you think about this?

> It's very arguable
> so if you think we should bring in assets too, let's do it. I can
> prepare a patch if you want.

What do you mean by assets?  Which package provides them?

>> 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?
>
> Didn't succeed either but it should be possible... :/
> Looking on the web, on passwordless login, the lightdm-autologin pam is
> often cited so this line:
>
> (pam-entry (control "required") (module "pam_succeed_if.so")
>            (arguments (list "uid >= 1000")))
>
> might be related. But I'm really not knowledgeable enough on this matter
> to give a proper answer.

I can take a look at this and the other PAM questions you had.

--
Ricardo




^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-10 19:21       ` Ricardo Wurmus
@ 2020-05-11 10:14         ` L p R n d n
  2020-05-12  9:59         ` L p R n d n
  1 sibling, 0 replies; 30+ messages in thread
From: L p R n d n @ 2020-05-11 10:14 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 35305

[-- Attachment #1: Type: text/plain, Size: 2794 bytes --]

Hello,

Ricardo Wurmus <rekado@elephly.net> writes:

> L p R n d n <guix@lprndn.info> writes:
>
>>> I built a VM and noticed that all icons are missing.  Should the service
>>> arrange for a certain fallback icon theme to be installed?
>>
>> If you only added (service-type lightdm-service-type) without any
>> greeter, it's expected.
>> LightDM without autologin needs a greeter. So in this case you just get
>> a "fallback" session to avoid unnecesseraly breaking the user's
>> system. I choose not to bring lightdm-gtk-greeter's assets to give the
>> user a little push toward adding a greeter service.
>
> Ah, now I understand the comment in lightdm-profile-service.

Sorry, my comment was not clear :/

> I think the default configuration should take care of all this.  It
> seems problematic to me that users specify “greeter-session” as a mere
> string, but the corresponding greeter may not even be installed.  That’s
> also what’s bothering me about the greeter search directories.

I agree but just to clarify the current behavior:
* A user can either define only a lightdm-service, only greeter-service.s
or both.
* There can be multiple greeter services defined hence allowing
different greeters, greeter configurations or assets for different seats
* Greeters' services extend the lightdm-service so the latter is really only needed
if you want to modify the default confiuration or do not define any
greeter.
* A seat defined in a greeter service have its `greeter-session
overwritten + get the greeter package for free. This is why defining
seats through the greeter is preferred.

Hope it's clear, I had some troubles with the possessive in those sentences...

> Would it make sense to let “greeter-session” be a *package* instead of a
> string?  Then we could specify the lightdm-gtk-greeter package as the
> default and use its output directory as the lookup directory for
> greeters — instead of the global system profile.

Yet, it's better, yes! So we remove the `greeters-directory field from the
`lightdm-configuration and use a package as input of the greeter-session
field of `lightdm-seat-configuration, right?

> I think this would be more elegant and reduce potential for
> misconfiguration.  What do you think about this?
>
>> It's very arguable
>> so if you think we should bring in assets too, let's do it. I can
>> prepare a patch if you want.
>
> What do you mean by assets?  Which package provides them?

I meant the assets used by the greeter. They're defined in the
`lightdm-gtk-greeter-configuration-assets field of the
lightdm-gtk-greeter's configuration. It's really the only thing lacking
in the fallback session. A little patch that should be enough to fix the
missing icons.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: add-default-assets.diff --]
[-- Type: text/x-patch, Size: 606 bytes --]

diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
index fa5330aade..0ef7f43215 100644
--- a/gnu/services/lightdm.scm
+++ b/gnu/services/lightdm.scm
@@ -291,7 +291,9 @@ remote-sessions-directory = " ,remote-sessions-directory "
   (let ((seats (lightdm-configuration-seats config))
         (lightdm (lightdm-configuration-lightdm config)))
     (if (null? seats)
-        (list lightdm lightdm-gtk-greeter)
+        (list lightdm lightdm-gtk-greeter
+              ;; assets
+              adwaita-icon-theme gnome-themes-standard)
         (list lightdm))))
 
 (define lightdm-service-type

[-- Attachment #3: Type: text/plain, Size: 786 bytes --]


>>> 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?
>>
>> Didn't succeed either but it should be possible... :/
>> Looking on the web, on passwordless login, the lightdm-autologin pam is
>> often cited so this line:
>>
>> (pam-entry (control "required") (module "pam_succeed_if.so")
>>            (arguments (list "uid >= 1000")))
>>
>> might be related. But I'm really not knowledgeable enough on this matter
>> to give a proper answer.
>
> I can take a look at this and the other PAM questions you had.

That would be nice! Beside this point, it's really checking that
there are no errors.

> --
> Ricardo

Have a nice day,

L  p R n  d n

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-10 19:21       ` Ricardo Wurmus
  2020-05-11 10:14         ` L p R n d n
@ 2020-05-12  9:59         ` L p R n d n
  2020-05-20 20:51           ` Ricardo Wurmus
  1 sibling, 1 reply; 30+ messages in thread
From: L p R n d n @ 2020-05-12  9:59 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 35305

[-- Attachment #1: Type: text/plain, Size: 143 bytes --]

Hello,

Little from my side, I forgot to add the polkit extension of the lightdm
service so here is a patch.

Have a nice day,

L  p R n  d n


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0010-services-lightdm-Extend-polkit-service.patch --]
[-- Type: text/x-patch, Size: 1150 bytes --]

From e40317008723f27743f72f90008587ca2f779dde Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Mon, 11 May 2020 20:15:55 +0200
Subject: [PATCH 10/10] services: lightdm: Extend polkit service.

* gnu/services/lightdm.scm (lightdm-service-type): Add the LightDM package to
the polkit service.
---
 gnu/services/lightdm.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
index fa5330aade..5edeecd195 100644
--- a/gnu/services/lightdm.scm
+++ b/gnu/services/lightdm.scm
@@ -308,6 +308,8 @@ remote-sessions-directory = " ,remote-sessions-directory "
                   (service-extension dbus-root-service-type
                                      (compose list
                                               lightdm-configuration-lightdm))
+                  (service-extension polkit-service-type
+                                     (compose list lightdm-configuration-lightdm))
                   (service-extension account-service-type
                                      (const %lightdm-accounts))
                   (service-extension etc-service-type
-- 
2.26.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-12  9:59         ` L p R n d n
@ 2020-05-20 20:51           ` Ricardo Wurmus
  2020-05-21  8:28             ` L p R n d n
  0 siblings, 1 reply; 30+ messages in thread
From: Ricardo Wurmus @ 2020-05-20 20:51 UTC (permalink / raw)
  To: L p R n d n; +Cc: 35305

Hey,

I’m very sorry for the delay.

What took me so long is that I’m conflicted about how to move forward.
On one hand I really don’t want to delay this.  I think your patches are
a great and important addition to Guix.  On the other hand I feel that
the relationship between these new components isn’t quite right.

It still doesn’t feel quite right to me that there’s a
lightdm-service-type and an independent
lightdm-gtk-greeter-service-type.  I know that there can be any number
of greeters, but only one will be used with lightdm-service-type
dependent on the string value of greeter-session.  This leads to
potential misconfiguration as we don’t (and can’t) validate this string.

It also feels wrong to me to have a global directory as the only
location for greeter desktop files, which means that all greeters must
be installed globally.

What I envision is something like this: we only have a single
lightdm-service-type and it has a field “greeters”, which by default is
a list of just one item: a <greeter> record containing the
lightdm-gtk-greeter and its configuration.

Other greeters could be added; they would all be record values of type
<greeter> and come with their own extensions of the
ligthdm-service-type.

The lightdm-service-type would go through each of the greeters in the
list and apply their specified extensions to itself.

The reason why I haven’t implemented this yet is because a) I don’t want
to break what already works with your patches and b) I don’t know if
that’s ultimately a clearer implementation.

I feel that this would be a more intuitive configuration and result in
clearer relationships between the display manager and its swappable
components.  It would also allow for better defaults (so less
configuration needed) and avoid the problem of stringy types that are
easy to get wrong.

Maybe we are already really close to this solution, though: maybe the
proposed “greeter” field could simply accept service types like the
lightdm-gtk-greeter-service-type you already defined.

I’m going to play with this a little bit more, but if this doesn’t lead
anywhere I’ll merge the current version.

My apologies for delaying this!

-- 
Ricardo




^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-20 20:51           ` Ricardo Wurmus
@ 2020-05-21  8:28             ` L p R n d n
  2020-05-21  9:23               ` Ricardo Wurmus
  0 siblings, 1 reply; 30+ messages in thread
From: L p R n d n @ 2020-05-21  8:28 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: brice, 35305

Hello,

Ricardo Wurmus <rekado@elephly.net> writes:

> Hey,
>
> I’m very sorry for the delay.

Again, there's no hurry. ;)

> What took me so long is that I’m conflicted about how to move forward.
> On one hand I really don’t want to delay this.  I think your patches are
> a great and important addition to Guix.  On the other hand I feel that
> the relationship between these new components isn’t quite right.
>
> It still doesn’t feel quite right to me that there’s a
> lightdm-service-type and an independent
> lightdm-gtk-greeter-service-type.  I know that there can be any number
> of greeters, but only one will be used with lightdm-service-type
> dependent on the string value of greeter-session.  This leads to
> potential misconfiguration as we don’t (and can’t) validate this string.

Just to clarify, as per my understanding, there can be multiple
`greeter-session fields defined. It's not a global value but a per seat
one. Each seat should be able to use a different greeter, I
think. Personally, I have a very standard use whith only one seat so
there are no questions in that case. However there might be use-cases
where it's needed. I CC bricewge, they might be more knowledgeable on
this issue.

> It also feels wrong to me to have a global directory as the only
> location for greeter desktop files, which means that all greeters must
> be installed globally.

Isn't using packages as inputs of `greeter-session solving this issue?
We can collect them from seats and string-join them into the
`greeter-directory field.

> What I envision is something like this: we only have a single
> lightdm-service-type and it has a field “greeters”, which by default is
> a list of just one item: a <greeter> record containing the
> lightdm-gtk-greeter and its configuration.
>
> Other greeters could be added; they would all be record values of type
> <greeter> and come with their own extensions of the
> ligthdm-service-type.
>
> The lightdm-service-type would go through each of the greeters in the
> list and apply their specified extensions to itself.

If I understand correctly, the main difference would be that the
greeters would be defined from within the lightdm-service (as a list of records?), right?
The current implementation was chosen to avoid too much field nesting
but I don't mind.
Also, you can have a look at the previous implementation (see
mail from 19th of March). It lacks seats and some featurse but it looks a
little closer to what you're describing. It might give some ideas.

> The reason why I haven’t implemented this yet is because a) I don’t want
> to break what already works with your patches and b) I don’t know if
> that’s ultimately a clearer implementation.
>
> I feel that this would be a more intuitive configuration and result in
> clearer relationships between the display manager and its swappable
> components.  It would also allow for better defaults (so less
> configuration needed) and avoid the problem of stringy types that are
> easy to get wrong.
>
> Maybe we are already really close to this solution, though: maybe the
> proposed “greeter” field could simply accept service types like the
> lightdm-gtk-greeter-service-type you already defined.

We're close. :)
Just curious here, if we use a list of services (for example) as input of
the greeters field, how do we take care of it? Can we "merge" the
different services into the lightdm one? If it's possible, this might be
a good solution.

> I’m going to play with this a little bit more, but if this doesn’t lead
> anywhere I’ll merge the current version.
>
> My apologies for delaying this!

Everything is going a lot faster than it was a few months ago so it's
already fine.

Have a nice day,

L  p R n  d n




^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-21  8:28             ` L p R n d n
@ 2020-05-21  9:23               ` Ricardo Wurmus
  2020-06-08 15:35                 ` L p R n d n
  2020-06-19 14:47                 ` [bug#35305] " L p R n d n
  0 siblings, 2 replies; 30+ messages in thread
From: Ricardo Wurmus @ 2020-05-21  9:23 UTC (permalink / raw)
  To: L p R n d n; +Cc: brice, 35305


L p R n d n <guix@lprndn.info> writes:

> Hello,
>
> Ricardo Wurmus <rekado@elephly.net> writes:
>
>> Hey,
>>
>> I’m very sorry for the delay.
>
> Again, there's no hurry. ;)
>
>> What took me so long is that I’m conflicted about how to move forward.
>> On one hand I really don’t want to delay this.  I think your patches are
>> a great and important addition to Guix.  On the other hand I feel that
>> the relationship between these new components isn’t quite right.
>>
>> It still doesn’t feel quite right to me that there’s a
>> lightdm-service-type and an independent
>> lightdm-gtk-greeter-service-type.  I know that there can be any number
>> of greeters, but only one will be used with lightdm-service-type
>> dependent on the string value of greeter-session.  This leads to
>> potential misconfiguration as we don’t (and can’t) validate this string.
>
> Just to clarify, as per my understanding, there can be multiple
> `greeter-session fields defined. It's not a global value but a per seat
> one. Each seat should be able to use a different greeter, I
> think. Personally, I have a very standard use whith only one seat so
> there are no questions in that case. However there might be use-cases
> where it's needed. I CC bricewge, they might be more knowledgeable on
> this issue.

Right, I realized this after composing my message.  However, currently
the lightdm-gtk-greeter-service-type inherits all the seats and then
overrides the greeter-session value for each of them, which seems rather
rude.  So maybe it is wrong to let greeters do that at all.

I wondered why there’s a service type for the greeter at all, so I
looked at the service extensions it provides:

* lightdm-service-type: only used to override greeter-session in all
  defined seats, which seems like an anti-feature.  If other greeters
  do the same, then effectively there can only be one greeter for all
  seats, and that would be wrong.  So seat configuration really should
  remain in lightdm-service-type and not be an extension.

* etc-service-type: that’s to provide the greeter’s global configuration
  file.  Ideally, we would not need to use a global configuration file.
  It looks like lightdm-gtk-greeter respects the XDG_CONFIG_DIRS
  variable, so we should be able to generate its configuration file in
  an arbitrary location and then add it to XDG_CONFIG_DIRS in the
  environment of lightdm itself.

* profile-service-type: that’s to install lightdm-gtk-greeter and its
  assets into the system profile.  Again, that’s something we should aim
  to avoid.  It seems that we can avoid it with the use of environment
  variables in the lightdm shepherd service.

If we can avoid all three extensions then we don’t need a
lightdm-gtk-greeter-service-type at all.  If we don’t need a service we
can specify greeters as record type values with a name and configuration
file generator.

-- 
Ricardo




^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-21  9:23               ` Ricardo Wurmus
@ 2020-06-08 15:35                 ` L p R n d n
  2022-08-04  5:09                   ` [bug#35305] [WIP] " Maxim Cournoyer
  2020-06-19 14:47                 ` [bug#35305] " L p R n d n
  1 sibling, 1 reply; 30+ messages in thread
From: L p R n d n @ 2020-06-08 15:35 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: brice, 35305

Hello,

I spent some time thinking about the lightdm service and what are our
possibilities so here are my thoughts and conclusions.

(Here, I'll only describe relations between seats, greeters and the lightdm
service as it's our main source of problems)

So if we get rid of the greeter's services, we can have:

1:
(service lightd-service-type
    (lightdm-configuration
        (greeters
            (list
                (lightdm-gtk-greeter-configuration
                  (seats
                      (list
                          (lightdm-seat-configuration ...))))))))

Here seats are defined by greeters. This way the user doesn't need to
fill `greeter-session field as we can do it automatically. But there's a lot of nesting
(and two lists.) + How do we define autologin?

2:
(service lightd-service-type
    (lightdm-configuration
        (seats
            (list
                (lightdm-seat-configuration
                    (greeter-session
                        (lightdm-gtk-greeter-configuration ...)))))))

Defining greeters inside seats allows in the `greeter-session field make
it a little simpler. However, we would get errors or conflicts if a user
define two different configurations of the same greeter for two
different seats. The thing is that we can only have one configuration
per greeter as it will always look for a hardcoded file in /etc/ (worst
case) or a file we hardcoded at build time (best case). :/

3:
(service lightd-service-type
    (lightdm-configuration
        (seats
            (list
                (lightdm-seat-configuration
                    (greeter-session 'lightdm-gtk-greeter))))
        (greeters
            (list
                (lightdm-gtk-greeter-configuration
                  )))))

We can have separate fields for greeters and seats. The user will have
to define `greeter-session by himself. And what happen if they define
multiple occurences of one greeter's configuration?


So my conclusion is that the current implementation using a different service for lightdm and its
greeters is probably not so bad as it prevents most of these
issues. Unless someone has an even better idea, indeed. :D

Ricardo Wurmus <rekado@elephly.net> writes:

> L p R n d n <guix@lprndn.info> writes:
>
>> Hello,
>>
>> Ricardo Wurmus <rekado@elephly.net> writes:
[...]
> Right, I realized this after composing my message.  However, currently
> the lightdm-gtk-greeter-service-type inherits all the seats and then
> overrides the greeter-session value for each of them, which seems rather
> rude.  So maybe it is wrong to let greeters do that at all.
>
> I wondered why there’s a service type for the greeter at all, so I
> looked at the service extensions it provides:
>
> * lightdm-service-type: only used to override greeter-session in all
>   defined seats, which seems like an anti-feature.  If other greeters
>   do the same, then effectively there can only be one greeter for all
>   seats, and that would be wrong.  So seat configuration really should
>   remain in lightdm-service-type and not be an extension.

As disussed on IRC, a greeter service only overwrites its own
`greeter-session field. But we could get rid of the `greeter-session
field altogether as it's probably not necessary if they're filled by the
greeters' service or record (depending of what we choose).

> * etc-service-type: that’s to provide the greeter’s global configuration
>   file.  Ideally, we would not need to use a global configuration file.
>   It looks like lightdm-gtk-greeter respects the XDG_CONFIG_DIRS
>   variable, so we should be able to generate its configuration file in
>   an arbitrary location and then add it to XDG_CONFIG_DIRS in the
>   environment of lightdm itself.

I didn't find any informations about lightdm-gtk-greeter using
XDG_CONFIG_DIRS. Could you provide further explaination as it could
impact what I wrote earlier.

> * profile-service-type: that’s to install lightdm-gtk-greeter and its
>   assets into the system profile.  Again, that’s something we should aim
>   to avoid.  It seems that we can avoid it with the use of environment
>   variables in the lightdm shepherd service.

Yeah ;)

> If we can avoid all three extensions then we don’t need a
> lightdm-gtk-greeter-service-type at all.  If we don’t need a service we
> can specify greeters as record type values with a name and configuration
> file generator.

Hope it's clear, I'm really just dumping my thoughts... :)
Please tell me what you think.

Have a nice day,

L  p R n  d n




^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] LightDM service
  2020-05-21  9:23               ` Ricardo Wurmus
  2020-06-08 15:35                 ` L p R n d n
@ 2020-06-19 14:47                 ` L p R n d n
  1 sibling, 0 replies; 30+ messages in thread
From: L p R n d n @ 2020-06-19 14:47 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: brice, 35305

[-- Attachment #1: Type: text/plain, Size: 1647 bytes --]

Hello,

Here I come again with a new attempt for the LightDM service.
This one is a little too complex to my taste but it succeeds IMHO at
dealing with most cases nicely. Also I didn't find any other occurence
of this in Guix, so it might just not fit in. It's a draft and it's
ugly, it probably needs some refactoring/renaming, maybe using methods?
or just alists?

In the meantime, the chosen design is to have the lightdm-service and
greeter services to extend another, private service (lightdm-aggregate)
that deals with mergin everything all configuration and extending the
needed services accordingly. This way, data can be shared between
lightdm's and greeters' configurations (here, greeters' desktop file
directories and a list of greeters needed by the seats definition)

It features:

* A user can define only the a lightdm-service or only a greeter service
  or both, he should always get a working LightDM. If a seats asks for a
  greeter which is not defined in the user config, the lightdm-aggregate
  service adds its service with default config.

* Seats are defined only in the lightdm service so, on one hand, the user needs to
  manually set the `greeter-session field but, on the other hand, we get
  a clear distinction between configurations.

* Too many (cond ...). There might be better solutions.


Please give me your opinion. I think I'll try one last design which will
be the complete opposite of this one. (lightdm-service deals with its
conf, greeters deal with theirs. The user deals with the rest. Also
(service lightdm-service-type) is not enough for a working
display-manager).

Have a nice day,

L  p R n  d n


[-- Attachment #2: 0001-services-Add-lightdm-service-type.patch --]
[-- Type: text/x-patch, Size: 27380 bytes --]

From dad5c510f6c7bbe96140a49d4eb795e8b735c405 Mon Sep 17 00:00:00 2001
From: L  p R n  d n <guix@lprndn.info>
Date: Thu, 18 Apr 2019 17:58:56 +0200
Subject: [PATCH] services: Add lightdm-service-type.

* gnu/services/lightdm.scm: Add file
(<lightdm-configuration>, <lightdm-seat-configuration>,
<lightdm-gtk-greeter-configuration>): New record types.
(lightdm-seat-configuration->list, lightdm-configuration-file,
lightdm-pam-services, lightdm-pam-service, lightdm-etc-service,
lightdm-shepherd-service, lightdm-profile-service,
lightdm-gtk-greeter-configuration-file, lightdm-gtk-greeter-profile-service,
lightdm-gtk-greeter-lightdm-service, lightdm-gtk-greeter-etc-service): New
procedures.
(%lightdm-accounts, %lightdm-activation, lightdm-greeter-pam-service,
lightdm-autologin-pam-service, lightdm-service-type,
lightdm-gtk-greeter-service-type): New variables.
* doc/guix.texi (X Window): Add documentation.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 doc/guix.texi            | 123 ++++++++++
 gnu/local.mk             |   1 +
 gnu/services/lightdm.scm | 496 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 620 insertions(+)
 create mode 100644 gnu/services/lightdm.scm

diff --git a/doc/guix.texi b/doc/guix.texi
index 2268e159a2..be45313ac5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -15325,6 +15325,129 @@ auto-login session.
 @end table
 @end deftp
 
+@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'
+services for their specific configuration.
+@end defvr
+
+@deftp {Data Type} lightdm-configuration
+Data type representing the LightDM service configuration.
+
+@table @asis
+@item @code{lightdm} (default: @code{lightdm})
+The LightDM package to use.
+
+@item @code{allow-empty-passwords?} (default: @code{#f})
+Whether to allow logins with empty passwords.
+
+@item @code{xorg-configuration} (default: @code{(xorg-configuration)})
+Default configuration of the Xorg graphical server. This configuration
+will be used for all seats unless explicitly defined.
+
+@item @code{sessions-directories} (default:'("/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{greeters-directories} (default:'("$XDG_DATA_DIRS/lightdm/greeters" "$XDG_DATA_DIRS/xgreeters" "/run/current-system/profile/share/xgreeters"))
+Directories where LightDM will search for sessions' @code{.desktop} files.
+
+@item @code{remote-sessions-directories} (default:'("/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.
+
+@item @code{extra-config} (default: @code{'()})
+A list of strings each describing a custom setting to append to the LightDM
+configuration.
+
+@end table
+@end deftp
+
+@deftp {Data Type} lightdm-seat-configuration
+Record representing a seat configuration for LightDM.
+
+@table @asis
+@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{xorg-configuration} (default: @code{#f})
+Configuration of the Xorg graphical server.
+
+@item @code{session-wrapper} (default: @code{(xinitrc)})
+Script to run before starting a X session.
+
+@item @code{greeter-session} (default: 'lightdm-gtk-greeter)
+The name of the greeter to be used for this seat.
+
+@item @code{default-user-session} (default: "")
+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}.
+
+@item @code{extra-config} (default: @code{'()})
+A list of strings each describing a custom setting to append to the seat
+configuration.
+
+@end table
+@end deftp
+
+@defvr {Scheme Variable} lightdm-gtk-greeter-service-type
+Service type for the @code{lightdm-gtk-greeter} for LightDM.
+See @code{lightdm-gtk-greeter-configuration} below for configuration.
+@end defvr
+
+@deftp {Data Type} lightdm-gtk-greeter-configuration
+This data type represents the configuration for @code{lightdm-gtk-greeter}.
+Use it as an argument of @code{lightdm-gtk-greeter-configuration-file} to
+get the corresponding file.
+
+@table @asis
+@item @code{lightdm-gtk-greeter} (default: @code{lightdm-gtk-greeter})
+lightdm-gtk-greeter package to use.
+
+@item @code{assets} (default: @code{(list adwaita-icon-theme gnome-themes-standard)})
+A list of packages needed by the greeter: icons, themes, fonts etc.
+
+@item @code{theme-name} (default: "Adwaita")
+The name of the GTK+ theme to be used.
+
+@item @code{icon-theme-name} (default: "Adwaita")
+The name of the icon theme to be used for displaying icons.
+
+@item @code{cursor-theme-name} (default: "Adwaita")
+The name of the theme to be used for the cursor.
+
+@item @code{cursor-size} (default: @code{16})
+The size of the cursor.
+
+@item @code{background} (default: @code{(file-append %artwork-repository "/grub/GuixSD-fully-black-16-9.svg")})
+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
+on exit, @code{"-name"} disables at start and @code{"+name"} enables it.
+
+@item @code{reader} (default: "")
+Command to launch screen reader.
+
+@item @code{extra-config} (default: @code{'()})
+A list of string each describing a custom setting to append to the greeter
+configuration.
+
+@end table
+@end deftp
+
 @cindex Xorg, configuration
 @deftp {Data Type} xorg-configuration
 This data type represents the configuration of the Xorg graphical display
diff --git a/gnu/local.mk b/gnu/local.mk
index fd3cc88af5..6d19b54874 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -586,6 +586,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/guix.scm			\
   %D%/services/hurd.scm				\
   %D%/services/kerberos.scm			\
+  %D%/services/lightdm.scm      		\
   %D%/services/linux.scm			\
   %D%/services/lirc.scm				\
   %D%/services/virtualization.scm		\
diff --git a/gnu/services/lightdm.scm b/gnu/services/lightdm.scm
new file mode 100644
index 0000000000..1869140609
--- /dev/null
+++ b/gnu/services/lightdm.scm
@@ -0,0 +1,496 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019,2020 L  p R n  d n   <guix@lprndn.info>
+;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (gnu services lightdm)
+  #:use-module (srfi srfi-1)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 receive)
+
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+
+  #:use-module (gnu artwork)
+  #:use-module (gnu system pam)
+  #:use-module (gnu system shadow)
+
+  #:use-module (gnu services)
+  #:use-module (gnu services dbus)
+  #:use-module (gnu services desktop)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu services xorg)
+
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages display-managers)
+  #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
+  #:use-module (gnu packages xorg)
+
+  #:export (lightdm-seat-configuration
+
+            lightdm-configuration
+            lightdm-configuration?
+            lightdm-service-type
+
+            lightdm-gtk-greeter-configuration
+            lightdm-gtk-greeter-configuration?
+            lightdm-gtk-greeter-service-type))
+
+;; GREETERS
+
+(define-record-type* <lightdm-gtk-greeter-configuration>
+  lightdm-gtk-greeter-configuration make-lightdm-gtk-greeter-configuration
+  lightdm-gtk-greeter-configuration?
+
+  (lightdm-gtk-greeter lightdm-gtk-greeter-configuration-lightdm-gtk-greeter
+                       (default lightdm-gtk-greeter))
+  (assets lightdm-gtk-greeter-configuration-assets
+          (default (list adwaita-icon-theme
+                         gnome-themes-standard)))
+  (theme-name lightdm-gtk-greeter-configuration-theme-name
+              (default "Adwaita"))
+  (icon-theme-name
+   lightdm-gtk-greeter-configuration-icon-theme-name
+   (default "Adwaita"))
+  (cursor-theme-name
+   lightdm-gtk-greeter-configuration-cursor-theme-name
+   (default "Adwaita"))
+  (cursor-theme-size lightdm-gtk-greeter-configuration-cursor-theme-size
+                     (default 16))
+  (background lightdm-gtk-greeter-configuration-background
+              (default (file-append %artwork-repository
+                                    "/grub/GuixSD-fully-black-16-9.svg")))
+  (a11y-states lightdm-gtk-greeter-a11y-states
+               (default "contrast; font; keyboard; reader"))
+  (reader lightdm-gtk-greeter-reader
+          (default #f))
+  (extra-config lightdm-gtk-greeter-configuration-extra-config
+                (default '())))
+
+(define (lightdm-gtk-greeter-configuration-file config)
+  (match-record config <lightdm-gtk-greeter-configuration>
+                (theme-name icon-theme-name cursor-theme-name
+                            cursor-theme-size background a11y-states
+                            reader extra-config)
+                (mixed-text-file "lightdm-gtk-greeter.conf" "
+[greeter]
+theme-name = "          theme-name                         "
+icon-theme-name = "     icon-theme-name                    "
+cursor-theme-name = "   cursor-theme-name                  "
+cursor-theme-size = "   (number->string cursor-theme-size) "
+background = "          background                         "
+a11y-states = "         a11y-states                        "
+" (if reader (string-append "reader = " reader) "") "
+" (string-join extra-config "\n"))))
+
+;; LIGHTDM
+
+(define-record-type* <lightdm-seat-configuration>
+  lightdm-seat-configuration make-lightdm-seat-configuration
+  lightdm-seat-configuration?
+  (name-glob lightdm-seat-configuration-name-glob
+             (default "*"))
+  (type lightdm-seat-configuration-type
+        (default 'local))
+  (xorg-configuration lightdm-seat-configuration-xorg-configuration
+                      (default #f))
+  (session-wrapper lightdm-seat-configuration-session-wrapper
+                   (default (xinitrc)))
+  (greeter-session lightdm-seat-configuration-greeter-session
+                   (default 'lightdm-gtk-greeter))
+  (default-user-session lightdm-seat-configuration-default-user-session
+    (default ""))
+  (autologin-user lightdm-seat-configuration-autologin-user
+                  (default ""))
+  (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."
+  (match-record seat <lightdm-seat-configuration>
+                (name-glob
+                 type xorg-configuration session-wrapper
+                 greeter-session default-user-session
+                 autologin-user extra-config)
+                (list "
+  [Seat:"               name-glob                              "]
+  type = "              (symbol->string type)
+  ;; If no xorg-configuration is set by the seat use the one provided
+  ;; by the lightdm service
+  "
+  xserver-command = "   (xorg-start-command
+                         (or xorg-configuration
+                             default-xorg-configuration))
+  "
+  session-wrapper = "   session-wrapper                         "
+  greeter-session = "   (symbol->string greeter-session)
+  (if (string-null? default-user-session) ""
+      (string-append "
+  user-session = "      default-user-session))                  "
+  "
+  ;; Turn autologin ON if autologin-user is set
+  (if (string-null? autologin-user) ""
+      (string-append "
+  autologin-user = "    autologin-user                          "
+  autologin-session = " default-user-session))                  "
+  " (string-join extra-config "\n"))))
+
+
+(define-record-type* <lightdm-configuration>
+  lightdm-configuration make-lightdm-configuration
+  lightdm-configuration?
+  ;; General configuration
+  (lightdm lightdm-configuration-lightdm
+           (default lightdm))
+  (allow-empty-passwords? lightdm-configuration-allow-empty-passwords?
+                          (default #f))
+  (sessions-directories
+   lightdm-configuration-sessions-directory
+   (default '("/run/current-system/profile/share/xsessions"
+              "/run/current-system/profile/share/wayland-sessions")))
+  (greeters-directories lightdm-configuration-greeters-directories
+                        (default '("$XDG_DATA_DIRS/lightdm/greeters"
+                                  "$XDG_DATA_DIRS/xgreeters"
+                                  "/run/current-system/profile/share/xgreeters")))
+  (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
+                      (default (xorg-configuration)))
+  (seats lightdm-configuration-seats
+         (default (list (lightdm-seat-configuration))))
+  (extra-config lightdm-configuration-extra-config
+                (default '())))
+
+(define (lightdm-configuration-file config)
+  (match-record config <lightdm-configuration>
+                (allow-empty-passwords?
+                 sessions-directories greeters-directories
+                 remote-sessions-directories xorg-configuration
+                 seats extra-config)
+                ;; Little trick to allow unquote-splicing of seats
+                (apply mixed-text-file "lightdm.conf" "
+[LightDM]
+greeter-user = lightdm
+greeters-directory = " #~(string-join '#$greeters-directories ":") "
+sessions-directory = " (string-join sessions-directories ":") "
+remote-sessions-directory = " (string-join remote-sessions-directories ":") "
+
+#Seats
+ " (append
+    (concatenate
+     (map (lambda (seat)
+            (lightdm-seat-configuration->list seat xorg-configuration))
+          seats))
+    (list "
+#Extra config
+" (string-join extra-config "\n"))))))
+
+(define %lightdm-accounts
+  (list (user-group (name "lightdm") (system? #t))
+        (user-account
+         (name "lightdm")
+         (group "lightdm")
+         (system? #t)
+         (comment "LightDM user")
+         (home-directory "/var/lib/lightdm")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define %lightdm-activation
+  ;; Ensure /var/lib/lightdm is owned by the "lightdm" user.
+  ;; Mimics what is done for gdm
+  ;; see a43e9157ef479e94c19951cc9d228cf153bf78ee
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils))
+
+        (define (ensure-ownership directory)
+          (let* ((lightdm (getpwnam "lightdm"))
+                 (uid (passwd:uid lightdm))
+                 (gid (passwd:gid lightdm))
+                 (st  (stat directory #f)))
+            ;; Recurse into directory only if it has wrong ownership.
+            (when (and st
+                       (or (not (= uid (stat:uid st)))
+                           (not (= gid (stat:gid st)))))
+              (for-each (lambda (file)
+                          (chown file uid gid))
+                        (find-files "directory"
+                                    #:directories? #t)))))
+
+        (when (not (stat "/var/lib/lightdm-data" #f))
+          (mkdir-p "/var/lib/lightdm-data"))
+        (for-each ensure-ownership
+                  '("/var/lib/lightdm"
+                    "/var/lib/lightdm-data")))))
+
+(define (lightdm-pam-service config)
+  "Return a PAM service for @command{lightdm}."
+  (unix-pam-service
+   "lightdm"
+   #:login-uid? #t
+   #:allow-empty-passwords?
+   (lightdm-configuration-allow-empty-passwords? config)))
+
+
+(define (lightdm-greeter-pam-service)
+  "Return a PAM service for @command{lightdm-greeter}}."
+  (pam-service
+   (name "lightdm-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"))))
+   ;; No action required for account management
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+
+(define (lightdm-autologin-pam-service)
+  "Return a PAM service for @command{lightdm-autologin}}."
+  (pam-service
+   (name "lightdm-autologin")
+   (auth
+    (list
+     ;; Block login if they are globally disabled
+     (pam-entry (control "required") (module "pam_nologin.so"))
+
+     (pam-entry (control "required") (module "pam_succeed_if.so")
+                (arguments (list "uid >= 1000")))
+     ;; Allow access without authentication
+     (pam-entry (control "required") (module "pam_permit.so"))))
+   ;; Stop autologin if account requires action
+   (account
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))
+   ;; Can't change password
+   (password
+    (list
+     (pam-entry (control "required") (module "pam_deny.so"))))
+   ;; Setup session
+   (session
+    (list
+     (pam-entry (control "required") (module "pam_unix.so"))))))
+
+(define (lightdm-pam-services config)
+  (list (lightdm-pam-service config)
+        (lightdm-greeter-pam-service)
+        (lightdm-autologin-pam-service)))
+
+(define (lightdm-shepherd-service config)
+  "Return a <lightdm-service> for LightDM with CONFIG."
+
+  (define lightdm-command
+    #~(list #$(file-append (lightdm-configuration-lightdm config)
+                           "/sbin/lightdm")
+            "-c"
+            #$(lightdm-configuration-file config)))
+
+  (define lightdm-paths
+    (let ((lightdm (lightdm-configuration-lightdm config)))
+      #~(string-join
+         '#$(map (lambda (dir)
+                   (file-append lightdm dir))
+                 '("/bin" "/sbin" "/libexec"))
+         ":")))
+
+  (list
+   (shepherd-service
+    (documentation "LightDM display manager.")
+    (requirement '(dbus-system user-processes host-name))
+    (provision '(display-manager xorg-server))
+    (respawn? #f)
+    (start
+     #~(lambda ()
+         (fork+exec-command
+          #$lightdm-command
+          ;; Lightdm needs itself in its PATH
+          #:environment-variables
+          (list
+           (string-append "PATH=" #$lightdm-paths)))))
+    (stop #~(make-kill-destructor)))))
+
+;; LightDM Aggregate
+
+(define-record-type* <lightdm-aggregate>
+  lightdm-aggregate make-lightdm-aggregate
+  lightdm-aggregate?
+  (lightdm lightdm-aggregate-lightdm
+           (default (lightdm-configuration)))
+  (greeters lightdm-aggregate-greeters
+            (default '())))
+
+;; WHAT TO DO IF THERE IS A NON DEFAULT GREETER SERVICE AND
+;; A DEFAULT LIGHTDM SERVICE DEFINED OR THE OPPOSITE
+
+;;
+(define (greeter-default-configuration greeter-symbol)
+  "Given a greeter's symbol, return its default configuration."
+  (cond
+   ((eq? 'lightdm-gtk-greeter greeter-symbol)
+    (lightdm-gtk-greeter-configuration))
+   (else #f)))
+
+(define (greeter-desktop-directory greeter-config)
+  "Return the directory providing the greeter's .desktop file given a
+configuration object. Return #F for unknown greeters."
+  (cond
+   ((lightdm-gtk-greeter-configuration? greeter-config)
+    (file-append (lightdm-gtk-greeter-configuration-lightdm-gtk-greeter
+                  greeter-config)
+                 "/share/xgreeters"))
+   (else #f)))
+
+(define (lightdm-gtk-greeter-etc-service config)
+  `(("xdg/lightdm/lightdm-gtk-greeter.conf"
+     ,(lightdm-gtk-greeter-configuration-file config))))
+
+(define (lightdm-gtk-greeter-profile-service config)
+  (lightdm-gtk-greeter-configuration-assets config))
+
+(define (lightdm-greeter-etc-service greeter-config)
+  (cond
+   ((lightdm-gtk-greeter-configuration? greeter-config)
+    (lightdm-gtk-greeter-etc-service greeter-config))
+   (else #f)))
+
+(define (lightdm-greeter-profile-service greeter-config)
+  (cond
+   ((lightdm-gtk-greeter-configuration? greeter-config)
+    (lightdm-gtk-greeter-profile-service greeter-config))
+   (else #f)))
+
+(define (augment-greeters-directories lightdm-config greeters)
+  "Returns a new lightdm-configuration record based on @code{lightdm-conf}
+but with @code{greeters} available in its @code{greeters-directories} field."
+  (lightdm-configuration
+   (inherit lightdm-config)
+   (greeters-directories
+    (append (map greeter-desktop-directory greeters)
+            (lightdm-configuration-greeters-directories lightdm-config)))))
+
+(define (aggregate->greeters aggregate)
+  "Given a lightdm-aggregate, outputs a list of greeter
+configurations."
+  (let ( ;; Greeters found in seat-configurations.
+        (needed-greeters
+         (map (lambda (seat)
+                (lightdm-seat-configuration-greeter-session seat))
+              (lightdm-configuration-seats
+               (lightdm-aggregate-lightdm aggregate))))
+        ;; Greeter configurations defined by the user
+        (user-defined-greeters (lightdm-aggregate-greeters aggregate)))
+    (map
+     (lambda (greeter)
+       ;; If a greeter is used in a seat but not defined by the user
+       ;; get its default configuration object
+       (or (assoc-ref greeter user-defined-greeters)
+           (greeter-default-configuration greeter)))
+     needed-greeters)))
+
+;; Private service merging configuration of lightdm and its greeters
+(define lightdm-aggregate-service-type
+  (service-type
+   (name 'lightdm-aggregate)
+   (extensions
+    (list (service-extension etc-service-type
+                       (lambda (aggregate)
+                         (concatenate (map lightdm-greeter-etc-service
+                                           (lightdm-aggregate-greeters aggregate)))))
+    (service-extension profile-service-type
+                       (lambda (aggregate)
+                         (concatenate (map lightdm-greeter-profile-service
+                                           (lightdm-aggregate-greeters aggregate)))))
+    ;; LightDM Specifics (at leats for now)
+    (service-extension pam-root-service-type
+                       (compose lightdm-pam-services
+                                lightdm-aggregate-lightdm))
+    (service-extension shepherd-root-service-type
+                       (compose lightdm-shepherd-service
+                                lightdm-aggregate-lightdm))
+    (service-extension activation-service-type
+                       (const %lightdm-activation))
+    (service-extension dbus-root-service-type
+                       (compose list lightdm-configuration-lightdm
+                                lightdm-aggregate-lightdm))
+    (service-extension polkit-service-type
+                       (compose list lightdm-configuration-lightdm
+                                lightdm-aggregate-lightdm))
+    (service-extension account-service-type
+                       (const %lightdm-accounts))))
+   ;; Get lightdm-configuration from its service and pairs like
+   ;; ('greeter-symbol . greeter-configuration) from greeters
+   (compose (lambda (extensions)
+              (receive (lightdm-extension greeters-extensions)
+                  (partition lightdm-configuration? extensions)
+                (make-lightdm-aggregate
+                 (if (null? lightdm-extension) (lightdm-configuration) (car lightdm-extension))
+                 greeters-extensions))))
+   (extend (lambda (config extensions)
+             (let ((greeters (aggregate->greeters extensions)))
+               (make-lightdm-aggregate
+                ;; If there are no lightdm-service defined, use the default one.
+                ;; Also, add greeters' desktop directories to greeters-directories.
+                (augment-greeters-directories
+                 (lightdm-aggregate-lightdm extensions) greeters)
+                greeters))))
+   (default-value (lightdm-aggregate))
+   (description "Private service merging LightDM and LightDM's greeters
+services configurations and extending needed services.")))
+
+;; GREETERS
+
+(define lightdm-gtk-greeter-service-type
+  (service-type (name 'lightdm-gtk-greeter)
+                (extensions
+                 (list
+                  (service-extension lightdm-aggregate-service-type
+                                     (lambda (g) (cons 'lightdm-gtk-greeter g)))))
+                (default-value (lightdm-gtk-greeter-configuration))
+                (description
+                 "Set-up lightdm-gtk-greeter as well
+as its configuration file and extends LightDM with its seats.")))
+
+;; LightDM
+
+(define lightdm-service-type
+  (handle-xorg-configuration
+   lightdm-configuration
+   (service-type (name 'lightdm)
+                 (extensions
+                  (list
+                   (service-extension lightdm-aggregate-service-type
+                                      const)))
+                 (default-value (lightdm-configuration))
+                 (description "Return a service that spawns the
+ LightDM graphical login manager."))))
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [bug#35305] [WIP] LightDM service
  2020-05-06 14:05 ` L p R n d n
  2020-05-08 22:18   ` Ricardo Wurmus
@ 2022-08-04  2:19   ` Maxim Cournoyer
  1 sibling, 0 replies; 30+ messages in thread
From: Maxim Cournoyer @ 2022-08-04  2:19 UTC (permalink / raw)
  To: L p R n d n; +Cc: 35305

Hi,

> Hello,

> New set of patches with some modifications according to the feedbacks
> from rekado.

> One notable change is that all tests are now enabled for LightDM's
> package. The package builds but there might be some non deterministic
> tests failures sometimes (not necessarily those that have been re-enabled). 

> Have a nice day,

> L  p R n  d n

> [2. text/x-patch; 0001-gnu-lightdm-Update-1.30.0.patch]...

> [3. text/x-patch; 0002-gnu-lightdm-Add-vala-bindings.patch]...

> [4. text/x-patch; 0003-gnu-lightdm-gtk-greeter-Fix-at-spi-runtime-dependenc.patch]...

> [5. text/x-patch; 0004-gnu-lightdm-gtk-greeter-Fix-.desktop-file.patch]...

> [6. text/x-patch; 0005-gnu-lightdm-gtk-greeter-Wrap-binary.patch]...

> [7. text/x-patch; 0006-gnu-lightdm-Build-accountsservice-files.patch]...

> [8. text/x-patch; 0007-gnu-lightdm-gtk-greeter-Disable-indicator-services.patch]...

> [9. text/x-patch; 0008-services-Add-lightdm-service-type.patch]...

> [10. text/x-patch; 0009-gnu-lightdm-gtk-greeter-Set-XCURSOR_PATH-in-wrapper.patch]...

All the above changes except for the service have now been merged into
master.  I'll now look at the service various versions.

Thank you!

Maxim




^ permalink raw reply	[flat|nested] 30+ messages in thread

* [bug#35305] [WIP] LightDM service
  2020-06-08 15:35                 ` L p R n d n
@ 2022-08-04  5:09                   ` Maxim Cournoyer
  0 siblings, 0 replies; 30+ messages in thread
From: Maxim Cournoyer @ 2022-08-04  5:09 UTC (permalink / raw)
  To: L p R n d n; +Cc: Ricardo Wurmus, brice, 35305

Hi,

L  p R n  d n    <guix@lprndn.info> writes:

> Hello,
>
> I spent some time thinking about the lightdm service and what are our
> possibilities so here are my thoughts and conclusions.
>
> (Here, I'll only describe relations between seats, greeters and the lightdm
> service as it's our main source of problems)
>
> So if we get rid of the greeter's services, we can have:
>
> 1:
> (service lightd-service-type
>     (lightdm-configuration
>         (greeters
>             (list
>                 (lightdm-gtk-greeter-configuration
>                   (seats
>                       (list
>                           (lightdm-seat-configuration ...))))))))
>
> Here seats are defined by greeters. This way the user doesn't need to
> fill `greeter-session field as we can do it automatically. But there's a lot of nesting
> (and two lists.) + How do we define autologin?
>
> 2:
> (service lightd-service-type
>     (lightdm-configuration
>         (seats
>             (list
>                 (lightdm-seat-configuration
>                     (greeter-session
>                         (lightdm-gtk-greeter-configuration ...)))))))
>
> Defining greeters inside seats allows in the `greeter-session field make
> it a little simpler. However, we would get errors or conflicts if a user
> define two different configurations of the same greeter for two
> different seats. The thing is that we can only have one configuration
> per greeter as it will always look for a hardcoded file in /etc/ (worst
> case) or a file we hardcoded at build time (best case). :/
>
> 3:
> (service lightd-service-type
>     (lightdm-configuration
>         (seats
>             (list
>                 (lightdm-seat-configuration
>                     (greeter-session 'lightdm-gtk-greeter))))
>         (greeters
>             (list
>                 (lightdm-gtk-greeter-configuration
>                   )))))
>
> We can have separate fields for greeters and seats. The user will have
> to define `greeter-session by himself. And what happen if they define
> multiple occurences of one greeter's configuration?

After reading more about lightdm (and there's not much to read about
it... [0]), I can better understand your points above, and I find #3
perhaps the most natural.  The negative points (leaving place for user
errors) can be mitigated by a validating the configuration (e.g. that
all the configuration types listed in greeters are different).

I'll try to adjust your code to use the above layout when I get a
chance.

Thanks,

Maxim

[0]  https://wiki.ubuntu.com/LightDM




^ permalink raw reply	[flat|nested] 30+ messages in thread

* bug#35305: [WIP] LightDM service
  2019-04-17 14:24 [bug#35305] [WIP] LightDM service L p R n d n
                   ` (4 preceding siblings ...)
  2020-05-06 14:05 ` L p R n d n
@ 2022-08-31  7:13 ` Ricardo Wurmus
  5 siblings, 0 replies; 30+ messages in thread
From: Ricardo Wurmus @ 2022-08-31  7:13 UTC (permalink / raw)
  To: 35305-done

A variation of this has been pushed to the master branch with commit
0ea62e84a787fe94cfeadf67ef27ea995a382b84.

-- 
Ricardo




^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2022-08-31  7:16 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-17 14:24 [bug#35305] [WIP] LightDM service L p R n d n
2019-04-18 11:20 ` Jonathan Brielmaier
     [not found] ` <handler.35305.B.155550391014002.ack@debbugs.gnu.org>
2019-04-18 13:20   ` [bug#35305] Acknowledgement ([WIP] LightDM service) L p R n d n
2019-04-18 16:03     ` L p R n d n
2019-08-26 15:58   ` L p R n d n
2020-03-15 21:50     ` Nicolò Balzarotti
2020-03-16  7:34       ` Efraim Flashner
2020-03-16  8:36         ` L p R n d n
2020-03-19 11:54       ` [bug#35305] LightDM service L p R n d n
2019-05-23 11:04 ` [bug#35305] [PATCH] " L p R n d n
2020-04-07 17:06 ` [bug#35305] " Brice Waegeneire
2020-04-09 16:02   ` L p R n d n
2020-04-12  9:53     ` Brice Waegeneire
2020-04-14  9:38       ` L p R n d n
2020-04-14 13:17         ` L p R n d n
2020-04-22 15:26       ` L p R n d n
2020-05-06 14:05 ` L p R n d n
2020-05-08 22:18   ` Ricardo Wurmus
2020-05-09 15:09     ` L p R n d n
2020-05-10 19:21       ` Ricardo Wurmus
2020-05-11 10:14         ` L p R n d n
2020-05-12  9:59         ` L p R n d n
2020-05-20 20:51           ` Ricardo Wurmus
2020-05-21  8:28             ` L p R n d n
2020-05-21  9:23               ` Ricardo Wurmus
2020-06-08 15:35                 ` L p R n d n
2022-08-04  5:09                   ` [bug#35305] [WIP] " Maxim Cournoyer
2020-06-19 14:47                 ` [bug#35305] " L p R n d n
2022-08-04  2:19   ` [bug#35305] [WIP] " Maxim Cournoyer
2022-08-31  7:13 ` bug#35305: " Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).