unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Tropin <andrew@trop.in>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 56758@debbugs.gnu.org
Subject: [bug#56758] [PATCH v2 0/4] Don't try to mkdir XDG_RUNTIME_DIR
Date: Tue, 2 Aug 2022 09:00:17 +0300	[thread overview]
Message-ID: <875yjbi3ji.fsf@trop.in> (raw)
In-Reply-To: <87r120z36g.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 614 bytes --]


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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: v2-0001-home-xdg-Use-single-intsead-of.patch --]
[-- Type: text/x-patch, Size: 1883 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: v2-0002-home-xdg-Skip-mkdir-XDG_RUNTIME_DIR-in-activation.patch --]
[-- Type: text/x-patch, Size: 1841 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: v2-0003-home-Use-warning-instead-of-display.patch --]
[-- Type: text/x-patch, Size: 1776 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.5: v2-0004-tests-Make-tests-inside-container-reproducible.patch --]
[-- Type: text/x-patch, Size: 1005 bytes --]

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


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

  parent reply	other threads:[~2022-08-02  6:06 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
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   ` Andrew Tropin [this message]
2022-08-05  9:06     ` bug#56758: [PATCH v2 0/4] " 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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=875yjbi3ji.fsf@trop.in \
    --to=andrew@trop.in \
    --cc=56758@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /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 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).