GNU bug report logs - #50856
Unbound variables in Guix Home

Previous Next

Package: guix;

Reported by: Oleg Pykhalov <go.wigust <at> gmail.com>

Date: Mon, 27 Sep 2021 21:16:02 UTC

Severity: normal

Done: Oleg Pykhalov <go.wigust <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50856 in the body.
You can then email your comments to 50856 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#50856; Package guix. (Mon, 27 Sep 2021 21:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Mon, 27 Sep 2021 21:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: bug-guix <bug-guix <at> gnu.org>
Cc: Andrew Tropin <andrew <at> trop.in>
Subject: Unbound variables in Guix Home
Date: Tue, 28 Sep 2021 00:15:33 +0300
[Message part 1 (text/plain, inline)]
Hi Guix,

We have unbound variables in some Guix Home files:
--8<---------------cut here---------------start------------->8---
gnu/home-services/configuration.scm:56:6: warning: possibly unbound variable `formatted-message'
gnu/home-services/configuration.scm:57:7: warning: possibly unbound variable `G_'
gnu/home-services/xdg.scm:309:43: warning: possibly unbound variable `maybe-list'
gnu/home-services/xdg.scm:330:13: warning: possibly unbound variable `list->human-readable-list'
guix/scripts/home/import.scm:210:18: warning: possibly unbound variable `package-version'
guix/scripts/home/import.scm:210:35: warning: possibly unbound variable `find-packages-by-name'
guix/scripts/home/import.scm:222:23: warning: possibly unbound variable `cut'
guix/scripts/home/import.scm:222:27: warning: possibly unbound variable `version>?'
guix/scripts/home/import.scm:222:45: warning: possibly unbound variable `<>'
guix/scripts/home/import.scm:225:16: warning: possibly unbound variable `version-unique-prefix'
--8<---------------cut here---------------end--------------->8---

maybe-list and list->human-readable-list come from
gnu/home-services-utils.scm in rde project.

Oleg.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#50856; Package guix. (Tue, 28 Sep 2021 09:36:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Oleg Pykhalov <go.wigust <at> gmail.com>, bug-guix <bug-guix <at> gnu.org>
Subject: Re: Unbound variables in Guix Home
Date: Tue, 28 Sep 2021 12:35:37 +0300
[Message part 1 (text/plain, inline)]
On 2021-09-28 00:15, Oleg Pykhalov wrote:

> Hi Guix,
>
> We have unbound variables in some Guix Home files:
> --8<---------------cut here---------------start------------->8---
> gnu/home-services/configuration.scm:56:6: warning: possibly unbound variable `formatted-message'
> gnu/home-services/configuration.scm:57:7: warning: possibly unbound variable `G_'
> gnu/home-services/xdg.scm:309:43: warning: possibly unbound variable `maybe-list'
> gnu/home-services/xdg.scm:330:13: warning: possibly unbound variable `list->human-readable-list'
> guix/scripts/home/import.scm:210:18: warning: possibly unbound variable `package-version'
> guix/scripts/home/import.scm:210:35: warning: possibly unbound variable `find-packages-by-name'
> guix/scripts/home/import.scm:222:23: warning: possibly unbound variable `cut'
> guix/scripts/home/import.scm:222:27: warning: possibly unbound variable `version>?'
> guix/scripts/home/import.scm:222:45: warning: possibly unbound variable `<>'
> guix/scripts/home/import.scm:225:16: warning: possibly unbound variable `version-unique-prefix'
> --8<---------------cut here---------------end--------------->8---
>
> maybe-list and list->human-readable-list come from
> gnu/home-services-utils.scm in rde project.
>
> Oleg.

My bad)  Here it is:

[0001-home-services-Add-missing-imports-and-function-defin.patch (text/x-patch, inline)]
From 634e6cbb7153ea02fb2ace6d39dae4055ed0c73c Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Tue, 28 Sep 2021 12:30:55 +0300
Subject: [PATCH] home-services: Add missing imports and function definition.

* gnu/home-services/configuration.scm: Add missing imports.
* gnu/home-services/utils.scm (list->human-readable-list): Add new function.
* gnu/home-services/configuration.scm: Add missing imports.
* gnu/home-services/xdg.scm: Fix ensure-list function.
* guix/scripts/home/import.scm: Add missing imports.
---
 gnu/home-services/configuration.scm |  2 ++
 gnu/home-services/utils.scm         | 30 ++++++++++++++++++++++++++++-
 gnu/home-services/xdg.scm           | 12 +++++++-----
 guix/scripts/home/import.scm        |  4 ++++
 4 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/gnu/home-services/configuration.scm b/gnu/home-services/configuration.scm
index 3698006c37..e8f4bc77ec 100644
--- a/gnu/home-services/configuration.scm
+++ b/gnu/home-services/configuration.scm
@@ -23,6 +23,8 @@
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 curried-definitions)
   #:use-module (ice-9 match)
+  #:use-module (guix i18n)
+  #:use-module (guix diagnostics)
 
   #:export (filter-configuration-fields
 
diff --git a/gnu/home-services/utils.scm b/gnu/home-services/utils.scm
index 3e490a0515..f13133a7ae 100644
--- a/gnu/home-services/utils.scm
+++ b/gnu/home-services/utils.scm
@@ -24,7 +24,8 @@
 
   #:export (maybe-object->string
             object->snake-case-string
-            object->camel-case-string))
+            object->camel-case-string
+            list->human-readable-list))
 
 (define (maybe-object->string object)
   "Like @code{object->string} but don't do anyting if OBJECT already is
@@ -75,3 +76,30 @@ STYLE can be three `@code{lower}', `@code{upper}', defaults to
              (cons (first splitted-string)
                    (map string-capitalize
                         (cdr splitted-string))))))))))
+
+(define* (list->human-readable-list lst
+                                    #:key
+                                    (cumulative? #f)
+                                    (proc identity))
+  "Turn a list LST into a sequence of terms readable by humans.
+If CUMULATIVE? is @code{#t}, use ``and'', otherwise use ``or'' before
+the last term.
+
+PROC is a procedure to apply to each of the elements of a list before
+turning them into a single human readable string.
+
+@example
+(list->human-readable-list '(1 4 9) #:cumulative? #t #:proc sqrt)
+@result{} \"1, 2, and 3\"
+@end example
+
+yields:"
+  (let* ((word (if cumulative? "and " "or "))
+         (init (append (drop-right lst 1))))
+    (format #f "~a" (string-append
+                     (string-join
+                      (map (compose maybe-object->string proc) init)
+                      ", " 'suffix)
+                     word
+                     (maybe-object->string (proc (last lst)))))))
+
diff --git a/gnu/home-services/xdg.scm b/gnu/home-services/xdg.scm
index 457ce999a1..94275f3b65 100644
--- a/gnu/home-services/xdg.scm
+++ b/gnu/home-services/xdg.scm
@@ -287,9 +287,9 @@ The value of an XDG MIME entry must be a list, string or symbol, was given ~a")
 
 @example
 (merge-duplicates '((key1 . value1)
-                      (key2 . value2)
-                      (key1 . value3)
-                      (key1 . value4)) '())
+                    (key2 . value2)
+                    (key1 . value3)
+                    (key1 . value4)) '())
 
 @result{} ((key1 . (value4 value3 value1)) (key2 . value2))
 @end example"
@@ -299,14 +299,16 @@ The value of an XDG MIME entry must be a list, string or symbol, was given ~a")
                   (tail (cdr alist))
                   (key (first head))
                   (value (cdr head))
-                  (duplicate? (assoc key acc)))
+                  (duplicate? (assoc key acc))
+                  (ensure-list (lambda (x)
+                                 (if (list? x) x (list x)))))
              (if duplicate?
                  ;; XXX: This will change the order of things,
                  ;; though, it shouldn't be a problem for XDG MIME.
                  (merge-duplicates
                   tail
                   (alist-cons key
-                              (cons value (maybe-list (cdr duplicate?)))
+                              (cons value (ensure-list (cdr duplicate?)))
                               (alist-delete key acc)))
                  (merge-duplicates tail (cons head acc)))))))
 
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm
index 39f45dbeac..79fb23a2fd 100644
--- a/guix/scripts/home/import.scm
+++ b/guix/scripts/home/import.scm
@@ -20,9 +20,13 @@
 (define-module (guix scripts home import)
   #:use-module (guix profiles)
   #:use-module (guix ui)
+  #:use-module (guix utils)
+  #:use-module (guix packages)
+  #:use-module (gnu packages)
   #:use-module (ice-9 match)
   #:use-module (ice-9 pretty-print)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
   #:export (import-manifest))
 
 ;;; Commentary:
-- 
2.33.0

[signature.asc (application/pgp-signature, inline)]

Reply sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
You have taken responsibility. (Tue, 28 Sep 2021 11:07:02 GMT) Full text and rfc822 format available.

Notification sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
bug acknowledged by developer. (Tue, 28 Sep 2021 11:07:02 GMT) Full text and rfc822 format available.

Message #13 received at 50856-done <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: 50856-done <at> debbugs.gnu.org
Cc: Andrew Tropin <andrew <at> trop.in>
Subject: Re: Unbound variables in Guix Home
Date: Tue, 28 Sep 2021 14:06:32 +0300
[Message part 1 (text/plain, inline)]
Andrew Tropin <andrew <at> trop.in> writes:

[…]

> From 634e6cbb7153ea02fb2ace6d39dae4055ed0c73c Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew <at> trop.in>
> Date: Tue, 28 Sep 2021 12:30:55 +0300
> Subject: [PATCH] home-services: Add missing imports and function definition.
>
> * gnu/home-services/configuration.scm: Add missing imports.
> * gnu/home-services/utils.scm (list->human-readable-list): Add new function.
> * gnu/home-services/configuration.scm: Add missing imports.
> * gnu/home-services/xdg.scm: Fix ensure-list function.
> * guix/scripts/home/import.scm: Add missing imports.
> ---
>  gnu/home-services/configuration.scm |  2 ++
>  gnu/home-services/utils.scm         | 30 ++++++++++++++++++++++++++++-
>  gnu/home-services/xdg.scm           | 12 +++++++-----
>  guix/scripts/home/import.scm        |  4 ++++
>  4 files changed, 42 insertions(+), 6 deletions(-)

Applied, thank you!

Oleg.

[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 26 Oct 2021 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 155 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.