all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Andrew Tropin <andrew@trop.in>
Cc: 56758@debbugs.gnu.org
Subject: [bug#56758] [PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR
Date: Mon, 01 Aug 2022 12:08:39 +0200	[thread overview]
Message-ID: <87r120z36g.fsf@gnu.org> (raw)
In-Reply-To: <87wnc1zfrh.fsf@trop.in> (Andrew Tropin's message of "Mon, 25 Jul 2022 12:43:47 +0300")

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

Hi,

Andrew Tropin <andrew@trop.in> skribis:

> From d08ed8de3ead1a704a96e0e6673dffb62f859597 Mon Sep 17 00:00:00 2001
> From: Andrew Tropin <andrew@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@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’.


[-- Attachment #2: the modified patch --]
[-- Type: text/x-patch, Size: 1978 bytes --]

From f6ff733aaaea7e5b8277b65430e7dc090dffa9aa Mon Sep 17 00:00:00 2001
From: Andrew Tropin <andrew@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@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


  reply	other threads:[~2022-08-01 10:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25  9:43 [bug#56758] [PATCH 0/2] Don't try to mkdir XDG_RUNTIME_DIR Andrew Tropin
2022-08-01 10:08 ` Ludovic Courtès [this message]
2022-08-01 12:49   ` Andrew Tropin
2022-08-01 14:09     ` Andrew Tropin
2022-08-01 22:12     ` Maxime Devos
2022-08-02  6:00   ` [bug#56758] [PATCH v2 0/4] " Andrew Tropin
2022-08-05  9:06     ` bug#56758: " Ludovic Courtès
2022-08-05 15:03       ` [bug#56758] " Andrew Tropin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r120z36g.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=56758@debbugs.gnu.org \
    --cc=andrew@trop.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.