Subject: [PATCH] gnu: Add lightdm-pantheon-greeter.

From: [email-masked]
Date: Mon, 30 Dec 2024 15:05:16 +0800

From: Feng Shu <[email-masked]>

* gnu/packages/display-managers.scm (lightdm-pantheon-greeter): New variable.

Change-Id: I31611965f4e09d083b1ab9fe39465c31fdb7d638
---
 gnu/packages/display-managers.scm | 77 +++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 16d0339701..1c337ad9c7 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -64,6 +64,7 @@ (define-module (gnu packages display-managers)
   #:use-module (gnu packages kde-frameworks)
   #:use-module (gnu packages libcanberra)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages pantheon)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages qt)
@@ -366,6 +367,82 @@ (define-public sugar-light-sddm-theme
 experience for your users, your family and yourself")
     (license license:gpl3+)))
 
+(define-public lightdm-pantheon-greeter
+  (package
+    (name "lightdm-pantheon-greeter")
+    ;; Versiton 8.0.0 can not build for mutter < 46 in guix, see:
+    ;; https://github.com/elementary/greeter/issues/778
+    (version "7.0.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/elementary/greeter")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1gz42852j50jk2apk16lxl34zw39knwy6fgkjyhqlgl0q1l6xz4v"))))
+    (build-system meson-build-system)
+    (arguments
+     (list
+      #:glib-or-gtk? #t
+      #:parallel-build? #f  ; Enable this option will build fail.
+      #:configure-flags
+      #~(list
+         ;; Put the binary under /bin rather than /sbin, so that it gets
+         ;; wrapped by the glib-or-gtk-wrap phase.
+         (string-append "--sbindir=" #$output "/bin"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'glib-or-gtk-wrap 'custom-wrap
+            (lambda _
+              (for-each (lambda (prog)
+                          (wrap-script (string-append #$output prog)
+                            ;; Wrap GDK_PIXBUF_MODULE_FILE, so that the SVG loader is
+                            ;; available at all times even outside of profiles, such as
+                            ;; when used in the lightdm-service-type.  Otherwise, it
+                            ;; wouldn't be able to display its own icons.
+                            `("GDK_PIXBUF_MODULE_FILE" =
+                              (,(string-append #$output "lib/gdk-pixbuf-2.0/2.10.0/loaders.cache")))
+                            `("XDG_DATA_DIRS" ":" prefix
+                              (,(string-append "/run/current-system/profile/share:"
+                                               (getenv "XDG_DATA_DIRS"))))
+                            '("XCURSOR_PATH" ":" prefix
+                              ("/run/current-system/profile/share/icons"))))
+                        '("/bin/io.elementary.greeter"
+                          "/bin/io.elementary.greeter-compositor"))))
+          (add-after 'install 'fix-.desktop-file
+            (lambda _
+              (substitute* (string-append #$output
+                                          "/share/xgreeters/io.elementary.greeter.desktop")
+                (("Exec=io.elementary.greeter")
+                 ;; NOTE: io.elementary.greeter-compositor do not work in guix
+                 ;; at the moment, for it use wayland.
+                 (string-append "Exec=" #$output "/bin/io.elementary.greeter"))))))))
+    (native-inputs
+     (list gettext-minimal
+           (list glib "bin")
+           pkg-config
+           vala))
+    (inputs
+     (list accountsservice
+           desktop-file-utils
+           glib
+           gnome-desktop
+           gnome-settings-daemon
+           granite-6
+           gtk+
+           guile-3.0
+           libhandy
+           libx11
+           lightdm
+           mutter))
+    (synopsis "A greeter from the elementary OS project")
+    (home-page "https://github.com/elementary/greeter")
+    (description "Login and Lock Screen greeter for elementary OS and
+Pantheon, using LightDM.")
+    (license license:gpl3)))
+
 (define-public lightdm
   (package
     (name "lightdm")
-- 
2.45.2