Subject: [bug#68009] home-xdg-user-directories-service-type: Extend it with home-environment-variables service

From: [email-masked]
Date: Sun, 24 Dec 2023 18:00:12 +0000

Current home-xdg-user-directories-service-type creates a 
~/.config/user-dirs.dirs which some non posix-compliant shells like fish 
aren't able to read, this makes necessary to use some external tool like 
fish-foreign-env, but this solution makes fish startup times really 
slower in the case fish sources it in a non-login shell.
After thinking about it for a bit, I guess it would be proper if guix 
itself was responsible for setting these environment variables. This 
could avoid the need for users of other non-posix shells to make their 
own custom workarounds for this problem.

From f915f08c166ffdeaadfdd2438a66d8d0d3401629 Mon Sep 17 00:00:00 2001
From: Luis Guilherme Coelho <[email-masked]>
Date: Sun, 24 Dec 2023 14:43:38 -0300
Subject: [PATCH] home-xdg-user-directories-service-type: Extend it with
 home-environment-service-type

---
 gnu/home/services/xdg.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index 958772696b..e14870df05 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2021, 2022 Andrew Tropin <[email-masked]>
 ;;; Copyright © 2021 Xinglu Chen <[email-masked]>
 ;;; Copyright © 2023 Bruno Victal <[email-masked]>
+;;; Copyright © 2023 Luis Guilherme Coelho <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -256,12 +257,27 @@ (define (home-xdg-user-directories-activation-service config)
         (map ensure-dir '#$dirs)
         (display " done\n"))))
 
+(define (home-xdg-user-directories-environment-variables-service config)
+  (match-record config <home-xdg-user-directories-configuration>
+    (desktop documents music pictures videos publicshare download templates)
+    `(("XDG_DESKTOP_DIR" . ,desktop)
+      ("XDG_DOCUMENTS_DIR" . ,documents)
+      ("XDG_DOWNLOAD_DIR" . ,download)
+      ("XDG_MUSIC_DIR" . ,music)
+      ("XDG_PICTURES_DIR" . ,pictures)
+      ("XDG_PUBLICSHARE_DIR" . ,publicshare)
+      ("XDG_TEMPLATES_DIR" . ,templates)
+      ("XDG_VIDEOS_DIR" . ,videos))))
+
 (define home-xdg-user-directories-service-type
   (service-type (name 'home-xdg-user-directories)
                 (extensions
                  (list (service-extension
                         home-xdg-configuration-files-service-type
                         home-xdg-user-directories-files-service)
+                       (service-extension
+                        home-environment-variables-service-type
+                        home-xdg-user-directories-environment-variables-service)
                        (service-extension
                         home-activation-service-type
                         home-xdg-user-directories-activation-service)))
-- 
2.41.0