GNU bug report logs - #56758
[PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR

Previous Next

Package: guix-patches;

Reported by: Andrew Tropin <andrew <at> trop.in>

Date: Mon, 25 Jul 2022 09:47:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

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 56758 in the body.
You can then email your comments to 56758 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 guix-patches <at> gnu.org:
bug#56758; Package guix-patches. (Mon, 25 Jul 2022 09:47:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrew Tropin <andrew <at> trop.in>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 25 Jul 2022 09:47:02 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: guix-patches <at> gnu.org
Subject: [PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR
Date: Mon, 25 Jul 2022 12:43:47 +0300
[Message part 1 (text/plain, inline)]
Andrew Tropin (2):
  home: xdg: Use closures in activation scripts.
  home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation script.

 gnu/home/services/xdg.scm | 46 ++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 18 deletions(-)

-- 
2.37.0

[0001-home-xdg-Use-closures-in-activation-scripts.patch (text/x-patch, inline)]
From d08ed8de3ead1a704a96e0e6673dffb62f859597 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Thu, 21 Jul 2022 15:24:32 +0300
Subject: [PATCH 1/2] home: xdg: Use closures in activation scripts.

* gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation,
home-xdg-user-directories-files-service): Use closures in activation scripts.
---
 gnu/home/services/xdg.scm | 41 ++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index 71c028c788..5a41dc4994 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -23,6 +23,7 @@ (define-module (gnu home services xdg)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu home services utils)
   #:use-module (guix gexp)
+  #:use-module (guix modules)
   #:use-module (guix records)
   #:use-module (guix i18n)
   #:use-module (guix diagnostics)
@@ -105,16 +106,17 @@ (define (home-xdg-base-directories-environment-variables-service config)
    home-xdg-base-directories-configuration-fields))
 
 (define (ensure-xdg-base-dirs-on-activation config)
-  #~(map (lambda (xdg-base-dir-variable)
-           ((@@ (guix build utils) mkdir-p)
-            (getenv
-             xdg-base-dir-variable)))
-         '#$(map (lambda (field)
-                   (format
-                    #f "XDG_~a"
-                    (object->snake-case-string
-                     (configuration-field-name field) 'upper)))
-                 home-xdg-base-directories-configuration-fields)))
+  (with-imported-modules '((guix build utils))
+    #~(map (lambda (xdg-base-dir-variable)
+             ((@ (guix build utils) mkdir-p)
+              (getenv
+               xdg-base-dir-variable)))
+           '#$(map (lambda (field)
+                     (format
+                      #f "XDG_~a"
+                      (object->snake-case-string
+                       (configuration-field-name field) 'upper)))
+                   home-xdg-base-directories-configuration-fields))))
 
 (define (last-extension-or-cfg config extensions)
   "Picks configuration value from last provided extension.  If there
@@ -205,14 +207,17 @@ (define (home-xdg-user-directories-activation-service config)
   (let ((dirs (map (lambda (field)
                      ((configuration-field-getter field) config))
                    home-xdg-user-directories-configuration-fields)))
-    #~(let ((ensure-dir
-             (lambda (path)
-               (mkdir-p
-                ((@@ (ice-9 string-fun) string-replace-substring)
-                 path "$HOME" (getenv "HOME"))))))
-        (display "Creating XDG user directories...")
-        (map ensure-dir '#$dirs)
-        (display " done\n"))))
+    (with-imported-modules `((guix build utils)
+                             ,@(source-module-closure
+                                '((ice-9 string-fun))))
+      #~(let ((ensure-dir
+               (lambda (path)
+                 ((@ (guix build utils) mkdir-p)
+                  ((@ (ice-9 string-fun) string-replace-substring)
+                   path "$HOME" (getenv "HOME"))))))
+          (display "Creating XDG user directories...")
+          (map ensure-dir '#$dirs)
+          (display " done\n")))))
 
 (define home-xdg-user-directories-service-type
   (service-type (name 'home-xdg-user-directories)
-- 
2.37.0

[0002-home-xdg-Skip-mkdir-XDG_RUNTIME_DIR-in-activation-sc.patch (text/x-patch, inline)]
From da332f8272ea3c240fc4e3664051da3b3a4e18c6 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Thu, 21 Jul 2022 17:06:24 +0300
Subject: [PATCH 2/2] home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation
 script.

* gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation): Skip mkdir
XDG_RUNTIME_DIR in activation script.
---
 gnu/home/services/xdg.scm | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index 5a41dc4994..541f64a379 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -109,13 +109,18 @@ (define (ensure-xdg-base-dirs-on-activation config)
   (with-imported-modules '((guix build utils))
     #~(map (lambda (xdg-base-dir-variable)
              ((@ (guix build utils) mkdir-p)
-              (getenv
-               xdg-base-dir-variable)))
-           '#$(map (lambda (field)
-                     (format
-                      #f "XDG_~a"
-                      (object->snake-case-string
-                       (configuration-field-name field) 'upper)))
+              (getenv xdg-base-dir-variable)))
+           '#$(filter-map
+               (lambda (field)
+                 (let ((env-var-name
+                        (format
+                         #f "XDG_~a"
+                         (object->snake-case-string
+                          (configuration-field-name field) 'upper))))
+                   ;; XDG_RUNTIME_DIR shouldn't be created during activation
+                   ;; and will be provided by elogind or other service.
+                   (and (not (string=? "XDG_RUNTIME_DIR" env-var-name))
+                        env-var-name)))
                    home-xdg-base-directories-configuration-fields))))
 
 (define (last-extension-or-cfg config extensions)
-- 
2.37.0

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

Information forwarded to guix-patches <at> gnu.org:
bug#56758; Package guix-patches. (Mon, 01 Aug 2022 10:09:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Tropin <andrew <at> trop.in>
Cc: 56758 <at> debbugs.gnu.org
Subject: Re: bug#56758: [PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR
Date: Mon, 01 Aug 2022 12:08:39 +0200
[Message part 1 (text/plain, inline)]
Hi,

Andrew Tropin <andrew <at> trop.in> skribis:

> From d08ed8de3ead1a704a96e0e6673dffb62f859597 Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew <at> trop.in>
> Date: Thu, 21 Jul 2022 15:24:32 +0300
> Subject: [PATCH 1/2] home: xdg: Use closures in activation scripts.
>
> * gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation,
> home-xdg-user-directories-files-service): Use closures in activation scripts.

[...]

>  (define (ensure-xdg-base-dirs-on-activation config)
> -  #~(map (lambda (xdg-base-dir-variable)
> -           ((@@ (guix build utils) mkdir-p)
> -            (getenv
> -             xdg-base-dir-variable)))
> -         '#$(map (lambda (field)
> -                   (format
> -                    #f "XDG_~a"
> -                    (object->snake-case-string
> -                     (configuration-field-name field) 'upper)))
> -                 home-xdg-base-directories-configuration-fields)))
> +  (with-imported-modules '((guix build utils))
> +    #~(map (lambda (xdg-base-dir-variable)
> +             ((@ (guix build utils) mkdir-p)

This change doesn’t hurt but it’s apparently unnecessary.

> +    (with-imported-modules `((guix build utils)
> +                             ,@(source-module-closure
> +                                '((ice-9 string-fun))))

However this one is incorrect is it would lead (ice-9 string-fun) from
the host Guile to be imported into the build environment, thereby making
the result dependent on the version of Guile that is used “outside” (you
may have seen a warning like “importing (ice-9 string-fun) from the
host”.)

> From da332f8272ea3c240fc4e3664051da3b3a4e18c6 Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew <at> trop.in>
> Date: Thu, 21 Jul 2022 17:06:24 +0300
> Subject: [PATCH 2/2] home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation
>  script.
>
> * gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation): Skip mkdir
> XDG_RUNTIME_DIR in activation script.
> ---
>  gnu/home/services/xdg.scm | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
> index 5a41dc4994..541f64a379 100644
> --- a/gnu/home/services/xdg.scm
> +++ b/gnu/home/services/xdg.scm
> @@ -109,13 +109,18 @@ (define (ensure-xdg-base-dirs-on-activation config)
>    (with-imported-modules '((guix build utils))
>      #~(map (lambda (xdg-base-dir-variable)
>               ((@ (guix build utils) mkdir-p)
> -              (getenv
> -               xdg-base-dir-variable)))
> -           '#$(map (lambda (field)
> -                     (format
> -                      #f "XDG_~a"
> -                      (object->snake-case-string
> -                       (configuration-field-name field) 'upper)))
> +              (getenv xdg-base-dir-variable)))
> +           '#$(filter-map
> +               (lambda (field)
> +                 (let ((env-var-name
> +                        (format
> +                         #f "XDG_~a"
> +                         (object->snake-case-string
> +                          (configuration-field-name field) 'upper))))
> +                   ;; XDG_RUNTIME_DIR shouldn't be created during activation
> +                   ;; and will be provided by elogind or other service.
> +                   (and (not (string=? "XDG_RUNTIME_DIR" env-var-name))
> +                        env-var-name)))
>                     home-xdg-base-directories-configuration-fields))))
>  
>  (define (last-extension-or-cfg config extensions)

I tweaked that accordingly (patch attached), but that leads to a test
failure in ‘tests/guix-home.sh’ because there’s a warning about
XDG_RUNTIME_DIR not existing that goes to standard output of ‘guix home
container’:

--8<---------------cut here---------------start------------->8---
+ guix home container home.scm -- false
XDG_RUNTIME_DIR doesn't exists, on-first-login script
won't execute anything.  You can check if xdg runtime directory exists,
XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
script by running '$HOME/.guix-home/on-first-login'++ guix home container home.scm -- echo '$HOME'
guix home: warning: only 4.1 GiB of free space available on /gnu/store
hint: Consider deleting old profile generations and collecting garbage, along
these lines:

     guix gc --delete-generations=1m

+ test 'XDG_RUNTIME_DIR doesn'\''t exists, on-first-login script
won'\''t execute anything.  You can check if xdg runtime directory exists,
XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
script by running '\''$HOME/.guix-home/on-first-login'\''/home/ludo' = /home/ludo
--8<---------------cut here---------------end--------------->8---

Thoughts?

Ludo’.

[0001-home-xdg-Skip-mkdir-XDG_RUNTIME_DIR-in-activation-sc.patch (text/x-patch, inline)]
From f6ff733aaaea7e5b8277b65430e7dc090dffa9aa Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Thu, 21 Jul 2022 17:06:24 +0300
Subject: [PATCH] home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation script.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation): Skip mkdir
XDG_RUNTIME_DIR in activation script.

Co-authored-by: Ludovic Courtès <ludo <at> gnu.org>
---
 gnu/home/services/xdg.scm | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index 71c028c788..0219bc93e0 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -109,12 +109,18 @@ (define (ensure-xdg-base-dirs-on-activation config)
            ((@@ (guix build utils) mkdir-p)
             (getenv
              xdg-base-dir-variable)))
-         '#$(map (lambda (field)
-                   (format
-                    #f "XDG_~a"
-                    (object->snake-case-string
-                     (configuration-field-name field) 'upper)))
-                 home-xdg-base-directories-configuration-fields)))
+         '#$(filter-map
+             (lambda (field)
+               (let ((variable
+                      (string-append
+                       "XDG_"
+                       (object->snake-case-string
+                        (configuration-field-name field) 'upper))))
+                 ;; XDG_RUNTIME_DIR shouldn't be created during activation
+                 ;; and will be provided by elogind or other service.
+                 (and (not (string=? "XDG_RUNTIME_DIR" variable))
+                      variable)))
+             home-xdg-base-directories-configuration-fields)))
 
 (define (last-extension-or-cfg config extensions)
   "Picks configuration value from last provided extension.  If there
-- 
2.37.1


Information forwarded to guix-patches <at> gnu.org:
bug#56758; Package guix-patches. (Mon, 01 Aug 2022 12:50:02 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 56758 <at> debbugs.gnu.org
Subject: Re: bug#56758: [PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR
Date: Mon, 01 Aug 2022 15:49:14 +0300
[Message part 1 (text/plain, inline)]
On 2022-08-01 12:08, Ludovic Courtès wrote:

> Hi,
>
> Andrew Tropin <andrew <at> trop.in> skribis:
>
>> From d08ed8de3ead1a704a96e0e6673dffb62f859597 Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew <at> trop.in>
>> Date: Thu, 21 Jul 2022 15:24:32 +0300
>> Subject: [PATCH 1/2] home: xdg: Use closures in activation scripts.
>>
>> * gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation,
>> home-xdg-user-directories-files-service): Use closures in activation scripts.
>
> [...]
>
>>  (define (ensure-xdg-base-dirs-on-activation config)
>> -  #~(map (lambda (xdg-base-dir-variable)
>> -           ((@@ (guix build utils) mkdir-p)
>> -            (getenv
>> -             xdg-base-dir-variable)))
>> -         '#$(map (lambda (field)
>> -                   (format
>> -                    #f "XDG_~a"
>> -                    (object->snake-case-string
>> -                     (configuration-field-name field) 'upper)))
>> -                 home-xdg-base-directories-configuration-fields)))
>> +  (with-imported-modules '((guix build utils))
>> +    #~(map (lambda (xdg-base-dir-variable)
>> +             ((@ (guix build utils) mkdir-p)
>
> This change doesn’t hurt but it’s apparently unnecessary.

At least it removes the usage of @@ :)

>
>> +    (with-imported-modules `((guix build utils)
>> +                             ,@(source-module-closure
>> +                                '((ice-9 string-fun))))
>
> However this one is incorrect as it would lead (ice-9 string-fun) from
> the host Guile to be imported into the build environment, thereby making
> the result dependent on the version of Guile that is used “outside” (you
> may have seen a warning like “importing (ice-9 string-fun) from the
> host”.)

Why so?  I expected modules closure to be compiled on build side and
provided to activation script via preset load-path.

BTW, I don't see this warning.

>
>> From da332f8272ea3c240fc4e3664051da3b3a4e18c6 Mon Sep 17 00:00:00 2001
>> From: Andrew Tropin <andrew <at> trop.in>
>> Date: Thu, 21 Jul 2022 17:06:24 +0300
>> Subject: [PATCH 2/2] home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation
>>  script.
>>
>> * gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation): Skip mkdir
>> XDG_RUNTIME_DIR in activation script.
>> ---
>>  gnu/home/services/xdg.scm | 19 ++++++++++++-------
>>  1 file changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
>> index 5a41dc4994..541f64a379 100644
>> --- a/gnu/home/services/xdg.scm
>> +++ b/gnu/home/services/xdg.scm
>> @@ -109,13 +109,18 @@ (define (ensure-xdg-base-dirs-on-activation config)
>>    (with-imported-modules '((guix build utils))
>>      #~(map (lambda (xdg-base-dir-variable)
>>               ((@ (guix build utils) mkdir-p)
>> -              (getenv
>> -               xdg-base-dir-variable)))
>> -           '#$(map (lambda (field)
>> -                     (format
>> -                      #f "XDG_~a"
>> -                      (object->snake-case-string
>> -                       (configuration-field-name field) 'upper)))
>> +              (getenv xdg-base-dir-variable)))
>> +           '#$(filter-map
>> +               (lambda (field)
>> +                 (let ((env-var-name
>> +                        (format
>> +                         #f "XDG_~a"
>> +                         (object->snake-case-string
>> +                          (configuration-field-name field) 'upper))))
>> +                   ;; XDG_RUNTIME_DIR shouldn't be created during activation
>> +                   ;; and will be provided by elogind or other service.
>> +                   (and (not (string=? "XDG_RUNTIME_DIR" env-var-name))
>> +                        env-var-name)))
>>                     home-xdg-base-directories-configuration-fields))))
>>  
>>  (define (last-extension-or-cfg config extensions)
>
> I tweaked that accordingly (patch attached), but that leads to a test
> failure in ‘tests/guix-home.sh’ because there’s a warning about
> XDG_RUNTIME_DIR not existing that goes to standard output of ‘guix home
> container’:
>
> --8<---------------cut here---------------start------------->8---
> + guix home container home.scm -- false
> XDG_RUNTIME_DIR doesn't exists, on-first-login script
> won't execute anything.  You can check if xdg runtime directory exists,
> XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
> script by running '$HOME/.guix-home/on-first-login'++ guix home container home.scm -- echo '$HOME'
> guix home: warning: only 4.1 GiB of free space available on /gnu/store
> hint: Consider deleting old profile generations and collecting garbage, along
> these lines:
>
>      guix gc --delete-generations=1m
>
> + test 'XDG_RUNTIME_DIR doesn'\''t exists, on-first-login script
> won'\''t execute anything.  You can check if xdg runtime directory exists,
> XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
> script by running '\''$HOME/.guix-home/on-first-login'\''/home/ludo' = /home/ludo
> --8<---------------cut here---------------end--------------->8---
>
> Thoughts?

Hm, I tried with both your and my patches, but I don't get a test fail.

--8<---------------cut here---------------start------------->8---
make check TESTS="tests/guix-home.sh"
make  check-recursive
make[1]: Entering directory '/home/bob/work/gnu/guix'
Making check in po/guix
make[2]: Entering directory '/home/bob/work/gnu/guix/po/guix'
make[2]: Nothing to be done for 'check'.
make[2]: Leaving directory '/home/bob/work/gnu/guix/po/guix'
Making check in po/packages
make[2]: Entering directory '/home/bob/work/gnu/guix/po/packages'
make[2]: Nothing to be done for 'check'.
make[2]: Leaving directory '/home/bob/work/gnu/guix/po/packages'
make[2]: Entering directory '/home/bob/work/gnu/guix'
Compiling Scheme modules...
Compiling Scheme modules...
Compiling Scheme modules...
Compiling Scheme modules...
make  check-TESTS check-local
make[3]: Entering directory '/home/bob/work/gnu/guix'
make[4]: Entering directory '/home/bob/work/gnu/guix'
PASS: tests/guix-home.sh
============================================================================
Testsuite summary for GNU Guix 1.3.0.22216-446db
============================================================================
# TOTAL: 1
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
make[4]: Leaving directory '/home/bob/work/gnu/guix'
make[3]: Nothing to be done for 'check-local'.
make[3]: Leaving directory '/home/bob/work/gnu/guix'
make[2]: Leaving directory '/home/bob/work/gnu/guix'
make[1]: Leaving directory '/home/bob/work/gnu/guix'

Compilation finished at Mon Aug  1 15:42:20
--8<---------------cut here---------------end--------------->8---


The same with guix home container.

--8<---------------cut here---------------start------------->8---
guix home container ~/tmp/he.scm -- false
WARNING: (guile-user): imported module (guix build utils) overrides core binding `delete'
Symlinking /home/bob/.profile -> /gnu/store/dann7r1095xll0kji5yl0ql07096rc8j-shell-profile... done
Symlinking /home/bob/.bash_profile -> /gnu/store/q0i9j1fbxwdr7sqin1hi16zhir8b4qwd-bash_profile... done
Symlinking /home/bob/.bashrc -> /gnu/store/0hblljbzbbrbawhcv2hlz14narb78s2m-bashrc... done
Symlinking /home/bob/.config/fontconfig/fonts.conf -> /gnu/store/4261pxafny0g2myhh9yj1771ry7k05lc-fonts.conf... done
 done
Finished updating symlinks.

Comparing /gnu/store/non-existing-generation/profile/share/fonts and
          /gnu/store/f2bc4zy8hqv3in72yg4kxdxppigfafn1-home/profile/share/fonts... done (same)
Evaluating on-change gexps.

On-change gexps evaluation finished.
--8<---------------cut here---------------end--------------->8---

-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#56758; Package guix-patches. (Mon, 01 Aug 2022 14:11:01 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 56758 <at> debbugs.gnu.org
Subject: Re: bug#56758: [PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR
Date: Mon, 01 Aug 2022 17:09:59 +0300
[Message part 1 (text/plain, inline)]
On 2022-08-01 15:49, Andrew Tropin wrote:

> On 2022-08-01 12:08, Ludovic Courtès wrote:
>
>> Hi,
>>
>> Andrew Tropin <andrew <at> trop.in> skribis:
>>
>>> From d08ed8de3ead1a704a96e0e6673dffb62f859597 Mon Sep 17 00:00:00 2001
>>> From: Andrew Tropin <andrew <at> trop.in>
>>> Date: Thu, 21 Jul 2022 15:24:32 +0300
>>> Subject: [PATCH 1/2] home: xdg: Use closures in activation scripts.
>>>
>>> * gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation,
>>> home-xdg-user-directories-files-service): Use closures in activation scripts.
>>
>> [...]
>>
>>>  (define (ensure-xdg-base-dirs-on-activation config)
>>> -  #~(map (lambda (xdg-base-dir-variable)
>>> -           ((@@ (guix build utils) mkdir-p)
>>> -            (getenv
>>> -             xdg-base-dir-variable)))
>>> -         '#$(map (lambda (field)
>>> -                   (format
>>> -                    #f "XDG_~a"
>>> -                    (object->snake-case-string
>>> -                     (configuration-field-name field) 'upper)))
>>> -                 home-xdg-base-directories-configuration-fields)))
>>> +  (with-imported-modules '((guix build utils))
>>> +    #~(map (lambda (xdg-base-dir-variable)
>>> +             ((@ (guix build utils) mkdir-p)
>>
>> This change doesn’t hurt but it’s apparently unnecessary.
>
> At least it removes the usage of @@ :)
>
>>
>>> +    (with-imported-modules `((guix build utils)
>>> +                             ,@(source-module-closure
>>> +                                '((ice-9 string-fun))))
>>
>> However this one is incorrect as it would lead (ice-9 string-fun) from
>> the host Guile to be imported into the build environment, thereby making
>> the result dependent on the version of Guile that is used “outside” (you
>> may have seen a warning like “importing (ice-9 string-fun) from the
>> host”.)
>
> Why so?  I expected modules closure to be compiled on build side and
> provided to activation script via preset load-path.
>
> BTW, I don't see this warning.
>
>>
>>> From da332f8272ea3c240fc4e3664051da3b3a4e18c6 Mon Sep 17 00:00:00 2001
>>> From: Andrew Tropin <andrew <at> trop.in>
>>> Date: Thu, 21 Jul 2022 17:06:24 +0300
>>> Subject: [PATCH 2/2] home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation
>>>  script.
>>>
>>> * gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation): Skip mkdir
>>> XDG_RUNTIME_DIR in activation script.
>>> ---
>>>  gnu/home/services/xdg.scm | 19 ++++++++++++-------
>>>  1 file changed, 12 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
>>> index 5a41dc4994..541f64a379 100644
>>> --- a/gnu/home/services/xdg.scm
>>> +++ b/gnu/home/services/xdg.scm
>>> @@ -109,13 +109,18 @@ (define (ensure-xdg-base-dirs-on-activation config)
>>>    (with-imported-modules '((guix build utils))
>>>      #~(map (lambda (xdg-base-dir-variable)
>>>               ((@ (guix build utils) mkdir-p)
>>> -              (getenv
>>> -               xdg-base-dir-variable)))
>>> -           '#$(map (lambda (field)
>>> -                     (format
>>> -                      #f "XDG_~a"
>>> -                      (object->snake-case-string
>>> -                       (configuration-field-name field) 'upper)))
>>> +              (getenv xdg-base-dir-variable)))
>>> +           '#$(filter-map
>>> +               (lambda (field)
>>> +                 (let ((env-var-name
>>> +                        (format
>>> +                         #f "XDG_~a"
>>> +                         (object->snake-case-string
>>> +                          (configuration-field-name field) 'upper))))
>>> +                   ;; XDG_RUNTIME_DIR shouldn't be created during activation
>>> +                   ;; and will be provided by elogind or other service.
>>> +                   (and (not (string=? "XDG_RUNTIME_DIR" env-var-name))
>>> +                        env-var-name)))
>>>                     home-xdg-base-directories-configuration-fields))))
>>>  
>>>  (define (last-extension-or-cfg config extensions)
>>
>> I tweaked that accordingly (patch attached), but that leads to a test
>> failure in ‘tests/guix-home.sh’ because there’s a warning about
>> XDG_RUNTIME_DIR not existing that goes to standard output of ‘guix home
>> container’:
>>
>> --8<---------------cut here---------------start------------->8---
>> + guix home container home.scm -- false
>> XDG_RUNTIME_DIR doesn't exists, on-first-login script
>> won't execute anything.  You can check if xdg runtime directory exists,
>> XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
>> script by running '$HOME/.guix-home/on-first-login'++ guix home container home.scm -- echo '$HOME'
>> guix home: warning: only 4.1 GiB of free space available on /gnu/store
>> hint: Consider deleting old profile generations and collecting garbage, along
>> these lines:
>>
>>      guix gc --delete-generations=1m
>>
>> + test 'XDG_RUNTIME_DIR doesn'\''t exists, on-first-login script
>> won'\''t execute anything.  You can check if xdg runtime directory exists,
>> XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
>> script by running '\''$HOME/.guix-home/on-first-login'\''/home/ludo' = /home/ludo
>> --8<---------------cut here---------------end--------------->8---
>>
>> Thoughts?
>
> Hm, I tried with both your and my patches, but I don't get a test fail.
>
> --8<---------------cut here---------------start------------->8---
> make check TESTS="tests/guix-home.sh"
> make  check-recursive
> make[1]: Entering directory '/home/bob/work/gnu/guix'
> Making check in po/guix
> make[2]: Entering directory '/home/bob/work/gnu/guix/po/guix'
> make[2]: Nothing to be done for 'check'.
> make[2]: Leaving directory '/home/bob/work/gnu/guix/po/guix'
> Making check in po/packages
> make[2]: Entering directory '/home/bob/work/gnu/guix/po/packages'
> make[2]: Nothing to be done for 'check'.
> make[2]: Leaving directory '/home/bob/work/gnu/guix/po/packages'
> make[2]: Entering directory '/home/bob/work/gnu/guix'
> Compiling Scheme modules...
> Compiling Scheme modules...
> Compiling Scheme modules...
> Compiling Scheme modules...
> make  check-TESTS check-local
> make[3]: Entering directory '/home/bob/work/gnu/guix'
> make[4]: Entering directory '/home/bob/work/gnu/guix'
> PASS: tests/guix-home.sh
> ============================================================================
> Testsuite summary for GNU Guix 1.3.0.22216-446db
> ============================================================================
> # TOTAL: 1
> # PASS:  1
> # SKIP:  0
> # XFAIL: 0
> # FAIL:  0
> # XPASS: 0
> # ERROR: 0
> ============================================================================
> make[4]: Leaving directory '/home/bob/work/gnu/guix'
> make[3]: Nothing to be done for 'check-local'.
> make[3]: Leaving directory '/home/bob/work/gnu/guix'
> make[2]: Leaving directory '/home/bob/work/gnu/guix'
> make[1]: Leaving directory '/home/bob/work/gnu/guix'
>
> Compilation finished at Mon Aug  1 15:42:20
> --8<---------------cut here---------------end--------------->8---
>
>
> The same with guix home container.
>
> --8<---------------cut here---------------start------------->8---
> guix home container ~/tmp/he.scm -- false
> WARNING: (guile-user): imported module (guix build utils) overrides core binding `delete'
> Symlinking /home/bob/.profile -> /gnu/store/dann7r1095xll0kji5yl0ql07096rc8j-shell-profile... done
> Symlinking /home/bob/.bash_profile -> /gnu/store/q0i9j1fbxwdr7sqin1hi16zhir8b4qwd-bash_profile... done
> Symlinking /home/bob/.bashrc -> /gnu/store/0hblljbzbbrbawhcv2hlz14narb78s2m-bashrc... done
> Symlinking /home/bob/.config/fontconfig/fonts.conf -> /gnu/store/4261pxafny0g2myhh9yj1771ry7k05lc-fonts.conf... done
>  done
> Finished updating symlinks.
>
> Comparing /gnu/store/non-existing-generation/profile/share/fonts and
>           /gnu/store/f2bc4zy8hqv3in72yg4kxdxppigfafn1-home/profile/share/fonts... done (same)
> Evaluating on-change gexps.
>
> On-change gexps evaluation finished.
> --8<---------------cut here---------------end--------------->8---

Ok, I found the problem. guix container uses hosts $SHELL variable,
which in my case is zsh and this makes the shell inside container not to
source ~/.profile, so on-first-login isn't executed.

I was able to reproduce test fail and message inside container.

My thoughts:
1. home container in tests must always use bash.
2. Error message should be printed to stderr.
3. Right now I experiment with elogind-less system, trying out seatd and
greetd, and try to figure out when and how process (especially shepherd)
should be started and killed.  I'll share my findings on this later, but
it's very likely that we will get rid of on-first-login at all (or at
least won't source it automatically by login shell in all or some the
cases).

Do you want me to prepare patch for #2?

-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#56758; Package guix-patches. (Mon, 01 Aug 2022 22:13:01 GMT) Full text and rfc822 format available.

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

From: Maxime Devos <maximedevos <at> telenet.be>
To: Andrew Tropin <andrew <at> trop.in>, Ludovic Courtès
 <ludo <at> gnu.org>
Cc: 56758 <at> debbugs.gnu.org
Subject: Re: [bug#56758] [PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR
Date: Tue, 2 Aug 2022 00:12:19 +0200
[Message part 1 (text/plain, inline)]
On 01-08-2022 14:49, Andrew Tropin wrote:

>> However this one is incorrect as it would lead (ice-9 string-fun) from
>> the host Guile to be imported into the build environment, thereby making
>> the result dependent on the version of Guile that is used “outside” (you
>> may have seen a warning like “importing (ice-9 string-fun) from the
>> host”.)
> Why so?  I expected modules closure to be compiled on build side and
> provided to activation script via preset load-path.

This is true, and this causes the problem that Ludo' describes:

Two problems:

* (ice-9 string-fun) is part of Guile, so compiling it again is 
pointless (and potentially harmful, if ice-9/string-fun.scm contains a 
reference /gnu/store/.../some-target-specific-library.so)

* a form of non-determinism and non-reproducibility -- you are copying 
the modules from the Guile that 'guix' is run with, instead of always 
using the modules from the Guile that is defined inside Guix.

* additionally, maybe the inside-Guix and what-Guix-is-compiled-with 
Guile expect different behaviour of (ice-9 string-fun), causing bugs

Greetings,
Maxime.


[Message part 2 (text/html, inline)]
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#56758; Package guix-patches. (Tue, 02 Aug 2022 06:06:02 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 56758 <at> debbugs.gnu.org
Subject: [PATCH v2 0/4] Don't try to mkdir XDG_RUNTIME_DIR
Date: Tue, 2 Aug 2022 09:00:17 +0300
[Message part 1 (text/plain, inline)]
Changes since v1:
- Don't use modules closure.
- Use string-append instead of format.
- Use warning instead of display.
- Hardcode SHELL=bash for home tests inside container.

Andrew Tropin (4):
  home: xdg: Use single @ intsead of @@.
  home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation script.
  home: Use warning instead of display.
  tests: Make tests inside container reproducible.

 gnu/home/services.scm     |  8 +++++---
 gnu/home/services/xdg.scm | 25 ++++++++++++++++---------
 tests/guix-home.sh        |  5 ++++-
 3 files changed, 25 insertions(+), 13 deletions(-)

-- 
2.37.0

[v2-0001-home-xdg-Use-single-intsead-of.patch (text/x-patch, inline)]
From e4b582654903d2cc227f8824df7873bf75f8b100 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Thu, 21 Jul 2022 15:24:32 +0300
Subject: [PATCH v2 1/4] home: xdg: Use single @ intsead of @@.

* gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation,
home-xdg-user-directories-files-service): Use single @ intsead of @@.
---
 gnu/home/services/xdg.scm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index 71c028c788..04cf9d0aed 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -23,6 +23,7 @@ (define-module (gnu home services xdg)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu home services utils)
   #:use-module (guix gexp)
+  #:use-module (guix modules)
   #:use-module (guix records)
   #:use-module (guix i18n)
   #:use-module (guix diagnostics)
@@ -106,7 +107,7 @@ (define (home-xdg-base-directories-environment-variables-service config)
 
 (define (ensure-xdg-base-dirs-on-activation config)
   #~(map (lambda (xdg-base-dir-variable)
-           ((@@ (guix build utils) mkdir-p)
+           ((@ (guix build utils) mkdir-p)
             (getenv
              xdg-base-dir-variable)))
          '#$(map (lambda (field)
@@ -207,8 +208,8 @@ (define (home-xdg-user-directories-activation-service config)
                    home-xdg-user-directories-configuration-fields)))
     #~(let ((ensure-dir
              (lambda (path)
-               (mkdir-p
-                ((@@ (ice-9 string-fun) string-replace-substring)
+               ((@ (guix build utils) mkdir-p)
+                ((@ (ice-9 string-fun) string-replace-substring)
                  path "$HOME" (getenv "HOME"))))))
         (display "Creating XDG user directories...")
         (map ensure-dir '#$dirs)
-- 
2.37.0

[v2-0002-home-xdg-Skip-mkdir-XDG_RUNTIME_DIR-in-activation.patch (text/x-patch, inline)]
From 35125e96522c0539308f09a151ff67571a865900 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Tue, 2 Aug 2022 08:00:21 +0300
Subject: [PATCH v2 2/4] home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation
 script.

* gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation): Skip mkdir
XDG_RUNTIME_DIR in activation script.
---
 gnu/home/services/xdg.scm | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index 04cf9d0aed..63c6041cd4 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -110,12 +110,18 @@ (define (ensure-xdg-base-dirs-on-activation config)
            ((@ (guix build utils) mkdir-p)
             (getenv
              xdg-base-dir-variable)))
-         '#$(map (lambda (field)
-                   (format
-                    #f "XDG_~a"
-                    (object->snake-case-string
-                     (configuration-field-name field) 'upper)))
-                 home-xdg-base-directories-configuration-fields)))
+         '#$(filter-map
+             (lambda (field)
+               (let ((variable
+                      (string-append
+                       "XDG_"
+                       (object->snake-case-string
+                        (configuration-field-name field) 'upper))))
+                 ;; XDG_RUNTIME_DIR shouldn't be created during activation
+                 ;; and will be provided by elogind or other service.
+                 (and (not (string=? "XDG_RUNTIME_DIR" variable))
+                      variable)))
+             home-xdg-base-directories-configuration-fields)))
 
 (define (last-extension-or-cfg config extensions)
   "Picks configuration value from last provided extension.  If there
-- 
2.37.0

[v2-0003-home-Use-warning-instead-of-display.patch (text/x-patch, inline)]
From b67b8217830ee6e1afdf7532a961835fd77a5519 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Tue, 2 Aug 2022 08:20:38 +0300
Subject: [PATCH v2 3/4] home: Use warning instead of display.

* gnu/home/services/xdg.scm (compute-on-first-login-script): Use warning
instead of display.
---
 gnu/home/services.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gnu/home/services.scm b/gnu/home/services.scm
index 6fbc91fab2..4376422014 100644
--- a/gnu/home/services.scm
+++ b/gnu/home/services.scm
@@ -368,9 +368,11 @@ (define %initialize-gettext
 (define (compute-on-first-login-script _ gexps)
   (program-file
    "on-first-login"
-   (with-imported-modules (source-module-closure '((guix i18n)))
+   (with-imported-modules (source-module-closure '((guix i18n)
+                                                   (guix diagnostics)))
      #~(begin
-       (use-modules (guix i18n))
+         (use-modules (guix i18n)
+                      (guix diagnostics))
        #$%initialize-gettext
 
        (let* ((xdg-runtime-dir (or (getenv "XDG_RUNTIME_DIR")
@@ -387,7 +389,7 @@ (define (compute-on-first-login-script _ gexps)
                (begin #$@gexps (touch flag-file-path)))
              ;; TRANSLATORS: 'on-first-login' is the name of a service and
              ;; shouldn't be translated
-             (display (G_ "XDG_RUNTIME_DIR doesn't exists, on-first-login script
+             (warning (G_ "XDG_RUNTIME_DIR doesn't exists, on-first-login script
 won't execute anything.  You can check if xdg runtime directory exists,
 XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
 script by running '$HOME/.guix-home/on-first-login'"))))))))
-- 
2.37.0

[v2-0004-tests-Make-tests-inside-container-reproducible.patch (text/x-patch, inline)]
From 4c7084308338aa3eaedb3097b43117c421c39580 Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew <at> trop.in>
Date: Tue, 2 Aug 2022 08:40:31 +0300
Subject: [PATCH v2 4/4] tests: Make tests inside container reproducible.

* tests/guix-home.sh: Make tests inside container reproducible.
---
 tests/guix-home.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/guix-home.sh b/tests/guix-home.sh
index 1d1acbfd6e..d5e2dadbb5 100644
--- a/tests/guix-home.sh
+++ b/tests/guix-home.sh
@@ -107,7 +107,10 @@ EOF
 
     if container_supported
     then
-	# Run the home in a container.
+	# Run the home in a container.  Always use bash inside container for
+        # reproducibility of the tests.
+        # TODO: Make container independent from external environment variables.
+        SHELL=bash
 	guix home container home.scm -- true
 	! guix home container home.scm -- false
 	test "$(guix home container home.scm -- echo '$HOME')" = "$HOME"
-- 
2.37.0

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

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Fri, 05 Aug 2022 09:07:01 GMT) Full text and rfc822 format available.

Notification sent to Andrew Tropin <andrew <at> trop.in>:
bug acknowledged by developer. (Fri, 05 Aug 2022 09:07:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Tropin <andrew <at> trop.in>
Cc: 56758-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2 0/4] Don't try to mkdir XDG_RUNTIME_DIR
Date: Fri, 05 Aug 2022 11:06:07 +0200
Hi Andrew,

Andrew Tropin <andrew <at> trop.in> skribis:

>   home: xdg: Use single @ intsead of @@.
>   home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation script.
>   home: Use warning instead of display.
>   tests: Make tests inside container reproducible.

Applied, thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#56758; Package guix-patches. (Fri, 05 Aug 2022 15:04:01 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 56758-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2 0/4] Don't try to mkdir XDG_RUNTIME_DIR
Date: Fri, 05 Aug 2022 18:03:25 +0300
[Message part 1 (text/plain, inline)]
On 2022-08-05 11:06, Ludovic Courtès wrote:

> Hi Andrew,
>
> Andrew Tropin <andrew <at> trop.in> skribis:
>
>>   home: xdg: Use single @ intsead of @@.
>>   home: xdg: Skip mkdir XDG_RUNTIME_DIR in activation script.
>>   home: Use warning instead of display.
>>   tests: Make tests inside container reproducible.
>
> Applied, thanks!
>
> Ludo’.

Thank you very much!)

-- 
Best regards,
Andrew Tropin
[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. (Sat, 03 Sep 2022 11:24:07 GMT) Full text and rfc822 format available.

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

Previous Next


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