all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session.
@ 2022-09-10 20:29 ( via Guix-patches via
  2022-09-10 20:30 ` [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-10 20:29 UTC (permalink / raw)
  To: 57721; +Cc: (

Hey Guix!

This patchset adds support for a second greetd greeter: wlgreet. This
is my first time contributing additions to the documentation, so I
probably got something wrong there; corrections would be appreciated!

( (4):
  gnu: Add rust-greetd-ipc-0.8.
  gnu: Add rust-os-pipe-0.8.
  gnu: Add wlgreet.
  gnu: base: Add greetd-wlgreet-sway-session.

 doc/guix.texi              |  76 +++++++++++++++++++++++
 gnu/packages/admin.scm     |  71 +++++++++++++++++++++
 gnu/packages/crates-io.scm |  46 +++++++++++++-
 gnu/services/base.scm      | 122 +++++++++++++++++++++++++++++++++++++
 4 files changed, 314 insertions(+), 1 deletion(-)

-- 
2.37.3





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

* [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8.
  2022-09-10 20:29 [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
@ 2022-09-10 20:30 ` ( via Guix-patches via
  2022-09-10 20:30   ` [bug#57721] [PATCH 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
                     ` (2 more replies)
  2022-09-11  8:02 ` [bug#57721] [PATCH v2 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-10 20:30 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/packages/crates-io.scm (rust-greetd-ipc-0.8): New variable.
---
 gnu/packages/crates-io.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 02f7bc7d4d..c7b971ffc2 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -28,6 +28,7 @@
 ;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2022 Evgenii Lepikhin <e.lepikhin@corp.mail.ru>
 ;;; Copyright © 2022 Gabriel Arazas <foo.dogsquared@gmail.com>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26136,6 +26137,32 @@ (define-public rust-goblin-0.0
 loading crate.")
     (license license:expat)))
 
+(define-public rust-greetd-ipc-0.8
+  (package
+    (name "rust-greetd-ipc")
+    (version "0.8.0")
+    (source (origin
+              (method url-fetch)
+              (uri (crate-uri "greetd-ipc" version))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1dscriv3adjyaxfaax3cmqrzx6q2vwwchbh86dhll783wjc4ivw0"))))
+    (build-system cargo-build-system)
+    (arguments
+     (list #:cargo-inputs
+           `(("rust-async-trait" ,rust-async-trait-0.1)
+             ("rust-serde" ,rust-serde-1)
+             ("rust-serde-json" ,rust-serde-json-1)
+             ("rust-thiserror" ,rust-thiserror-1)
+             ("rust-tokio" ,rust-tokio-1))))
+    (home-page "https://kl.wtf/projects/greetd")
+    (synopsis "@command{greetd} IPC protocol library for Rust")
+    (description
+     "This package provides library that helps you use the
+@command{greetd} JSON-based IPC protocol from Rust.")
+    (license license:gpl3)))
+
 (define-public rust-grep-0.2
   (package
     (name "rust-grep")
-- 
2.37.3





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

* [bug#57721] [PATCH 2/4] gnu: Add rust-os-pipe-0.8.
  2022-09-10 20:30 ` [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
@ 2022-09-10 20:30   ` ( via Guix-patches via
  2022-09-10 20:30   ` [bug#57721] [PATCH 3/4] gnu: Add wlgreet ( via Guix-patches via
  2022-09-10 20:30   ` [bug#57721] [PATCH 4/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
  2 siblings, 0 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-10 20:30 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/packages/crates-io.scm (rust-os-pipe-0.8): New variable.
---
 gnu/packages/crates-io.scm | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index c7b971ffc2..f1a84e9d22 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -40800,10 +40800,27 @@ (define-public rust-os-pipe-0.9
          "04yjs1hf88jjm17g8a2lr7ibxyyg460rzbgcw9f1yzihq833y8zv"))))
     (native-inputs (list))))
 
-(define-public rust-os-pipe-0.5
+(define-public rust-os-pipe-0.8
   (package
     (inherit rust-os-pipe-0.9)
     (name "rust-os-pipe")
+    (version "0.8.2")
+    (source (origin
+              (method url-fetch)
+              (uri (crate-uri "os-pipe" version))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "049ax8shxik7mm68r2nf7xnrcq3z3p7hz54sbrcxwywxqsjdzs41"))))
+    (arguments
+     (list #:cargo-inputs
+           `(("rust-nix" ,rust-nix-0.15)
+             ("rust-winapi" ,rust-winapi-0.3))))))
+
+(define-public rust-os-pipe-0.5
+  (package
+    (inherit rust-os-pipe-0.8)
+    (name "rust-os-pipe")
     (version "0.5.1")
     (source
      (origin
-- 
2.37.3





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

* [bug#57721] [PATCH 3/4] gnu: Add wlgreet.
  2022-09-10 20:30 ` [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
  2022-09-10 20:30   ` [bug#57721] [PATCH 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
@ 2022-09-10 20:30   ` ( via Guix-patches via
  2022-09-10 20:30   ` [bug#57721] [PATCH 4/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
  2 siblings, 0 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-10 20:30 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/packages/admin.scm (wlgreet): New variable.
---
 gnu/packages/admin.scm | 71 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 21f9176bfa..bf76d3bd30 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -51,6 +51,7 @@
 ;;; Copyright © 2021 Artyom V. Poptsov <poptsov.artyom@gmail.com>
 ;;; Copyright © 2022 Wamm K. D. <jaft.r@outlook.com>
 ;;; Copyright © 2022 Roman Riabenko <roman@riabenko.com>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -97,6 +98,7 @@ (define-module (gnu packages admin)
   #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages crates-graphics)
   #:use-module (gnu packages crates-io)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages crypto)
@@ -107,6 +109,7 @@ (define-module (gnu packages admin)
   #:use-module (gnu packages elf)
   #:use-module (gnu packages file)
   #:use-module (gnu packages flex)
+  #:use-module (gnu packages fonts)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gettext)
@@ -5192,6 +5195,74 @@ (define-public greetd-pam-mount
 auto-(mounting/unmounting) of XDG_RUNTIME_DIR in the way that it will not
 interfere with default pam-mount configuration.")))
 
+(define-public wlgreet
+  (package
+    (name "wlgreet")
+    (version "0.4")
+    (source (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://git.sr.ht/~kennylevinsen/wlgreet")
+                   (commit version)))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "00grp63n9nrgqls3knxfv9wjbc7p0jwr7i2vzxy750dz85gi2kzn"))))
+    (build-system cargo-build-system)
+    (arguments
+     (list #:cargo-inputs
+           `(("rust-chrono" ,rust-chrono-0.4)
+             ("rust-getopts" ,rust-getopts-0.2)
+             ("rust-greetd-ipc" ,rust-greetd-ipc-0.8)
+             ("rust-lazy-static" ,rust-lazy-static-1)
+             ("rust-memmap2" ,rust-memmap2-0.3)
+             ("rust-nix" ,rust-nix-0.15)
+             ("rust-os-pipe" ,rust-os-pipe-0.8)
+             ("rust-rusttype" ,rust-rusttype-0.7)
+             ("rust-serde" ,rust-serde-1)
+             ("rust-smithay-client-toolkit"
+              ,rust-smithay-client-toolkit-0.15)
+             ("rust-toml" ,rust-toml-0.5)
+             ("rust-wayland-client" ,rust-wayland-client-0.29)
+             ("rust-wayland-protocols" ,rust-wayland-protocols-0.29)
+             ("rust-xml-rs" ,rust-xml-rs-0.8))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'remove-bundled-fonts
+                 (lambda _
+                   (delete-file-recursively "fonts")))
+               (add-after 'remove-bundled-fonts 'fix-font-references
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* "src/draw.rs"
+                     (("\\.\\./fonts/dejavu/DejaVuSansMono\\.ttf" _)
+                      (search-input-file
+                       inputs
+                       "share/fonts/truetype/DejaVuSansMono.ttf"))
+                     (("\\.\\./fonts/Roboto-Regular\\.ttf" _)
+                      (search-input-file
+                       inputs
+                       "share/fonts/truetype/Roboto-Regular.ttf")))))
+               (add-after 'configure 'fix-library-references
+                 (lambda* (#:key inputs vendor-dir #:allow-other-keys)
+                   (substitute* (find-files vendor-dir "\\.rs$")
+                     (("lib(wayland-.*|xkbcommon)\\.so" so-file)
+                      (search-input-file
+                       inputs
+                       (string-append "lib/" so-file)))))))))
+    (inputs
+     (list font-dejavu
+           font-google-roboto
+           libxkbcommon
+           wayland))
+    (home-page "https://git.sr.ht/~kennylevinsen/wlgreet")
+    (synopsis "Bare-bones Wayland-based greeter for @command{greetd}")
+    (description
+     "@command{wlgreet} provides a @command{greetd} greeter
+that runs on a Wayland compositor such as @command{sway}.  It
+is implemented with pure Wayland APIs, so it does not depend
+on a GUI toolkit.")
+    (license license:gpl3)))
+
 (define-public libseat
   (package
     (name "libseat")
-- 
2.37.3





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

* [bug#57721] [PATCH 4/4] gnu: base: Add greetd-wlgreet-sway-session.
  2022-09-10 20:30 ` [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
  2022-09-10 20:30   ` [bug#57721] [PATCH 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
  2022-09-10 20:30   ` [bug#57721] [PATCH 3/4] gnu: Add wlgreet ( via Guix-patches via
@ 2022-09-10 20:30   ` ( via Guix-patches via
  2 siblings, 0 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-10 20:30 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/services/base.scm (greetd-wlgreet-session): New data type.
(greetd-wlgreet-sway-session): Likewise.
* doc/guix.texi ("Base Services")[greetd-service-type]: Document
  them.
---
 doc/guix.texi         |  76 ++++++++++++++++++++++++++
 gnu/services/base.scm | 122 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 198 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index c21235f28d..cf66014d8e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -106,6 +106,7 @@ Copyright @copyright{} 2022 Philip M@sup{c}Grath@*
 Copyright @copyright{} 2022 Karl Hallsby@*
 Copyright @copyright{} 2022 Justin Veilleux@*
 Copyright @copyright{} 2022 Reily Siegel@*
+Copyright @copyright{} 2022 (@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -18633,6 +18634,81 @@ are set right after mentioned variables, so that they can be overriden.
 @end table
 @end deftp
 
+@deftp {Data Type} greetd-wlgreet-session
+Generic configuration record for the wlgreet greetd greeter.
+
+@table @asis
+@item @code{wlgreet} (default: @code{wlgreet})
+The package with the @command{/bin/wlgreet} command.
+
+@item @code{command} (default: @code{(file-append sway "/bin/sway")})
+Command to be started by @command{/bin/wlgreet} on successful login.
+
+@item @code{command-args} (default: @code{'()})
+Command arguments to pass to command.
+
+@item @code{output-mode} (default: @code{"all"})
+Option to use for @code{outputMode} in the TOML configuration file.
+
+@item @code{scale} (default: @code{1})
+Option to use for @code{scale} in the TOML configuration file.
+
+@item @code{background} (default: @code{(list 0 0 0 0.9)})
+RGBA list to use as the background colour of the login prompt.
+
+@item @code{headline} (default: @code{(list 1 1 1 1)})
+RGBA list to use as the headline colour of the UI popup.
+
+@item @code{prompt} (default: @code{(list 1 1 1 1)})
+RGBA list to use as the prompt colour of the UI popup.
+
+@item @code{prompt-error} (default: @code{(list 1 1 1 1)})
+RGBA list to use as the error colour of the UI popup.
+
+@item @code{border} (default: @code{(list 1 1 1 1)})
+RGBA list to use as the border colour of the UI popup.
+
+@item @code{extra-env} (default: @code{'()})
+Extra environment variables to set on login.
+
+@end table
+@end deftp
+
+@deftp {Data Type} greetd-wlgreet-sway-session
+Sway-specific configuration record for the wlgreet greetd greeter.
+
+@table
+@item @code{wlgreet-session} (default: @code{(greetd-wlgreet-session)})
+A @code{greetd-wlgreet-session} record for generic wlgreet configuration,
+on top of the Sway-specific @code{greetd-wlgreet-sway-session}.
+
+@item @code{sway} (default: @code{sway})
+The package providing the @command{/bin/sway} command.
+
+@item @code{sway-configuration} (default: #f)
+File-like object providing an additional Sway configuration file to be
+prepended to the mandatory part of the configuration.
+
+@end table
+
+Here is an example of a greetd configuration that uses wlgreet and Sway:
+
+@lisp
+  (greetd-configuration
+   ;; We need to give the greeter user these permissions, otherwise
+   ;; Sway will crash on launch.
+   (greeter-supplementary-groups (list "video" "input" "seat"))
+   (terminals
+    (list (greetd-terminal-configuration
+           (terminal-vt "1")
+           (terminal-switch #t)
+           (default-session-command
+            (greetd-wlgreet-sway-session
+             (sway-configuration
+              (local-file "sway-greetd.conf"))))))))
+@end lisp
+@end deftp
+
 @node Scheduled Job Execution
 @subsection Scheduled Job Execution
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 616bc42e69..5de4e0a51a 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2021 muradm <mail@muradm.net>
 ;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -66,6 +67,7 @@ (define-module (gnu services base)
   #:use-module ((gnu packages gnupg) #:select (guile-gcrypt))
   #:use-module (gnu packages linux)
   #:use-module (gnu packages terminals)
+  #:use-module ((gnu packages wm) #:select (sway))
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
                           swap-space->flags-bit-mask))
@@ -231,6 +233,8 @@ (define-module (gnu services base)
             greetd-configuration
             greetd-terminal-configuration
             greetd-agreety-session
+            greetd-wlgreet-session
+            greetd-wlgreet-sway-session
 
             %base-services))
 
@@ -2869,6 +2873,122 @@ (define (make-greetd-agreety-session-command config command)
      "agreety-command"
      #~(execl #$agreety #$agreety "-c" #$command))))
 
+(define-record-type* <greetd-wlgreet-session>
+  greetd-wlgreet-session make-greetd-wlgreet-session
+  greetd-wlgreet-session?
+  (wlgreet greetd-wlgreet (default wlgreet))
+  (command greetd-wlgreet-command
+           (default (file-append sway "/bin/sway")))
+  (command-args greetd-wlgreet-command-args (default #~(list)))
+  (output-mode greetd-wlgreet-output-mode (default "all"))
+  (scale greetd-wlgreet-scale (default 1))
+  (background greetd-wlgreet-background (default (list 0 0 0 0.9)))
+  (headline greetd-wlgreet-headline (default (list 1 1 1 1)))
+  (prompt greetd-wlgreet-prompt (default (list 1 1 1 1)))
+  (prompt-error greetd-wlgreet-prompt-error (default (list 1 1 1 1)))
+  (border greetd-wlgreet-border (default (list 1 1 1 1)))
+  (extra-env greetd-wlgreet-extra-env (default #~(list))))
+
+(define (greetd-wlgreet-wayland-session-command session)
+  (program-file "wlgreet-session-command"
+    #~(let* ((username (getenv "USER"))
+             (useruid (number->string
+                       (passwd:uid (getpwuid username))))
+             (command #$(greetd-wlgreet-command session)))
+        (use-modules
+         (ice-9 format)
+         (ice-9 match))
+        (setenv "XDG_SESSION_TYPE" "wayland")
+        (setenv "XDG_RUNTIME_DIR"
+                (string-append "/run/user/" useruid))
+        (for-each (match-lambda
+                    ((var . val)
+                     (setenv var val)))
+                  #$(greetd-wlgreet-extra-env session))
+        (apply execl command command
+               #$(greetd-wlgreet-command-args session)))))
+
+(define (make-wlgreet-config-color section-name color)
+  (match color
+    ((red green blue opacity)
+     (string-append
+      "[" section-name "]\n"
+      "red = " (number->string red) "\n"
+      "green = " (number->string green) "\n"
+      "blue = " (number->string blue) "\n"
+      "opacity = " (number->string opacity) "\n"))))
+
+(define (make-wlgreet-configuration-file session)
+  (let ((command (greetd-wlgreet-wayland-session-command session))
+        (output-mode (greetd-wlgreet-output-mode session))
+        (scale (greetd-wlgreet-scale session))
+        (background (greetd-wlgreet-background session))
+        (headline (greetd-wlgreet-headline session))
+        (prompt (greetd-wlgreet-prompt session))
+        (prompt-error (greetd-wlgreet-prompt-error session))
+        (border (greetd-wlgreet-border session)))
+    (mixed-text-file "wlgreet.toml"
+      "command = \"" command "\"\n"
+      "outputMode = \"" output-mode "\"\n"
+      "scale = " (number->string scale) "\n"
+      (apply string-append
+             (map (match-lambda
+                    ((section-name . color)
+                     (make-wlgreet-config-color section-name color)))
+                  `(("background" . ,background)
+                    ("headline" . ,headline)
+                    ("prompt" . ,prompt)
+                    ("prompt-error" . ,prompt-error)
+                    ("border" . ,border)))))))
+
+(define-record-type* <greetd-wlgreet-sway-session>
+  greetd-wlgreet-sway-session make-greetd-wlgreet-sway-session
+  greetd-wlgreet-sway-session?
+  (wlgreet-session greetd-wlgreet-sway-session-wlgreet-session ;<greetd-wlgreet-session
+                   (default (greetd-wlgreet-session)))
+  (sway greetd-wlgreet-sway-session-sway (default sway)) ;<package>
+  (sway-configuration greetd-wlgreet-sway-session-sway-configuration ;file-like
+                      (default #f)))
+
+(define (make-wlgreet-sway-configuration-file session)
+  (let* ((wlgreet-session (greetd-wlgreet-sway-session-wlgreet-session session))
+         (wlgreet-config (make-wlgreet-configuration-file wlgreet-session))
+         (wlgreet (file-append (greetd-wlgreet wlgreet-session) "/bin/wlgreet"))
+         (sway-config (greetd-wlgreet-sway-session-sway-configuration session))
+         (swaymsg (file-append (greetd-wlgreet-sway-session-sway session)
+                               "/bin/swaymsg")))
+    (mixed-text-file "wlgreet-sway.conf"
+       (if sway-config
+           #~(string-append "include " #$sway-config "\n")
+           "")
+      "xwayland disable\n"
+      "exec \"" wlgreet " --config " wlgreet-config "; "
+      swaymsg " exit\"\n")))
+
+(define (greetd-wlgreet-sway-session-command session)
+  (program-file "wlgreet-sway-session-command"
+    #~(let* ((sway #$(file-append (greetd-wlgreet-sway-session-sway session)
+                                  "/bin/sway"))
+             (config #$(make-wlgreet-sway-configuration-file session))
+             (log-file (open-output-file
+                        (string-append "/tmp/sway-greeter."
+                                       (number->string (getpid))
+                                       ".log")))
+             (username (getenv "USER"))
+             (useruid (number->string (passwd:uid (getpwuid username)))))
+
+        ;; redirect stdout/err to log-file
+        (dup2 (fileno log-file) 1)
+        (dup2 1 2)
+
+        ;; XXX: If we start sway immediately, it won't find seatd for some
+        ;; reason...
+        (sleep 1)
+
+        (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid))
+        (execl sway sway "-d" "-c" config))))
+
+
 (define (make-greetd-default-session-command config-or-command)
   (cond ((greetd-agreety-session? config-or-command)
          (cond ((greetd-agreety-xdg-env? config-or-command)
@@ -2879,6 +2999,8 @@ (define (make-greetd-default-session-command config-or-command)
                 (make-greetd-agreety-session-command
                  config-or-command
                  (greetd-agreety-tty-session-command config-or-command)))))
+        ((greetd-wlgreet-sway-session? config-or-command)
+         (greetd-wlgreet-sway-session-command config-or-command))
         (#t config-or-command)))
 
 (define-record-type* <greetd-terminal-configuration>
-- 
2.37.3





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

* [bug#57721] [PATCH v2 1/4] gnu: Add rust-greetd-ipc-0.8.
  2022-09-10 20:29 [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
  2022-09-10 20:30 ` [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
@ 2022-09-11  8:02 ` ( via Guix-patches via
  2022-09-11  8:02   ` [bug#57721] [PATCH v2 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
                     ` (2 more replies)
  2022-10-06 14:13 ` [bug#57721] [PATCH 0/4] " Christopher Baines
  2022-10-09 18:16 ` [bug#57721] [PATCH v3] " ( via Guix-patches via
  3 siblings, 3 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-11  8:02 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/packages/crates-io.scm (rust-greetd-ipc-0.8): New variable.
---
 gnu/packages/crates-io.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index 02f7bc7d4d..c7b971ffc2 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -28,6 +28,7 @@
 ;;; Copyright © 2022 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2022 Evgenii Lepikhin <e.lepikhin@corp.mail.ru>
 ;;; Copyright © 2022 Gabriel Arazas <foo.dogsquared@gmail.com>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26136,6 +26137,32 @@ (define-public rust-goblin-0.0
 loading crate.")
     (license license:expat)))
 
+(define-public rust-greetd-ipc-0.8
+  (package
+    (name "rust-greetd-ipc")
+    (version "0.8.0")
+    (source (origin
+              (method url-fetch)
+              (uri (crate-uri "greetd-ipc" version))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1dscriv3adjyaxfaax3cmqrzx6q2vwwchbh86dhll783wjc4ivw0"))))
+    (build-system cargo-build-system)
+    (arguments
+     (list #:cargo-inputs
+           `(("rust-async-trait" ,rust-async-trait-0.1)
+             ("rust-serde" ,rust-serde-1)
+             ("rust-serde-json" ,rust-serde-json-1)
+             ("rust-thiserror" ,rust-thiserror-1)
+             ("rust-tokio" ,rust-tokio-1))))
+    (home-page "https://kl.wtf/projects/greetd")
+    (synopsis "@command{greetd} IPC protocol library for Rust")
+    (description
+     "This package provides library that helps you use the
+@command{greetd} JSON-based IPC protocol from Rust.")
+    (license license:gpl3)))
+
 (define-public rust-grep-0.2
   (package
     (name "rust-grep")
-- 
2.37.3





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

* [bug#57721] [PATCH v2 2/4] gnu: Add rust-os-pipe-0.8.
  2022-09-11  8:02 ` [bug#57721] [PATCH v2 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
@ 2022-09-11  8:02   ` ( via Guix-patches via
  2022-09-11  8:02   ` [bug#57721] [PATCH v2 3/4] gnu: Add wlgreet ( via Guix-patches via
  2022-09-11  8:02   ` [bug#57721] [PATCH v2 4/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
  2 siblings, 0 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-11  8:02 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/packages/crates-io.scm (rust-os-pipe-0.8): New variable.
---
 gnu/packages/crates-io.scm | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index c7b971ffc2..f1a84e9d22 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -40800,10 +40800,27 @@ (define-public rust-os-pipe-0.9
          "04yjs1hf88jjm17g8a2lr7ibxyyg460rzbgcw9f1yzihq833y8zv"))))
     (native-inputs (list))))
 
-(define-public rust-os-pipe-0.5
+(define-public rust-os-pipe-0.8
   (package
     (inherit rust-os-pipe-0.9)
     (name "rust-os-pipe")
+    (version "0.8.2")
+    (source (origin
+              (method url-fetch)
+              (uri (crate-uri "os-pipe" version))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "049ax8shxik7mm68r2nf7xnrcq3z3p7hz54sbrcxwywxqsjdzs41"))))
+    (arguments
+     (list #:cargo-inputs
+           `(("rust-nix" ,rust-nix-0.15)
+             ("rust-winapi" ,rust-winapi-0.3))))))
+
+(define-public rust-os-pipe-0.5
+  (package
+    (inherit rust-os-pipe-0.8)
+    (name "rust-os-pipe")
     (version "0.5.1")
     (source
      (origin
-- 
2.37.3





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

* [bug#57721] [PATCH v2 3/4] gnu: Add wlgreet.
  2022-09-11  8:02 ` [bug#57721] [PATCH v2 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
  2022-09-11  8:02   ` [bug#57721] [PATCH v2 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
@ 2022-09-11  8:02   ` ( via Guix-patches via
  2022-09-11  8:02   ` [bug#57721] [PATCH v2 4/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
  2 siblings, 0 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-11  8:02 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/packages/admin.scm (wlgreet): New variable.
---
 gnu/packages/admin.scm | 71 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 21f9176bfa..bf76d3bd30 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -51,6 +51,7 @@
 ;;; Copyright © 2021 Artyom V. Poptsov <poptsov.artyom@gmail.com>
 ;;; Copyright © 2022 Wamm K. D. <jaft.r@outlook.com>
 ;;; Copyright © 2022 Roman Riabenko <roman@riabenko.com>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -97,6 +98,7 @@ (define-module (gnu packages admin)
   #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages crates-graphics)
   #:use-module (gnu packages crates-io)
   #:use-module (gnu packages cross-base)
   #:use-module (gnu packages crypto)
@@ -107,6 +109,7 @@ (define-module (gnu packages admin)
   #:use-module (gnu packages elf)
   #:use-module (gnu packages file)
   #:use-module (gnu packages flex)
+  #:use-module (gnu packages fonts)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gettext)
@@ -5192,6 +5195,74 @@ (define-public greetd-pam-mount
 auto-(mounting/unmounting) of XDG_RUNTIME_DIR in the way that it will not
 interfere with default pam-mount configuration.")))
 
+(define-public wlgreet
+  (package
+    (name "wlgreet")
+    (version "0.4")
+    (source (origin
+             (method git-fetch)
+             (uri (git-reference
+                   (url "https://git.sr.ht/~kennylevinsen/wlgreet")
+                   (commit version)))
+             (file-name (git-file-name name version))
+             (sha256
+              (base32
+               "00grp63n9nrgqls3knxfv9wjbc7p0jwr7i2vzxy750dz85gi2kzn"))))
+    (build-system cargo-build-system)
+    (arguments
+     (list #:cargo-inputs
+           `(("rust-chrono" ,rust-chrono-0.4)
+             ("rust-getopts" ,rust-getopts-0.2)
+             ("rust-greetd-ipc" ,rust-greetd-ipc-0.8)
+             ("rust-lazy-static" ,rust-lazy-static-1)
+             ("rust-memmap2" ,rust-memmap2-0.3)
+             ("rust-nix" ,rust-nix-0.15)
+             ("rust-os-pipe" ,rust-os-pipe-0.8)
+             ("rust-rusttype" ,rust-rusttype-0.7)
+             ("rust-serde" ,rust-serde-1)
+             ("rust-smithay-client-toolkit"
+              ,rust-smithay-client-toolkit-0.15)
+             ("rust-toml" ,rust-toml-0.5)
+             ("rust-wayland-client" ,rust-wayland-client-0.29)
+             ("rust-wayland-protocols" ,rust-wayland-protocols-0.29)
+             ("rust-xml-rs" ,rust-xml-rs-0.8))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'remove-bundled-fonts
+                 (lambda _
+                   (delete-file-recursively "fonts")))
+               (add-after 'remove-bundled-fonts 'fix-font-references
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* "src/draw.rs"
+                     (("\\.\\./fonts/dejavu/DejaVuSansMono\\.ttf" _)
+                      (search-input-file
+                       inputs
+                       "share/fonts/truetype/DejaVuSansMono.ttf"))
+                     (("\\.\\./fonts/Roboto-Regular\\.ttf" _)
+                      (search-input-file
+                       inputs
+                       "share/fonts/truetype/Roboto-Regular.ttf")))))
+               (add-after 'configure 'fix-library-references
+                 (lambda* (#:key inputs vendor-dir #:allow-other-keys)
+                   (substitute* (find-files vendor-dir "\\.rs$")
+                     (("lib(wayland-.*|xkbcommon)\\.so" so-file)
+                      (search-input-file
+                       inputs
+                       (string-append "lib/" so-file)))))))))
+    (inputs
+     (list font-dejavu
+           font-google-roboto
+           libxkbcommon
+           wayland))
+    (home-page "https://git.sr.ht/~kennylevinsen/wlgreet")
+    (synopsis "Bare-bones Wayland-based greeter for @command{greetd}")
+    (description
+     "@command{wlgreet} provides a @command{greetd} greeter
+that runs on a Wayland compositor such as @command{sway}.  It
+is implemented with pure Wayland APIs, so it does not depend
+on a GUI toolkit.")
+    (license license:gpl3)))
+
 (define-public libseat
   (package
     (name "libseat")
-- 
2.37.3





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

* [bug#57721] [PATCH v2 4/4] gnu: base: Add greetd-wlgreet-sway-session.
  2022-09-11  8:02 ` [bug#57721] [PATCH v2 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
  2022-09-11  8:02   ` [bug#57721] [PATCH v2 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
  2022-09-11  8:02   ` [bug#57721] [PATCH v2 3/4] gnu: Add wlgreet ( via Guix-patches via
@ 2022-09-11  8:02   ` ( via Guix-patches via
  2 siblings, 0 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-09-11  8:02 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/services/base.scm (greetd-wlgreet-session): New data type.
(greetd-wlgreet-sway-session): Likewise.
* doc/guix.texi ("Base Services")[greetd-service-type]: Document
  them.
---
 doc/guix.texi         |  76 +++++++++++++++++++++++++++
 gnu/services/base.scm | 117 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 193 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index c21235f28d..0203685f82 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -106,6 +106,7 @@ Copyright @copyright{} 2022 Philip M@sup{c}Grath@*
 Copyright @copyright{} 2022 Karl Hallsby@*
 Copyright @copyright{} 2022 Justin Veilleux@*
 Copyright @copyright{} 2022 Reily Siegel@*
+Copyright @copyright{} 2022 (@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -18633,6 +18634,81 @@ are set right after mentioned variables, so that they can be overriden.
 @end table
 @end deftp
 
+@deftp {Data Type} greetd-wlgreet-session
+Generic configuration record for the wlgreet greetd greeter.
+
+@table @asis
+@item @code{wlgreet} (default: @code{wlgreet})
+The package with the @command{/bin/wlgreet} command.
+
+@item @code{command} (default: @code{(file-append sway "/bin/sway")})
+Command to be started by @command{/bin/wlgreet} on successful login.
+
+@item @code{command-args} (default: @code{'()})
+Command arguments to pass to command.
+
+@item @code{output-mode} (default: @code{"all"})
+Option to use for @code{outputMode} in the TOML configuration file.
+
+@item @code{scale} (default: @code{1})
+Option to use for @code{scale} in the TOML configuration file.
+
+@item @code{background} (default: @code{'(0 0 0 0.9)})
+RGBA list to use as the background colour of the login prompt.
+
+@item @code{headline} (default: @code{'(1 1 1 1)})
+RGBA list to use as the headline colour of the UI popup.
+
+@item @code{prompt} (default: @code{'(1 1 1 1)})
+RGBA list to use as the prompt colour of the UI popup.
+
+@item @code{prompt-error} (default: @code{'(1 1 1 1)})
+RGBA list to use as the error colour of the UI popup.
+
+@item @code{border} (default: @code{'(1 1 1 1)})
+RGBA list to use as the border colour of the UI popup.
+
+@item @code{extra-env} (default: @code{'()})
+Extra environment variables to set on login.
+
+@end table
+@end deftp
+
+@deftp {Data Type} greetd-wlgreet-sway-session
+Sway-specific configuration record for the wlgreet greetd greeter.
+
+@table @asis
+@item @code{wlgreet-session} (default: @code{(greetd-wlgreet-session)})
+A @code{greetd-wlgreet-session} record for generic wlgreet configuration,
+on top of the Sway-specific @code{greetd-wlgreet-sway-session}.
+
+@item @code{sway} (default: @code{sway})
+The package providing the @command{/bin/sway} command.
+
+@item @code{sway-configuration} (default: #f)
+File-like object providing an additional Sway configuration file to be
+prepended to the mandatory part of the configuration.
+
+@end table
+
+Here is an example of a greetd configuration that uses wlgreet and Sway:
+
+@lisp
+  (greetd-configuration
+   ;; We need to give the greeter user these permissions, otherwise
+   ;; Sway will crash on launch.
+   (greeter-supplementary-groups (list "video" "input" "seat"))
+   (terminals
+    (list (greetd-terminal-configuration
+           (terminal-vt "1")
+           (terminal-switch #t)
+           (default-session-command
+            (greetd-wlgreet-sway-session
+             (sway-configuration
+              (local-file "sway-greetd.conf"))))))))
+@end lisp
+@end deftp
+
 @node Scheduled Job Execution
 @subsection Scheduled Job Execution
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 616bc42e69..16c4b1f533 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2021 muradm <mail@muradm.net>
 ;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -66,6 +67,7 @@ (define-module (gnu services base)
   #:use-module ((gnu packages gnupg) #:select (guile-gcrypt))
   #:use-module (gnu packages linux)
   #:use-module (gnu packages terminals)
+  #:use-module ((gnu packages wm) #:select (sway))
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
                           swap-space->flags-bit-mask))
@@ -231,6 +233,8 @@ (define-module (gnu services base)
             greetd-configuration
             greetd-terminal-configuration
             greetd-agreety-session
+            greetd-wlgreet-session
+            greetd-wlgreet-sway-session
 
             %base-services))
 
@@ -2869,6 +2873,117 @@ (define (make-greetd-agreety-session-command config command)
      "agreety-command"
      #~(execl #$agreety #$agreety "-c" #$command))))
 
+(define-record-type* <greetd-wlgreet-session>
+  greetd-wlgreet-session make-greetd-wlgreet-session
+  greetd-wlgreet-session?
+  (wlgreet greetd-wlgreet (default wlgreet))
+  (command greetd-wlgreet-command
+           (default (file-append sway "/bin/sway")))
+  (command-args greetd-wlgreet-command-args (default '()))
+  (output-mode greetd-wlgreet-output-mode (default "all"))
+  (scale greetd-wlgreet-scale (default 1))
+  (background greetd-wlgreet-background (default '(0 0 0 0.9)))
+  (headline greetd-wlgreet-headline (default '(1 1 1 1)))
+  (prompt greetd-wlgreet-prompt (default '(1 1 1 1)))
+  (prompt-error greetd-wlgreet-prompt-error (default '(1 1 1 1)))
+  (border greetd-wlgreet-border (default '(1 1 1 1)))
+  (extra-env greetd-wlgreet-extra-env (default '())))
+
+(define (greetd-wlgreet-wayland-session-command session)
+  (program-file "wlgreet-session-command"
+    #~(let* ((username (getenv "USER"))
+             (useruid (number->string
+                       (passwd:uid (getpwuid username))))
+             (command #$(greetd-wlgreet-command session)))
+        (use-modules (ice-9 match))
+        (setenv "XDG_SESSION_TYPE" "wayland")
+        (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid))
+        (for-each (lambda (env) (setenv (car env) (cdr env)))
+                  '(#$@(greetd-wlgreet-extra-env session)))
+        (apply execl command command
+               (list #$@(greetd-wlgreet-command-args session))))))
+
+(define (make-wlgreet-config-color section-name color)
+  (match color
+    ((red green blue opacity)
+     (string-append
+      "[" section-name "]\n"
+      "red = " (number->string red) "\n"
+      "green = " (number->string green) "\n"
+      "blue = " (number->string blue) "\n"
+      "opacity = " (number->string opacity) "\n"))))
+
+(define (make-wlgreet-configuration-file session)
+  (let ((command (greetd-wlgreet-wayland-session-command session))
+        (output-mode (greetd-wlgreet-output-mode session))
+        (scale (greetd-wlgreet-scale session))
+        (background (greetd-wlgreet-background session))
+        (headline (greetd-wlgreet-headline session))
+        (prompt (greetd-wlgreet-prompt session))
+        (prompt-error (greetd-wlgreet-prompt-error session))
+        (border (greetd-wlgreet-border session)))
+    (mixed-text-file "wlgreet.toml"
+      "command = \"" command "\"\n"
+      "outputMode = \"" output-mode "\"\n"
+      "scale = " (number->string scale) "\n"
+      (apply string-append
+             (map (match-lambda
+                    ((section-name . color)
+                     (make-wlgreet-config-color section-name color)))
+                  `(("background" . ,background)
+                    ("headline" . ,headline)
+                    ("prompt" . ,prompt)
+                    ("prompt-error" . ,prompt-error)
+                    ("border" . ,border)))))))
+
+(define-record-type* <greetd-wlgreet-sway-session>
+  greetd-wlgreet-sway-session make-greetd-wlgreet-sway-session
+  greetd-wlgreet-sway-session?
+  (wlgreet-session greetd-wlgreet-sway-session-wlgreet-session ;<greetd-wlgreet-session
+                   (default (greetd-wlgreet-session)))
+  (sway greetd-wlgreet-sway-session-sway (default sway)) ;<package>
+  (sway-configuration greetd-wlgreet-sway-session-sway-configuration ;file-like
+                      (default #f)))
+
+(define (make-wlgreet-sway-configuration-file session)
+  (let* ((wlgreet-session (greetd-wlgreet-sway-session-wlgreet-session session))
+         (wlgreet-config (make-wlgreet-configuration-file wlgreet-session))
+         (wlgreet (file-append (greetd-wlgreet wlgreet-session) "/bin/wlgreet"))
+         (sway-config (greetd-wlgreet-sway-session-sway-configuration session))
+         (swaymsg (file-append (greetd-wlgreet-sway-session-sway session)
+                               "/bin/swaymsg")))
+    (mixed-text-file "wlgreet-sway.conf"
+       (if sway-config
+           #~(string-append "include " #$sway-config "\n")
+           "")
+      "xwayland disable\n"
+      "exec \"" wlgreet " --config " wlgreet-config "; "
+      swaymsg " exit\"\n")))
+
+(define (greetd-wlgreet-sway-session-command session)
+  (program-file "wlgreet-sway-session-command"
+    #~(let* ((sway #$(file-append (greetd-wlgreet-sway-session-sway session)
+                                  "/bin/sway"))
+             (config #$(make-wlgreet-sway-configuration-file session))
+             (log-file (open-output-file
+                        (string-append "/tmp/sway-greeter."
+                                       (number->string (getpid))
+                                       ".log")))
+             (username (getenv "USER"))
+             (useruid (number->string (passwd:uid (getpwuid username)))))
+
+        ;; redirect stdout/err to log-file
+        (dup2 (fileno log-file) 1)
+        (dup2 1 2)
+
+        ;; XXX: If we start sway immediately, it won't find seatd for some
+        ;; reason...
+        (sleep 1)
+
+        (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid))
+        (execl sway sway "-d" "-c" config))))
+
+
 (define (make-greetd-default-session-command config-or-command)
   (cond ((greetd-agreety-session? config-or-command)
          (cond ((greetd-agreety-xdg-env? config-or-command)
@@ -2879,6 +2994,8 @@ (define (make-greetd-default-session-command config-or-command)
                 (make-greetd-agreety-session-command
                  config-or-command
                  (greetd-agreety-tty-session-command config-or-command)))))
+        ((greetd-wlgreet-sway-session? config-or-command)
+         (greetd-wlgreet-sway-session-command config-or-command))
         (#t config-or-command)))
 
 (define-record-type* <greetd-terminal-configuration>
-- 
2.37.3





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

* [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session.
  2022-09-10 20:29 [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
  2022-09-10 20:30 ` [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
  2022-09-11  8:02 ` [bug#57721] [PATCH v2 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
@ 2022-10-06 14:13 ` Christopher Baines
  2022-10-06 18:21   ` ( via Guix-patches via
  2022-10-09 18:16 ` [bug#57721] [PATCH v3] " ( via Guix-patches via
  3 siblings, 1 reply; 13+ messages in thread
From: Christopher Baines @ 2022-10-06 14:13 UTC (permalink / raw)
  To: (; +Cc: 57721

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


"( via Guix-patches" via <guix-patches@gnu.org> writes:

> This patchset adds support for a second greetd greeter: wlgreet. This
> is my first time contributing additions to the documentation, so I
> probably got something wrong there; corrections would be appreciated!
>
> ( (4):
>   gnu: Add rust-greetd-ipc-0.8.
>   gnu: Add rust-os-pipe-0.8.
>   gnu: Add wlgreet.
>   gnu: base: Add greetd-wlgreet-sway-session.
>
>  doc/guix.texi              |  76 +++++++++++++++++++++++
>  gnu/packages/admin.scm     |  71 +++++++++++++++++++++
>  gnu/packages/crates-io.scm |  46 +++++++++++++-
>  gnu/services/base.scm      | 122 +++++++++++++++++++++++++++++++++++++
>  4 files changed, 314 insertions(+), 1 deletion(-)

Sorry for the delay in looking at this, I've gone ahead and pushed the
new packages now.

As for the service, it would be good to have a system test doing
something with it, I don't know how feasible it is?

I'm happy to merge it though if it works. I haven't tested it, but if
someone could that would be useful. If that doesn't happen though, I'm
happy to merge it anyway.

If you could send the remaining patch again (to the same issue), that
would be useful too.

Thanks,

Chris

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

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

* [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session.
  2022-10-06 14:13 ` [bug#57721] [PATCH 0/4] " Christopher Baines
@ 2022-10-06 18:21   ` ( via Guix-patches via
  2022-10-11 11:08     ` bug#57721: " Christopher Baines
  0 siblings, 1 reply; 13+ messages in thread
From: ( via Guix-patches via @ 2022-10-06 18:21 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 57721

Hi Christopher,

On Thu Oct 6, 2022 at 3:13 PM BST, Christopher Baines wrote:
> Sorry for the delay in looking at this, I've gone ahead and pushed the
> new packages now.

Thanks! :D

> As for the service, it would be good to have a system test doing
> something with it, I don't know how feasible it is?

I have no idea either, but I suspect it's not feasible, since greetd
itself doesn't have any system tests.

> I'm happy to merge it though if it works. I haven't tested it, but if
> someone could that would be useful. If that doesn't happen though, I'm
> happy to merge it anyway.

It works, I've tested it and have been using it for a while.

> If you could send the remaining patch again (to the same issue), that
> would be useful too.

Okay, I've rebased it on the latest master and will send it independently.

    -- (




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

* [bug#57721] [PATCH v3] gnu: base: Add greetd-wlgreet-sway-session.
  2022-09-10 20:29 [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
                   ` (2 preceding siblings ...)
  2022-10-06 14:13 ` [bug#57721] [PATCH 0/4] " Christopher Baines
@ 2022-10-09 18:16 ` ( via Guix-patches via
  3 siblings, 0 replies; 13+ messages in thread
From: ( via Guix-patches via @ 2022-10-09 18:16 UTC (permalink / raw)
  To: 57721; +Cc: (

* gnu/services/base.scm (greetd-wlgreet-session): New data type.
(greetd-wlgreet-sway-session): Likewise.
* doc/guix.texi ("Base Services")[greetd-service-type]: Document
  them.
---
 doc/guix.texi         |  75 +++++++++++++++++++++++++++++
 gnu/services/base.scm | 109 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 14592142dd..d5cffc8905 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18681,6 +18681,81 @@ are set right after mentioned variables, so that they can be overriden.
 @end table
 @end deftp
 
+@deftp {Data Type} greetd-wlgreet-session
+Generic configuration record for the wlgreet greetd greeter.
+
+@table @asis
+@item @code{wlgreet} (default: @code{wlgreet})
+The package with the @command{/bin/wlgreet} command.
+
+@item @code{command} (default: @code{(file-append sway "/bin/sway")})
+Command to be started by @command{/bin/wlgreet} on successful login.
+
+@item @code{command-args} (default: @code{'()})
+Command arguments to pass to command.
+
+@item @code{output-mode} (default: @code{"all"})
+Option to use for @code{outputMode} in the TOML configuration file.
+
+@item @code{scale} (default: @code{1})
+Option to use for @code{scale} in the TOML configuration file.
+
+@item @code{background} (default: @code{'(0 0 0 0.9)})
+RGBA list to use as the background colour of the login prompt.
+
+@item @code{headline} (default: @code{'(1 1 1 1)})
+RGBA list to use as the headline colour of the UI popup.
+
+@item @code{prompt} (default: @code{'(1 1 1 1)})
+RGBA list to use as the prompt colour of the UI popup.
+
+@item @code{prompt-error} (default: @code{'(1 1 1 1)})
+RGBA list to use as the error colour of the UI popup.
+
+@item @code{border} (default: @code{'(1 1 1 1)})
+RGBA list to use as the border colour of the UI popup.
+
+@item @code{extra-env} (default: @code{'()})
+Extra environment variables to set on login.
+
+@end table
+@end deftp
+
+@deftp {Data Type} greetd-wlgreet-sway-session
+Sway-specific configuration record for the wlgreet greetd greeter.
+
+@table @asis
+@item @code{wlgreet-session} (default: @code{(greetd-wlgreet-session)})
+A @code{greetd-wlgreet-session} record for generic wlgreet configuration,
+on top of the Sway-specific @code{greetd-wlgreet-sway-session}.
+
+@item @code{sway} (default: @code{sway})
+The package providing the @command{/bin/sway} command.
+
+@item @code{sway-configuration} (default: #f)
+File-like object providing an additional Sway configuration file to be
+prepended to the mandatory part of the configuration.
+
+@end table
+
+Here is an example of a greetd configuration that uses wlgreet and Sway:
+
+@lisp
+  (greetd-configuration
+   ;; We need to give the greeter user these permissions, otherwise
+   ;; Sway will crash on launch.
+   (greeter-supplementary-groups (list "video" "input" "seat"))
+   (terminals
+    (list (greetd-terminal-configuration
+           (terminal-vt "1")
+           (terminal-switch #t)
+           (default-session-command
+            (greetd-wlgreet-sway-session
+             (sway-configuration
+              (local-file "sway-greetd.conf"))))))))
+@end lisp
+@end deftp
+
 @node Scheduled Job Execution
 @subsection Scheduled Job Execution
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 3f662f1a6c..d3e3335030 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2021 muradm <mail@muradm.net>
 ;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
+;;; Copyright © 2022 ( <paren@disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -71,6 +72,7 @@ (define-module (gnu services base)
   #:use-module ((gnu packages file-systems)
                 #:select (bcachefs-tools exfat-utils jfsutils zfs))
   #:use-module (gnu packages terminals)
+  #:use-module ((gnu packages wm) #:select (sway))
   #:use-module ((gnu build file-systems)
                 #:select (mount-flags->bit-mask
                           swap-space->flags-bit-mask))
@@ -237,6 +239,8 @@ (define-module (gnu services base)
             greetd-configuration
             greetd-terminal-configuration
             greetd-agreety-session
+            greetd-wlgreet-session
+            greetd-wlgreet-sway-session
 
             %base-services))
 
@@ -2902,6 +2906,109 @@ (define (make-greetd-agreety-session-command config command)
      "agreety-command"
      #~(execl #$agreety #$agreety "-c" #$command))))
 
+(define-record-type* <greetd-wlgreet-session>
+  greetd-wlgreet-session make-greetd-wlgreet-session
+  greetd-wlgreet-session?
+  (wlgreet greetd-wlgreet (default wlgreet))
+  (command greetd-wlgreet-command
+           (default (file-append sway "/bin/sway")))
+  (command-args greetd-wlgreet-command-args (default '()))
+  (output-mode greetd-wlgreet-output-mode (default "all"))
+  (scale greetd-wlgreet-scale (default 1))
+  (background greetd-wlgreet-background (default '(0 0 0 0.9)))
+  (headline greetd-wlgreet-headline (default '(1 1 1 1)))
+  (prompt greetd-wlgreet-prompt (default '(1 1 1 1)))
+  (prompt-error greetd-wlgreet-prompt-error (default '(1 1 1 1)))
+  (border greetd-wlgreet-border (default '(1 1 1 1)))
+  (extra-env greetd-wlgreet-extra-env (default '())))
+
+(define (greetd-wlgreet-wayland-session-command session)
+  (program-file "wlgreet-session-command"
+    #~(let* ((username (getenv "USER"))
+             (useruid (number->string
+                       (passwd:uid (getpwuid username))))
+             (command #$(greetd-wlgreet-command session)))
+        (use-modules (ice-9 match))
+        (setenv "XDG_SESSION_TYPE" "wayland")
+        (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid))
+        (for-each (lambda (env) (setenv (car env) (cdr env)))
+                  '(#$@(greetd-wlgreet-extra-env session)))
+        (apply execl command command
+               (list #$@(greetd-wlgreet-command-args session))))))
+
+(define (make-wlgreet-config-color section-name color)
+  (match color
+    ((red green blue opacity)
+     (string-append
+      "[" section-name "]\n"
+      "red = " (number->string red) "\n"
+      "green = " (number->string green) "\n"
+      "blue = " (number->string blue) "\n"
+      "opacity = " (number->string opacity) "\n"))))
+
+(define (make-wlgreet-configuration-file session)
+  (let ((command (greetd-wlgreet-wayland-session-command session))
+        (output-mode (greetd-wlgreet-output-mode session))
+        (scale (greetd-wlgreet-scale session))
+        (background (greetd-wlgreet-background session))
+        (headline (greetd-wlgreet-headline session))
+        (prompt (greetd-wlgreet-prompt session))
+        (prompt-error (greetd-wlgreet-prompt-error session))
+        (border (greetd-wlgreet-border session)))
+    (mixed-text-file "wlgreet.toml"
+      "command = \"" command "\"\n"
+      "outputMode = \"" output-mode "\"\n"
+      "scale = " (number->string scale) "\n"
+      (apply string-append
+             (map (match-lambda
+                    ((section-name . color)
+                     (make-wlgreet-config-color section-name color)))
+                  `(("background" . ,background)
+                    ("headline" . ,headline)
+                    ("prompt" . ,prompt)
+                    ("prompt-error" . ,prompt-error)
+                    ("border" . ,border)))))))
+
+(define-record-type* <greetd-wlgreet-sway-session>
+  greetd-wlgreet-sway-session make-greetd-wlgreet-sway-session
+  greetd-wlgreet-sway-session?
+  (wlgreet-session greetd-wlgreet-sway-session-wlgreet-session       ;<greetd-wlgreet-session>
+                   (default (greetd-wlgreet-session)))
+  (sway greetd-wlgreet-sway-session-sway (default sway))             ;<package>
+  (sway-configuration greetd-wlgreet-sway-session-sway-configuration ;file-like
+                      (default (plain-file "wlgreet-sway-config" ""))))
+
+(define (make-wlgreet-sway-configuration-file session)
+  (let* ((wlgreet-session (greetd-wlgreet-sway-session-wlgreet-session session))
+         (wlgreet-config (make-wlgreet-configuration-file wlgreet-session))
+         (wlgreet (file-append (greetd-wlgreet wlgreet-session) "/bin/wlgreet"))
+         (sway-config (greetd-wlgreet-sway-session-sway-configuration session))
+         (swaymsg (file-append (greetd-wlgreet-sway-session-sway session)
+                               "/bin/swaymsg")))
+    (mixed-text-file "wlgreet-sway.conf"
+      "include " sway-config "\n"
+      "xwayland disable\n"
+      "exec \"" wlgreet " --config " wlgreet-config "; "
+      swaymsg " exit\"\n")))
+
+(define (greetd-wlgreet-sway-session-command session)
+  (let ((sway (file-append (greetd-wlgreet-sway-session-sway session)
+                           "/bin/sway"))
+        (config (make-wlgreet-sway-configuration-file session)))
+    (program-file "wlgreet-sway-session-command"
+      #~(let* ((log-file (open-output-file
+                          (string-append "/tmp/sway-greeter."
+                                         (number->string (getpid))
+                                         ".log")))
+             (username (getenv "USER"))
+             (useruid (number->string (passwd:uid (getpwuid username)))))
+          ;; redirect stdout/err to log-file
+          (dup2 (fileno log-file) 1)
+          (dup2 1 2)
+          (sleep 1) ;give seatd/logind some time to start up
+          (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid))
+          (execl #$sway #$sway "-d" "-c" #$config)))))
+
 (define (make-greetd-default-session-command config-or-command)
   (cond ((greetd-agreety-session? config-or-command)
          (cond ((greetd-agreety-xdg-env? config-or-command)
@@ -2912,6 +3019,8 @@ (define (make-greetd-default-session-command config-or-command)
                 (make-greetd-agreety-session-command
                  config-or-command
                  (greetd-agreety-tty-session-command config-or-command)))))
+        ((greetd-wlgreet-sway-session? config-or-command)
+         (greetd-wlgreet-sway-session-command config-or-command))
         (#t config-or-command)))
 
 (define-record-type* <greetd-terminal-configuration>
-- 
2.38.0





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

* bug#57721: [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session.
  2022-10-06 18:21   ` ( via Guix-patches via
@ 2022-10-11 11:08     ` Christopher Baines
  0 siblings, 0 replies; 13+ messages in thread
From: Christopher Baines @ 2022-10-11 11:08 UTC (permalink / raw)
  To: (; +Cc: 57721-done

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


"(" <paren@disroot.org> writes:

>> If you could send the remaining patch again (to the same issue), that
>> would be useful too.
>
> Okay, I've rebased it on the latest master and will send it independently.

Thanks, I've pushed this to master now as
59911ae29442aba18bcb53233e793d8f3d264504.

Chris

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

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

end of thread, other threads:[~2022-10-11 12:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-10 20:29 [bug#57721] [PATCH 0/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
2022-09-10 20:30 ` [bug#57721] [PATCH 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
2022-09-10 20:30   ` [bug#57721] [PATCH 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
2022-09-10 20:30   ` [bug#57721] [PATCH 3/4] gnu: Add wlgreet ( via Guix-patches via
2022-09-10 20:30   ` [bug#57721] [PATCH 4/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
2022-09-11  8:02 ` [bug#57721] [PATCH v2 1/4] gnu: Add rust-greetd-ipc-0.8 ( via Guix-patches via
2022-09-11  8:02   ` [bug#57721] [PATCH v2 2/4] gnu: Add rust-os-pipe-0.8 ( via Guix-patches via
2022-09-11  8:02   ` [bug#57721] [PATCH v2 3/4] gnu: Add wlgreet ( via Guix-patches via
2022-09-11  8:02   ` [bug#57721] [PATCH v2 4/4] gnu: base: Add greetd-wlgreet-sway-session ( via Guix-patches via
2022-10-06 14:13 ` [bug#57721] [PATCH 0/4] " Christopher Baines
2022-10-06 18:21   ` ( via Guix-patches via
2022-10-11 11:08     ` bug#57721: " Christopher Baines
2022-10-09 18:16 ` [bug#57721] [PATCH v3] " ( via Guix-patches via

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.