Subject: Re: [bug#77352] [PATCH v2] home: services: define hyprland home service

From: Andrew Wong <[email-masked]>
Date: Sun, 30 Mar 2025 21:14:35 -0400

Hello,
I've suggested some small changes which I've attached as patches. I also 
have some questions and comments:

On 3/30/25 1:11p, Carmine Margiotta wrote:> +;;; Gexp executables will 
be serialized on a program-file
> +(define (serialize-executable name value)
> +  (if (string? value) value
> +      (program-file (symbol->string name) value
> +                    #:module-path %load-path))
How will you serialize g-expressions? It seems that they are to be added 
to the store as scripts with 'program-file', but I can't figure out how 
to extract the file path from the resulting object; I tried in a REPL, 
program-file objects cannot be used as strings like this function seems 
to suggest, and none of the their properties seem to clearly give their 
location in the store.

Also, how are you testing your work? I asked in the IRC channel and they 
suggested spooling up a VM via 'guix system vm' with an operating-system 
definition containing the experimental service, but perhaps you have 
your own method.

From 0d2c72441d9b4a94aded6d53028d63b253f5e7ae Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Andrew Wong <[email-masked]>
Date: Sun, 30 Mar 2025 15:16:27 -0400
Subject: [PATCH 1/5] home: services: hyprland(%default-hyprland-env): Fix
 typo.

Change-Id: I7ade3bf3a9a550b246aa9db66f3cea626640c180
---
 gnu/home/services/hyprland.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/home/services/hyprland.scm b/gnu/home/services/hyprland.scm
index 3f2495ec0d..04dbb5ecc4 100644
--- a/gnu/home/services/hyprland.scm
+++ b/gnu/home/services/hyprland.scm
@@ -350,7 +350,7 @@ (define-public %default-hyprland-env
   (list
    (env (name "XCURSOR_SIZE")
         (value "24"))
-   (env (name "HYPRCURSON_SIZE")
+   (env (name "HYPRCURSOR_SIZE")
         (value "24"))))
 
 (define-public %default-hyprland-windowrule

base-commit: 353f7724b26d72986eab4e181dc342904755a5d6
-- 
2.49.0

From 746a1d5ec67f96965d80b280fc8783bdc7e68a01 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Andrew Wong <[email-masked]>
Date: Sun, 30 Mar 2025 15:17:24 -0400
Subject: [PATCH 2/5] home: services: hyprland(%default-hyprland-bindings):
 Rem. submap

Remove the 'submap' entry, because the currently packaged Hyprland config does
not define any submaps.
Change-Id: I7628aaf89ee60e7fa66b932e48a6c478e9d7a91a

Change-Id: Icaf0a44a46aa8346477da5367ee35555acfc0590
---
 gnu/home/services/hyprland.scm | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gnu/home/services/hyprland.scm b/gnu/home/services/hyprland.scm
index 04dbb5ecc4..f63d9f5bbb 100644
--- a/gnu/home/services/hyprland.scm
+++ b/gnu/home/services/hyprland.scm
@@ -539,10 +539,7 @@ (define-public %default-hyprland-bindings
                      ,(binding
                        (key "XF86AudioPrev")
                        (action "exec")
-                       (args "playerctl previous"))
-                     ,(binding (key "R")
-                               (action "submap")
-                               (args "resize"))))))
+                       (args "playerctl previous"))))))
 
 (define-public %default-hyprland-configuration
   (hyprland-configuration (general %default-hyprland-general)
-- 
2.49.0

From c8b0ac164be8eedf93a26eafe0e1b12430086139 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Andrew Wong <[email-masked]>
Date: Sun, 30 Mar 2025 15:18:38 -0400
Subject: [PATCH 3/5] home: services: hyprland(hyprland-reload): Reword phrases

Reword the documentation and the notification given on a mismatched default
config hash.

Change-Id: I8129ea168c1fd42078fabc953da21e6b830060d1
---
 gnu/home/services/hyprland.scm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gnu/home/services/hyprland.scm b/gnu/home/services/hyprland.scm
index f63d9f5bbb..c57573bcf9 100644
--- a/gnu/home/services/hyprland.scm
+++ b/gnu/home/services/hyprland.scm
@@ -563,9 +563,8 @@ (define-public %default-hyprland-configuration
 (define %default-configuration-hash 970253705680761254)
 
 ;;; Reload the first instance of hyprland to automatically load the new
-;;; configuration. If the package's default configuration changes, after
-;;; applying a new configuration, a warning notification is automatically
-;;; shown on Hyprland until maintainers don't align the guix defaults
+;;; configuration. If the package's default configuration changes, display a
+;;; notification in Hyprland asking for a review of the service's provided defaults.
 (define (hyprland-reload config)
   (with-imported-modules
       (source-module-closure
@@ -598,9 +597,8 @@ (define (hyprland-reload config)
 			 "0" ; this is a warning
 			 "20000" ; 10s duration
 			 "0" ; default color
-			 "Package default configuration has changed, \
-please review your configuration and notify \
-the Guix service maintainer")))))))
+			 "Hyprland's default configuration file has changed, and its\
+Guix service may be out of sync. Please file a bug via [email-masked].")))))))
 
 ;;;
 ;;; Definition of the Home Service.
-- 
2.49.0

From 659d791289be3807dada412890efd46a309c51aa Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Andrew Wong <[email-masked]>
Date: Sun, 30 Mar 2025 17:02:22 -0400
Subject: [PATCH 4/5] home: services: hyprland: Localize 'flatten'

home: services: hyprland(home-hyprland-service-type): Localize 'flatten'.
home: services: hyprland(flatten): Delete.
Change-Id: Id15d39d8b9fffd3b5d15cc2984bb8567551c3543
---
 gnu/home/services/hyprland.scm | 42 ++++++++++++----------------------
 1 file changed, 15 insertions(+), 27 deletions(-)

diff --git a/gnu/home/services/hyprland.scm b/gnu/home/services/hyprland.scm
index c57573bcf9..cade4402ac 100644
--- a/gnu/home/services/hyprland.scm
+++ b/gnu/home/services/hyprland.scm
@@ -59,18 +59,6 @@ (define (indent tabs)
       (apply string-append
              (repeat "\t" tabs))))
 
-(define (flatten lst)
-  (let loop
-      ((lst lst)
-       (acc '()))
-    (cond
-     ((null? lst)
-      acc)
-     ((pair? lst)
-      (loop (car lst)
-            (loop (cdr lst) acc)))
-     (else (cons lst acc)))))
-
 ;;;
 ;;; Definition of configurations.
 ;;;
@@ -608,21 +596,21 @@ (define-public home-hyprland-service-type
   (service-type (name 'home-hyprland-config)
                 (description "Configure Hyprland by providing a file
 @file{~/.config/hypr/hyprland.conf}.")
-                (compose (λ (extensions)
-                           (hyprland-extension (exec-once
-                                                (flatten
-                                                 (map
-                                                  hyprland-extension-exec-once
-                                                  extensions)))
-                                               (exec (flatten
-                                                      (map
-                                                       hyprland-extension-exec
-                                                       extensions)))
-                                               (bindings
-                                                (flatten
-                                                 (map
-                                                  hyprland-extension-bindings
-                                                  extensions))))))
+                (compose
+                 (λ (extensions)
+                   (let ((flatten lst)
+                         (let loop ((lst lst) (acc '()))
+                           (cond ((null? lst) acc)
+                                 ((pair? lst) (loop (car lst)
+                                                    (loop (cdr lst) acc)))
+                                 (else (cons lst acc)))))
+                     (hyprland-extension
+                      (exec-once
+                       (flatten (map hyprland-extension-exec-once extensions)))
+                      (exec (flatten (map hyprland-extension-exec
+                                          extensions)))
+                      (bindings (flatten (map hyprland-extension-bindings
+                                              extensions)))))))
                 (extend
                  (λ (config rules)
                    (hyprland-configuration
-- 
2.49.0

From 70dd0149f777eae9f4ea4a4c7d92ca058b1e76bf Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: Andrew Wong <[email-masked]>
Date: Sun, 30 Mar 2025 17:20:31 -0400
Subject: [PATCH 5/5] home: services: hyprland: Localize 'indent'

home: services: hyprland(serialize-block-entry): Localize 'indent'.
home: services: hyprland(indent): Delete.
home: services: hyprland(repeat): Delete.
Change-Id: Id36e4eac964bf424ac4f8e2b411d69da402d9b5b
---
 gnu/home/services/hyprland.scm | 52 +++++++++++-----------------------
 1 file changed, 16 insertions(+), 36 deletions(-)

diff --git a/gnu/home/services/hyprland.scm b/gnu/home/services/hyprland.scm
index cade4402ac..36e5ae951a 100644
--- a/gnu/home/services/hyprland.scm
+++ b/gnu/home/services/hyprland.scm
@@ -42,23 +42,6 @@ (define-module (home home services hyprland)
 ;;;
 ;;; Code:
 
-;;;
-;;; Helper functions.
-;;;
-
-;;; Repeat v n times
-(define (repeat v n)
-  (if (eq? n 0)
-      '()
-      `(,v ,@(repeat v
-                     (- n 1)))))
-
-;;; Generate an indenter string of n tabs
-(define (indent tabs)
-  (if (<= tabs 0) ""
-      (apply string-append
-             (repeat "\t" tabs))))
-
 ;;;
 ;;; Definition of configurations.
 ;;;
@@ -242,25 +225,22 @@ (define (serialize-block-entry value tabs)
          (() "")
          (((? symbol? name)
            value)
-          (string-append
-           (indent tabs)
-           (symbol->string name)
-           (match value
-             ((? string? v)
-              (string-append " = " v))
-             ((? number? v)
-              (string-append " = "
-                             (number->string v)))
-             ((? boolean? v)
-              (if v " = true" " = false"))
-             ((? block-entries? v)
-              (string-append
-               " {\n"
-               (serialize-block-entries
-                #f v
-                (+ tabs 1))
-               (indent tabs) "}")))
-           "\n"))
+          (let (indent (make-string (max 0 tabs) #\tab))
+            (string-append
+             (indent tabs)
+             (symbol->string name)
+             (match value
+               ((? string? v)
+                (string-append " = " v))
+               ((? number? v)
+                (string-append " = " (number->string v)))
+               ((? boolean? v)
+                (if v " = true" " = false"))
+               ((? block-entries? v)
+                (string-append " {\n"
+                               (serialize-block-entries #f v (+ tabs 1))
+                               (indent tabs) "}")))
+             "\n")))
          ((_)
           #f)) "\n")))
 
-- 
2.49.0