unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#58818] [PATCH 0/1] gnu: home: greetd-service-type: Add gexp compilers for sessions.
@ 2022-10-27 17:35 ( via Guix-patches via
  2022-10-27 17:38 ` [bug#58818] [PATCH 1/1] " ( via Guix-patches via
  0 siblings, 1 reply; 6+ messages in thread
From: ( via Guix-patches via @ 2022-10-27 17:35 UTC (permalink / raw)
  To: 58818; +Cc: (

Heya Guix!

This patch changes greetd-service-type to use gexp compilers to turn
session records into program-files, instead of an ad-hoc sanitiser
procedure.

( (1):
  gnu: home: greetd-service-type: Add gexp compilers for sessions.

 gnu/services/base.scm | 65 ++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 35 deletions(-)


base-commit: 78d4a08ac3a1de481bc56eef967a2e5ed2a912d5
-- 
2.38.0





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

* [bug#58818] [PATCH 1/1] gnu: home: greetd-service-type: Add gexp compilers for sessions.
  2022-10-27 17:35 [bug#58818] [PATCH 0/1] gnu: home: greetd-service-type: Add gexp compilers for sessions ( via Guix-patches via
@ 2022-10-27 17:38 ` ( via Guix-patches via
  2022-11-02 14:00   ` Andrew Tropin
  2022-11-09  7:33   ` Andrew Tropin
  0 siblings, 2 replies; 6+ messages in thread
From: ( via Guix-patches via @ 2022-10-27 17:38 UTC (permalink / raw)
  To: 58818; +Cc: (

* gnu/home/services/base.scm (make-greetd-agreety-session-command,
  greetd-wlgreet-sway-session-command,
  make-greetd-default-session-command): Remove variables.
(greetd-agreety-session-compiler,
greetd-wlgreet-sway-session-compiler): New gexp compilers.
(greetd-terminal-configuration)[default-session-command]<sanitize>:
Remove it.
---
 gnu/services/base.scm | 65 ++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 35 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index d3e3335030..3bf924b8f1 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2900,11 +2900,18 @@ (define greetd-agreety-tty-xdg-session-command
                     (quote (#$@extra-env)))
           (apply execl #$command #$command (list #$@args)))))))
 
-(define (make-greetd-agreety-session-command config command)
-  (let ((agreety (file-append (greetd-agreety config) "/bin/agreety")))
-    (program-file
-     "agreety-command"
-     #~(execl #$agreety #$agreety "-c" #$command))))
+(define-gexp-compiler (greetd-agreety-session-compiler
+                       (session <greetd-agreety-session>)
+                       system target)
+  (let ((agreety (file-append (greetd-agreety session)
+                              "/bin/agreety"))
+        (command ((if (greetd-agreety-xdg-env? session)
+                      greetd-agreety-tty-xdg-session-command
+                      greetd-agreety-tty-session-command)
+                  session)))
+    (lower-object
+     (program-file "agreety-command"
+       #~(execl #$agreety #$agreety "-c" #$command)))))
 
 (define-record-type* <greetd-wlgreet-session>
   greetd-wlgreet-session make-greetd-wlgreet-session
@@ -2991,37 +2998,26 @@ (define (make-wlgreet-sway-configuration-file session)
       "exec \"" wlgreet " --config " wlgreet-config "; "
       swaymsg " exit\"\n")))
 
-(define (greetd-wlgreet-sway-session-command session)
+(define-gexp-compiler (greetd-wlgreet-sway-session-compiler
+                       (session <greetd-wlgreet-sway-session>)
+                       system target)
   (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)
-                (make-greetd-agreety-session-command
-                 config-or-command
-                 (greetd-agreety-tty-xdg-session-command config-or-command)))
-               (#t
-                (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)))
+    (lower-object
+     (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-record-type* <greetd-terminal-configuration>
   greetd-terminal-configuration make-greetd-terminal-configuration
@@ -3035,8 +3031,7 @@ (define-record-type* <greetd-terminal-configuration>
   (terminal-switch greetd-terminal-switch (default #f))
   (default-session-user greetd-default-session-user (default "greeter"))
   (default-session-command greetd-default-session-command
-    (default (greetd-agreety-session))
-    (sanitize make-greetd-default-session-command)))
+    (default (greetd-agreety-session))))
 
 (define (default-config-file-name config)
   (string-join (list "config-" (greetd-terminal-vt config) ".toml") ""))
-- 
2.38.0





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

* [bug#58818] [PATCH 1/1] gnu: home: greetd-service-type: Add gexp compilers for sessions.
  2022-10-27 17:38 ` [bug#58818] [PATCH 1/1] " ( via Guix-patches via
@ 2022-11-02 14:00   ` Andrew Tropin
  2022-11-02 16:44     ` ( via Guix-patches via
  2022-11-09  7:33   ` Andrew Tropin
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Tropin @ 2022-11-02 14:00 UTC (permalink / raw)
  To: 58818; +Cc: (, muradm

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

On 2022-10-27 18:38, "\( via Guix-patches" via wrote:

> * gnu/home/services/base.scm (make-greetd-agreety-session-command,

It should be gnu/services/base.scm, whithout home.

>   greetd-wlgreet-sway-session-command,
>   make-greetd-default-session-command): Remove variables.
> (greetd-agreety-session-compiler,
> greetd-wlgreet-sway-session-compiler): New gexp compilers.
> (greetd-terminal-configuration)[default-session-command]<sanitize>:
> Remove it.
> ---
>  gnu/services/base.scm | 65 ++++++++++++++++++++-----------------------
>  1 file changed, 30 insertions(+), 35 deletions(-)
>
> diff --git a/gnu/services/base.scm b/gnu/services/base.scm
> index d3e3335030..3bf924b8f1 100644
> --- a/gnu/services/base.scm
> +++ b/gnu/services/base.scm
> @@ -2900,11 +2900,18 @@ (define greetd-agreety-tty-xdg-session-command
>                      (quote (#$@extra-env)))
>            (apply execl #$command #$command (list #$@args)))))))
>  
> -(define (make-greetd-agreety-session-command config command)
> -  (let ((agreety (file-append (greetd-agreety config) "/bin/agreety")))
> -    (program-file
> -     "agreety-command"
> -     #~(execl #$agreety #$agreety "-c" #$command))))
> +(define-gexp-compiler (greetd-agreety-session-compiler
> +                       (session <greetd-agreety-session>)
> +                       system target)
> +  (let ((agreety (file-append (greetd-agreety session)
> +                              "/bin/agreety"))
> +        (command ((if (greetd-agreety-xdg-env? session)
> +                      greetd-agreety-tty-xdg-session-command
> +                      greetd-agreety-tty-session-command)
> +                  session)))
> +    (lower-object
> +     (program-file "agreety-command"
> +       #~(execl #$agreety #$agreety "-c" #$command)))))
>  
>  (define-record-type* <greetd-wlgreet-session>
>    greetd-wlgreet-session make-greetd-wlgreet-session
> @@ -2991,37 +2998,26 @@ (define (make-wlgreet-sway-configuration-file session)
>        "exec \"" wlgreet " --config " wlgreet-config "; "
>        swaymsg " exit\"\n")))
>  
> -(define (greetd-wlgreet-sway-session-command session)
> +(define-gexp-compiler (greetd-wlgreet-sway-session-compiler
> +                       (session <greetd-wlgreet-sway-session>)
> +                       system target)
>    (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)
> -                (make-greetd-agreety-session-command
> -                 config-or-command
> -                 (greetd-agreety-tty-xdg-session-command config-or-command)))
> -               (#t
> -                (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)))
> +    (lower-object
> +     (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-record-type* <greetd-terminal-configuration>
>    greetd-terminal-configuration make-greetd-terminal-configuration
> @@ -3035,8 +3031,7 @@ (define-record-type* <greetd-terminal-configuration>
>    (terminal-switch greetd-terminal-switch (default #f))
>    (default-session-user greetd-default-session-user (default "greeter"))
>    (default-session-command greetd-default-session-command
> -    (default (greetd-agreety-session))
> -    (sanitize make-greetd-default-session-command)))
> +    (default (greetd-agreety-session))))
>  
>  (define (default-config-file-name config)
>    (string-join (list "config-" (greetd-terminal-vt config) ".toml") ""))

I didn't test it, but this change looks good.  Also CCed muradm.

I can take a deeper look and try it out later this week if nobody else
will do it earlier.

-- 
Best regards,
Andrew Tropin

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

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

* [bug#58818] [PATCH 1/1] gnu: home: greetd-service-type: Add gexp compilers for sessions.
  2022-11-02 14:00   ` Andrew Tropin
@ 2022-11-02 16:44     ` ( via Guix-patches via
  0 siblings, 0 replies; 6+ messages in thread
From: ( via Guix-patches via @ 2022-11-02 16:44 UTC (permalink / raw)
  To: andrew, 58818; +Cc: muradm

On Wed Nov 2, 2022 at 2:00 PM GMT, Andrew Tropin wrote:
> It should be gnu/services/base.scm, whithout home.

Oops! :)

    -- (




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

* [bug#58818] [PATCH 1/1] gnu: home: greetd-service-type: Add gexp compilers for sessions.
  2022-10-27 17:38 ` [bug#58818] [PATCH 1/1] " ( via Guix-patches via
  2022-11-02 14:00   ` Andrew Tropin
@ 2022-11-09  7:33   ` Andrew Tropin
  2022-11-09  7:41     ` ( via Guix-patches via
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Tropin @ 2022-11-09  7:33 UTC (permalink / raw)
  To: 58818; +Cc: (

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

On 2022-10-27 18:38, guix-patches@gnu.org wrote:

> * gnu/home/services/base.scm (make-greetd-agreety-session-command,
>   greetd-wlgreet-sway-session-command,
>   make-greetd-default-session-command): Remove variables.
> (greetd-agreety-session-compiler,
> greetd-wlgreet-sway-session-compiler): New gexp compilers.
> (greetd-terminal-configuration)[default-session-command]<sanitize>:
> Remove it.
> ---
>  gnu/services/base.scm | 65 ++++++++++++++++++++-----------------------
>  1 file changed, 30 insertions(+), 35 deletions(-)
>
> diff --git a/gnu/services/base.scm b/gnu/services/base.scm
> index d3e3335030..3bf924b8f1 100644
> --- a/gnu/services/base.scm
> +++ b/gnu/services/base.scm
> @@ -2900,11 +2900,18 @@ (define greetd-agreety-tty-xdg-session-command
>                      (quote (#$@extra-env)))
>            (apply execl #$command #$command (list #$@args)))))))
>  
> -(define (make-greetd-agreety-session-command config command)
> -  (let ((agreety (file-append (greetd-agreety config) "/bin/agreety")))
> -    (program-file
> -     "agreety-command"
> -     #~(execl #$agreety #$agreety "-c" #$command))))
> +(define-gexp-compiler (greetd-agreety-session-compiler
> +                       (session <greetd-agreety-session>)
> +                       system target)
> +  (let ((agreety (file-append (greetd-agreety session)
> +                              "/bin/agreety"))
> +        (command ((if (greetd-agreety-xdg-env? session)
> +                      greetd-agreety-tty-xdg-session-command
> +                      greetd-agreety-tty-session-command)
> +                  session)))
> +    (lower-object
> +     (program-file "agreety-command"
> +       #~(execl #$agreety #$agreety "-c" #$command)))))
>  
>  (define-record-type* <greetd-wlgreet-session>
>    greetd-wlgreet-session make-greetd-wlgreet-session
> @@ -2991,37 +2998,26 @@ (define (make-wlgreet-sway-configuration-file session)
>        "exec \"" wlgreet " --config " wlgreet-config "; "
>        swaymsg " exit\"\n")))
>  
> -(define (greetd-wlgreet-sway-session-command session)
> +(define-gexp-compiler (greetd-wlgreet-sway-session-compiler
> +                       (session <greetd-wlgreet-sway-session>)
> +                       system target)
>    (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)
> -                (make-greetd-agreety-session-command
> -                 config-or-command
> -                 (greetd-agreety-tty-xdg-session-command config-or-command)))
> -               (#t
> -                (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)))
> +    (lower-object
> +     (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-record-type* <greetd-terminal-configuration>
>    greetd-terminal-configuration make-greetd-terminal-configuration
> @@ -3035,8 +3031,7 @@ (define-record-type* <greetd-terminal-configuration>
>    (terminal-switch greetd-terminal-switch (default #f))
>    (default-session-user greetd-default-session-user (default "greeter"))
>    (default-session-command greetd-default-session-command
> -    (default (greetd-agreety-session))
> -    (sanitize make-greetd-default-session-command)))
> +    (default (greetd-agreety-session))))
>  
>  (define (default-config-file-name config)
>    (string-join (list "config-" (greetd-terminal-vt config) ".toml") ""))

Applied, tested agreety session, adjusted commit message, pushed as
fdc9e1b27edfb3df51d391364bcbc50e9cd1de40.

Thank you!

-- 
Best regards,
Andrew Tropin

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

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

* [bug#58818] [PATCH 1/1] gnu: home: greetd-service-type: Add gexp compilers for sessions.
  2022-11-09  7:33   ` Andrew Tropin
@ 2022-11-09  7:41     ` ( via Guix-patches via
  0 siblings, 0 replies; 6+ messages in thread
From: ( via Guix-patches via @ 2022-11-09  7:41 UTC (permalink / raw)
  To: andrew, 58818

On Wed Nov 9, 2022 at 7:33 AM GMT, Andrew Tropin wrote:
> Thank you!

Thanks!

    -- (




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

end of thread, other threads:[~2022-11-09  7:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-27 17:35 [bug#58818] [PATCH 0/1] gnu: home: greetd-service-type: Add gexp compilers for sessions ( via Guix-patches via
2022-10-27 17:38 ` [bug#58818] [PATCH 1/1] " ( via Guix-patches via
2022-11-02 14:00   ` Andrew Tropin
2022-11-02 16:44     ` ( via Guix-patches via
2022-11-09  7:33   ` Andrew Tropin
2022-11-09  7:41     ` ( via Guix-patches via

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