[PATCH 0/2] Respect XDG Base Directory Specification 0.8.

  • Open
  • quality assurance status badge
Details
4 participants
  • Andrew Tropin
  • Bruno Victal
  • (
  • Philip McGrath
Owner
unassigned
Submitted by
Bruno Victal
Severity
normal
B
B
Bruno Victal wrote on 5 Mar 16:16 +0100
(address . guix-patches@gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
cover.1678029159.git.mirai@makinata.eu
Note: Needs to be tested.

Bruno Victal (2):
home: services: xdg-base-directories: Set correct value for
XDG_STATE_HOME.
home: services: xdg-base-directories: Deprecate XDG_LOG_HOME.

gnu/home/services/desktop.scm | 4 +--
gnu/home/services/mcron.scm | 4 +--
gnu/home/services/pm.scm | 6 ++--
gnu/home/services/shepherd.scm | 4 +--
gnu/home/services/xdg.scm | 52 +++++++++++++++++++++++-----------
5 files changed, 44 insertions(+), 26 deletions(-)


base-commit: d92ec2f2812c76b23aab778e26708cf353542ae9
--
2.39.1
B
B
Bruno Victal wrote on 5 Mar 16:19 +0100
[PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME.
(address . 61982@debbugs.gnu.org)
3005f8a58ec5afc447f2baf40958956bd0d16099.1678029530.git.mirai@makinata.eu
XDG Base Directory Specification 0.8 officially introduces the
XDG_STATE_HOME environment variable.


* gnu/home/services/xdg.scm
(home-xdg-base-directories-configuration)[state-home]: Set default value according to spec.
Update field documentation.
(home-xdg-base-directories-service-type): Update service description.
---
gnu/home/services/xdg.scm | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

Toggle diff (44 lines)
diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index 3007493f85..ac557b4c3d 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -104,11 +104,11 @@ (define-configuration home-xdg-base-directories-configuration
Specification, but helps to make implementation of home services more
consistent.")
(state-home
- (path "$HOME/.local/var/lib")
- "Base directory for programs to store state files, like databases,
-analogus to @file{/var/lib}, but for user. It is not a part of XDG
-Base Directory Specification, but helps to make implementation of home
-services more consistent."))
+ (path "$HOME/.local/state")
+ "Base directory for programs to store state data that should persist
+between (application) restarts, such as logs, but are not important or
+portable enough to the user to warrant storing them in
+@env{XDG_DATA_HOME}."))
(define (home-xdg-base-directories-environment-variables-service config)
(map
@@ -158,12 +158,12 @@ (define home-xdg-base-directories-service-type
(compose identity)
(extend last-extension-or-cfg)
(description "Configure XDG base directories. This
-service introduces two additional variables @env{XDG_STATE_HOME},
-@env{XDG_LOG_HOME}. They are not a part of XDG specification, at
-least yet, but are convenient to have, it improves the consistency
-between different home services. The services of this service-type is
-instantiated by default, to provide non-default value, extend the
-service-type (using @code{simple-service} for example).")))
+service introduces an additional @env{XDG_LOG_HOME} variable. It's not
+a part of XDG specification, at least yet, but are convenient to have,
+it improves the consistency between different home services. The
+services of this service-type is instantiated by default, to provide
+non-default value, extend the service-type (using @code{simple-service}
+for example).")))
(define (generate-home-xdg-base-directories-documentation)
(generate-documentation

base-commit: d92ec2f2812c76b23aab778e26708cf353542ae9
--
2.39.1
B
B
Bruno Victal wrote on 5 Mar 16:19 +0100
[PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME.
(address . 61982@debbugs.gnu.org)
0a0764da3fa04f9a02f37a7960a0c9608782854d.1678029530.git.mirai@makinata.eu
XDG_LOG_HOME is non-standard and log files should go to XDG_STATE_HOME
according to the XDG Base Directory Specification.


* gnu/home/services/desktop.scm (home-dbus-shepherd-services): Log to XDG_STATE_HOME.
* gnu/home/services/mcron.scm (home-mcron-shepherd-services): Ditto.
* gnu/home/services/pm.scm (home-batsignal-shepherd-services): Ditto.
* gnu/home/services/shepherd.scm (launch-shepherd-gexp): Ditto.
* gnu/home/services/xdg.scm
(home-xdg-base-directories-configuration)[log-home]: Deprecate and unset default value.
(home-xdg-base-directories-environment-variables-service)
(ensure-xdg-base-dirs-on-activation): Handle field deprecation.
(home-xdg-base-directories-service-type): Update description.
---
gnu/home/services/desktop.scm | 4 ++--
gnu/home/services/mcron.scm | 4 ++--
gnu/home/services/pm.scm | 6 +++---
gnu/home/services/shepherd.scm | 4 ++--
gnu/home/services/xdg.scm | 36 +++++++++++++++++++++++++---------
5 files changed, 36 insertions(+), 18 deletions(-)

Toggle diff (164 lines)
diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
index cb25b03b64..76df7b30a2 100644
--- a/gnu/home/services/desktop.scm
+++ b/gnu/home/services/desktop.scm
@@ -206,8 +206,8 @@ (define (home-dbus-shepherd-services config)
(default-environment-variables))
#:log-file
(format #f "~a/dbus.log"
- (or (getenv "XDG_LOG_HOME")
- (format #f "~a/.local/var/log"
+ (or (getenv "XDG_STATE_HOME")
+ (format #f "~a/.local/state"
(getenv "HOME"))))))
(stop #~(make-kill-destructor)))))
diff --git a/gnu/home/services/mcron.scm b/gnu/home/services/mcron.scm
index 5f35bfe054..69c7f9faa6 100644
--- a/gnu/home/services/mcron.scm
+++ b/gnu/home/services/mcron.scm
@@ -99,8 +99,8 @@ (define (home-mcron-shepherd-services config)
#~())
#$@files)
#:log-file (string-append
- (or (getenv "XDG_LOG_HOME")
- (format #f "~a/.local/var/log"
+ (or (getenv "XDG_STATE_HOME")
+ (format #f "~a/.local/state"
(getenv "HOME")))
"/mcron.log")))
(stop #~(make-kill-destructor))
diff --git a/gnu/home/services/pm.scm b/gnu/home/services/pm.scm
index 5f09941827..274ab2303c 100644
--- a/gnu/home/services/pm.scm
+++ b/gnu/home/services/pm.scm
@@ -128,9 +128,9 @@ (define (home-batsignal-shepherd-services config)
(list "-i")
(list)))
#:log-file (string-append
- (or (getenv "XDG_LOG_HOME")
- (format #f "~a/.local/var/log"
- (getenv "HOME")))
+ (or (getenv "XDG_STATE_HOME")
+ (format #f "~a/.local/state"
+ (getenv "HOME")))
"/batsignal.log")))
(stop #~(make-kill-destructor))))))
diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm
index 1a70a220f0..825cf66f05 100644
--- a/gnu/home/services/shepherd.scm
+++ b/gnu/home/services/shepherd.scm
@@ -108,8 +108,8 @@ (define (launch-shepherd-gexp config)
(or (getenv "XDG_RUNTIME_DIR")
(format #f "/run/user/~a" (getuid)))
"/shepherd/socket"))
- (let ((log-dir (or (getenv "XDG_LOG_HOME")
- (format #f "~a/.local/var/log"
+ (let ((log-dir (or (getenv "XDG_STATE_HOME")
+ (format #f "~a/.local/state"
(getenv "HOME")))))
;; TODO: Remove it, 0.9.2 creates it automatically?
((@ (guix build utils) mkdir-p) log-dir)
diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
index ac557b4c3d..958772696b 100644
--- a/gnu/home/services/xdg.scm
+++ b/gnu/home/services/xdg.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021, 2022 Andrew Tropin <andrew@trop.in>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -22,6 +23,7 @@ (define-module (gnu home services xdg)
#:use-module (gnu home services)
#:use-module (gnu packages freedesktop)
#:use-module (gnu home services utils)
+ #:use-module (guix deprecation)
#:use-module (guix gexp)
#:use-module (guix modules)
#:use-module (guix records)
@@ -39,7 +41,7 @@ (define-module (gnu home services xdg)
home-xdg-base-directories-configuration-config-home
home-xdg-base-directories-configuration-data-home
home-xdg-base-directories-configuration-state-home
- home-xdg-base-directories-configuration-log-home
+ home-xdg-base-directories-configuration-log-home ; deprecated
home-xdg-base-directories-configuration-runtime-dir
home-xdg-user-directories-service-type
@@ -77,6 +79,7 @@ (define-module (gnu home services xdg)
(define (serialize-path field-name val) "")
(define path? string?)
+(define-maybe path)
(define-configuration home-xdg-base-directories-configuration
(cache-home
@@ -97,12 +100,17 @@ (define-configuration home-xdg-base-directories-configuration
(path "${XDG_RUNTIME_DIR:-/run/user/$UID}")
"Base directory for programs to store user-specific runtime files,
like sockets.")
+ ;; TODO: deprecated field, use $XDG_STATE_HOME(/log) instead.
(log-home
- (path "$HOME/.local/var/log")
+ maybe-path
"Base directory for programs to store log files, analogus to
@file{/var/log}, but for user. It is not a part of XDG Base Directory
Specification, but helps to make implementation of home services more
-consistent.")
+consistent."
+ (lambda (field-name val)
+ (when (maybe-value-set? val)
+ (warn-about-deprecation field-name #f #:replacement 'state-home))
+ (serialize-path field-name val)))
(state-home
(path "$HOME/.local/state")
"Base directory for programs to store state data that should persist
@@ -117,7 +125,13 @@ (define (home-xdg-base-directories-environment-variables-service config)
#f "XDG_~a"
(object->snake-case-string (configuration-field-name field) 'upper))
((configuration-field-getter field) config)))
- home-xdg-base-directories-configuration-fields))
+ ;; XXX: deprecated field, remove later
+ (if (maybe-value-set?
+ (home-xdg-base-directories-configuration-log-home config))
+ home-xdg-base-directories-configuration-fields
+ (filter-configuration-fields
+ home-xdg-base-directories-configuration-fields
+ '(log-home) #t))))
(define (ensure-xdg-base-dirs-on-activation config)
(with-imported-modules '((guix build utils))
@@ -138,7 +152,14 @@ (define (ensure-xdg-base-dirs-on-activation config)
;; and will be provided by elogind or other service.
(and (not (string=? "XDG_RUNTIME_DIR" variable))
variable)))
- home-xdg-base-directories-configuration-fields)))))
+ ;; XXX: deprecated field, remove later
+ (if (maybe-value-set?
+ (home-xdg-base-directories-configuration-log-home
+ config))
+ home-xdg-base-directories-configuration-fields
+ (filter-configuration-fields
+ home-xdg-base-directories-configuration-fields
+ '(log-home) #t)))))))
(define (last-extension-or-cfg config extensions)
"Picks configuration value from last provided extension. If there
@@ -157,10 +178,7 @@ (define home-xdg-base-directories-service-type
(default-value (home-xdg-base-directories-configuration))
(compose identity)
(extend last-extension-or-cfg)
- (description "Configure XDG base directories. This
-service introduces an additional @env{XDG_LOG_HOME} variable. It's not
-a part of XDG specification, at least yet, but are convenient to have,
-it improves the consistency between different home services. The
+ (description "Configure XDG base directories. The
services of this service-type is instantiated by default, to provide
non-default value, extend the service-type (using @code{simple-service}
for example).")))
--
2.39.1
A
A
Andrew Tropin wrote on 7 Apr 08:43 +0200
Re: [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME.
87lej4w5sp.fsf@trop.in
On 2023-03-05 15:19, Bruno Victal wrote:

Toggle quote (28 lines)
> XDG Base Directory Specification 0.8 officially introduces the
> XDG_STATE_HOME environment variable.
>
> Fixes <https://issues.guix.gnu.org/issue/61809>.
>
> * gnu/home/services/xdg.scm
> (home-xdg-base-directories-configuration)[state-home]: Set default value according to spec.
> Update field documentation.
> (home-xdg-base-directories-service-type): Update service description.
> ---
> gnu/home/services/xdg.scm | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
> index 3007493f85..ac557b4c3d 100644
> --- a/gnu/home/services/xdg.scm
> +++ b/gnu/home/services/xdg.scm
> @@ -104,11 +104,11 @@ (define-configuration home-xdg-base-directories-configuration
> Specification, but helps to make implementation of home services more
> consistent.")
> (state-home
> - (path "$HOME/.local/var/lib")
> - "Base directory for programs to store state files, like databases,
> -analogus to @file{/var/lib}, but for user. It is not a part of XDG
> -Base Directory Specification, but helps to make implementation of home
> -services more consistent."))
> + (path "$HOME/.local/state")

Ironically enough, it was my first idea for default value :)

Toggle quote (29 lines)
> + "Base directory for programs to store state data that should persist
> +between (application) restarts, such as logs, but are not important or
> +portable enough to the user to warrant storing them in
> +@env{XDG_DATA_HOME}."))
>
> (define (home-xdg-base-directories-environment-variables-service config)
> (map
> @@ -158,12 +158,12 @@ (define home-xdg-base-directories-service-type
> (compose identity)
> (extend last-extension-or-cfg)
> (description "Configure XDG base directories. This
> -service introduces two additional variables @env{XDG_STATE_HOME},
> -@env{XDG_LOG_HOME}. They are not a part of XDG specification, at
> -least yet, but are convenient to have, it improves the consistency
> -between different home services. The services of this service-type is
> -instantiated by default, to provide non-default value, extend the
> -service-type (using @code{simple-service} for example).")))
> +service introduces an additional @env{XDG_LOG_HOME} variable. It's not
> +a part of XDG specification, at least yet, but are convenient to have,
> +it improves the consistency between different home services. The
> +services of this service-type is instantiated by default, to provide
> +non-default value, extend the service-type (using @code{simple-service}
> +for example).")))
>
> (define (generate-home-xdg-base-directories-documentation)
> (generate-documentation
>
> base-commit: d92ec2f2812c76b23aab778e26708cf353542ae9

Applied and pushed the first patch as
5c893787be78a79433fe1343f5b70cd647e8f667

Will think about the second one a little more and reply on that later.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQvu6YACgkQIgjSCVjB
3rBkxg//bw2Snxad+y2klyFnHcvEBTknll1fF0v4jpT2Ex4IBZsnRhgAnbWDfIBV
xG7DwYC+uAr443rsj4joFpapMJK2d8OJBBff45I4u3KYFZ9Z/bLfurTS7cX8aPIC
Kcx5Wwvuf1R7ZWk+bRhHcQ75DmqAmBlLhupcBAluXgQ2kA+JhfyHnbv2zBAO9P8d
TFYzu4LunHIY8ZTrsvwJsUg7J/dIDN0dI8YQMLzalHivXtFlLkUBbiJfgnDnu+dv
YGUFGBqQmBpHq+5zcOqR1wnJhvqPzDuK15r160fpnrxp2JGe6m4qQSCeW/VxsJF2
PvXX+fyTwHT1dLv+0DCOzUJofgTMZ/7C/yDr3xKd+a1GHXlRHQowzfnsF33+xiuq
fJHdQ29FH0F3P5WfUQdylwqsbuzaZpTVmAcY7xV3YVzyXqkNmSwia6rdR2z5w87+
R6Jq4P01YXiG6i+hi5pZE0bZMSGHtk04sQYm7arI70WZmMuhtLHqZa2Z3F56u3/Q
fS2u6KrO0IgsD6d5lebO0LN1Dg91xSJ7Dao5gnAt24vUVbSfYY6vBgiNy4fKUlpg
NTpb0IPitGmQ3x7aKfUHqTJby/bIqqCRSkwTBVh1cPnhim5cXbSsGZNS//9Krxfb
LODE2N/dfvK6b95CL9Q/4HTxrEyY8iDDnjk51ovklilVzzyMNo8=
=LYE/
-----END PGP SIGNATURE-----

A
A
Andrew Tropin wrote on 7 Apr 10:45 +0200
Re: [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME.
87cz4gw06c.fsf@trop.in
On 2023-03-05 15:19, Bruno Victal wrote:

Toggle quote (35 lines)
> XDG_LOG_HOME is non-standard and log files should go to XDG_STATE_HOME
> according to the XDG Base Directory Specification.
>
> Fixes <https://issues.guix.gnu.org/61809>.
>
> * gnu/home/services/desktop.scm (home-dbus-shepherd-services): Log to XDG_STATE_HOME.
> * gnu/home/services/mcron.scm (home-mcron-shepherd-services): Ditto.
> * gnu/home/services/pm.scm (home-batsignal-shepherd-services): Ditto.
> * gnu/home/services/shepherd.scm (launch-shepherd-gexp): Ditto.
> * gnu/home/services/xdg.scm
> (home-xdg-base-directories-configuration)[log-home]: Deprecate and unset default value.
> (home-xdg-base-directories-environment-variables-service)
> (ensure-xdg-base-dirs-on-activation): Handle field deprecation.
> (home-xdg-base-directories-service-type): Update description.
> ---
> gnu/home/services/desktop.scm | 4 ++--
> gnu/home/services/mcron.scm | 4 ++--
> gnu/home/services/pm.scm | 6 +++---
> gnu/home/services/shepherd.scm | 4 ++--
> gnu/home/services/xdg.scm | 36 +++++++++++++++++++++++++---------
> 5 files changed, 36 insertions(+), 18 deletions(-)
>
> diff --git a/gnu/home/services/desktop.scm b/gnu/home/services/desktop.scm
> index cb25b03b64..76df7b30a2 100644
> --- a/gnu/home/services/desktop.scm
> +++ b/gnu/home/services/desktop.scm
> @@ -206,8 +206,8 @@ (define (home-dbus-shepherd-services config)
> (default-environment-variables))
> #:log-file
> (format #f "~a/dbus.log"
> - (or (getenv "XDG_LOG_HOME")
> - (format #f "~a/.local/var/log"
> + (or (getenv "XDG_STATE_HOME")
> + (format #f "~a/.local/state"

If we deprecate XDG_LOG_HOME, maybe it's a good idea to make a helper
function, which can be reused across different services?

Also, how about appending /log subdirectory by default?

WDYT?

Toggle quote (151 lines)
> (getenv "HOME"))))))
> (stop #~(make-kill-destructor)))))
>
> diff --git a/gnu/home/services/mcron.scm b/gnu/home/services/mcron.scm
> index 5f35bfe054..69c7f9faa6 100644
> --- a/gnu/home/services/mcron.scm
> +++ b/gnu/home/services/mcron.scm
> @@ -99,8 +99,8 @@ (define (home-mcron-shepherd-services config)
> #~())
> #$@files)
> #:log-file (string-append
> - (or (getenv "XDG_LOG_HOME")
> - (format #f "~a/.local/var/log"
> + (or (getenv "XDG_STATE_HOME")
> + (format #f "~a/.local/state"
> (getenv "HOME")))
> "/mcron.log")))
> (stop #~(make-kill-destructor))
> diff --git a/gnu/home/services/pm.scm b/gnu/home/services/pm.scm
> index 5f09941827..274ab2303c 100644
> --- a/gnu/home/services/pm.scm
> +++ b/gnu/home/services/pm.scm
> @@ -128,9 +128,9 @@ (define (home-batsignal-shepherd-services config)
> (list "-i")
> (list)))
> #:log-file (string-append
> - (or (getenv "XDG_LOG_HOME")
> - (format #f "~a/.local/var/log"
> - (getenv "HOME")))
> + (or (getenv "XDG_STATE_HOME")
> + (format #f "~a/.local/state"
> + (getenv "HOME")))
> "/batsignal.log")))
> (stop #~(make-kill-destructor))))))
>
> diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm
> index 1a70a220f0..825cf66f05 100644
> --- a/gnu/home/services/shepherd.scm
> +++ b/gnu/home/services/shepherd.scm
> @@ -108,8 +108,8 @@ (define (launch-shepherd-gexp config)
> (or (getenv "XDG_RUNTIME_DIR")
> (format #f "/run/user/~a" (getuid)))
> "/shepherd/socket"))
> - (let ((log-dir (or (getenv "XDG_LOG_HOME")
> - (format #f "~a/.local/var/log"
> + (let ((log-dir (or (getenv "XDG_STATE_HOME")
> + (format #f "~a/.local/state"
> (getenv "HOME")))))
> ;; TODO: Remove it, 0.9.2 creates it automatically?
> ((@ (guix build utils) mkdir-p) log-dir)
> diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm
> index ac557b4c3d..958772696b 100644
> --- a/gnu/home/services/xdg.scm
> +++ b/gnu/home/services/xdg.scm
> @@ -1,6 +1,7 @@
> ;;; GNU Guix --- Functional package management for GNU
> ;;; Copyright © 2021, 2022 Andrew Tropin <andrew@trop.in>
> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
> +;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -22,6 +23,7 @@ (define-module (gnu home services xdg)
> #:use-module (gnu home services)
> #:use-module (gnu packages freedesktop)
> #:use-module (gnu home services utils)
> + #:use-module (guix deprecation)
> #:use-module (guix gexp)
> #:use-module (guix modules)
> #:use-module (guix records)
> @@ -39,7 +41,7 @@ (define-module (gnu home services xdg)
> home-xdg-base-directories-configuration-config-home
> home-xdg-base-directories-configuration-data-home
> home-xdg-base-directories-configuration-state-home
> - home-xdg-base-directories-configuration-log-home
> + home-xdg-base-directories-configuration-log-home ; deprecated
> home-xdg-base-directories-configuration-runtime-dir
>
> home-xdg-user-directories-service-type
> @@ -77,6 +79,7 @@ (define-module (gnu home services xdg)
>
> (define (serialize-path field-name val) "")
> (define path? string?)
> +(define-maybe path)
>
> (define-configuration home-xdg-base-directories-configuration
> (cache-home
> @@ -97,12 +100,17 @@ (define-configuration home-xdg-base-directories-configuration
> (path "${XDG_RUNTIME_DIR:-/run/user/$UID}")
> "Base directory for programs to store user-specific runtime files,
> like sockets.")
> + ;; TODO: deprecated field, use $XDG_STATE_HOME(/log) instead.
> (log-home
> - (path "$HOME/.local/var/log")
> + maybe-path
> "Base directory for programs to store log files, analogus to
> @file{/var/log}, but for user. It is not a part of XDG Base Directory
> Specification, but helps to make implementation of home services more
> -consistent.")
> +consistent."
> + (lambda (field-name val)
> + (when (maybe-value-set? val)
> + (warn-about-deprecation field-name #f #:replacement 'state-home))
> + (serialize-path field-name val)))
> (state-home
> (path "$HOME/.local/state")
> "Base directory for programs to store state data that should persist
> @@ -117,7 +125,13 @@ (define (home-xdg-base-directories-environment-variables-service config)
> #f "XDG_~a"
> (object->snake-case-string (configuration-field-name field) 'upper))
> ((configuration-field-getter field) config)))
> - home-xdg-base-directories-configuration-fields))
> + ;; XXX: deprecated field, remove later
> + (if (maybe-value-set?
> + (home-xdg-base-directories-configuration-log-home config))
> + home-xdg-base-directories-configuration-fields
> + (filter-configuration-fields
> + home-xdg-base-directories-configuration-fields
> + '(log-home) #t))))
>
> (define (ensure-xdg-base-dirs-on-activation config)
> (with-imported-modules '((guix build utils))
> @@ -138,7 +152,14 @@ (define (ensure-xdg-base-dirs-on-activation config)
> ;; and will be provided by elogind or other service.
> (and (not (string=? "XDG_RUNTIME_DIR" variable))
> variable)))
> - home-xdg-base-directories-configuration-fields)))))
> + ;; XXX: deprecated field, remove later
> + (if (maybe-value-set?
> + (home-xdg-base-directories-configuration-log-home
> + config))
> + home-xdg-base-directories-configuration-fields
> + (filter-configuration-fields
> + home-xdg-base-directories-configuration-fields
> + '(log-home) #t)))))))
>
> (define (last-extension-or-cfg config extensions)
> "Picks configuration value from last provided extension. If there
> @@ -157,10 +178,7 @@ (define home-xdg-base-directories-service-type
> (default-value (home-xdg-base-directories-configuration))
> (compose identity)
> (extend last-extension-or-cfg)
> - (description "Configure XDG base directories. This
> -service introduces an additional @env{XDG_LOG_HOME} variable. It's not
> -a part of XDG specification, at least yet, but are convenient to have,
> -it improves the consistency between different home services. The
> + (description "Configure XDG base directories. The
> services of this service-type is instantiated by default, to provide
> non-default value, extend the service-type (using @code{simple-service}
> for example).")))

Overall LGTM, let me know what you think on a few comments above.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQv2BsACgkQIgjSCVjB
3rDrhw//cWndPui+Kl5k5KEkufH933IXT/qy8Y4yefqd9MJLAIbhfqTwsjz4v52P
YBeYAJb0vx0Vh9Cq22clzvFq3w9wbVsaKeDkC2sL1Xk3vATRxSuvMI6gcAw8M4Hh
3jc1Lbxv4rv3181d3Qjq+hV665gCSpEDb/gp2dBieGpMRhFPloDdjPkIoebtk9B+
rhngsrvlV67mZl5HDJai91+7BSsBKY2mMxnQ6WOgvFoRUP14YEQ0YM2iikOpnvp+
2Gjw6WIMRJC4CILglqf2mfLcBbxS6ivrgukOcvlpb0WR9wa7OlFpTZsARC39JPrd
DoB54HvmiJzs7cN/gbxfST35rZA/O6P6VnbFjjlIyFrtVr6s2+ORTDfz4k20tSia
hd83o6Z0jMrSr0x1PH9xjPCZ/2bKLiqGzpgvcP0cxl6yttiItojpSrXtBANTsT1Q
AzKYk43QO09hlJvIWYj7NXZvwB4Tlq+5/Uu8XQr6/K472OvUgc1+0BGcjxWtEWnY
F0/3i9d2OUdUJBqUi87j/2pN+C4bBZnJ7KPA/gCdJS2agPMN+88gybj0JBDKbePC
EMcKI91iWPV0vv2VsRMpTeTQZ8WZTZo7KCq49IwsdqBdK2Cj4RgGbb+8sbDPK4/6
C7DRl6O0sh7+ilcuEg8QeUGqz+FhR68uzP6LG+o/8lDOlvhKhwE=
=ijCt
-----END PGP SIGNATURE-----

B
B
Bruno Victal wrote on 7 Apr 13:47 +0200
(name . Andrew Tropin)(address . andrew@trop.in)
10e30d4c-07f2-8bf9-24ed-7bbf820d12e8@makinata.eu
Hi Andrew,

On 2023-04-07 09:45, Andrew Tropin wrote:
Toggle quote (18 lines)
> On 2023-03-05 15:19, Bruno Victal wrote:
>> --- a/gnu/home/services/desktop.scm
>> +++ b/gnu/home/services/desktop.scm
>> @@ -206,8 +206,8 @@ (define (home-dbus-shepherd-services config)
>> (default-environment-variables))
>> #:log-file
>> (format #f "~a/dbus.log"
>> - (or (getenv "XDG_LOG_HOME")
>> - (format #f "~a/.local/var/log"
>> + (or (getenv "XDG_STATE_HOME")
>> + (format #f "~a/.local/state"
>
> If we deprecate XDG_LOG_HOME, maybe it's a good idea to make a helper
> function, which can be reused across different services?
>
> Also, how about appending /log subdirectory by default?
>> WDYT?

I'm wondering if this continued usage of XDG_LOG_HOME was a good idea,
maybe the service should just start using XDG_STATE_HOME as soon as possible?
(in which case, this patch will have to be reworked to reflect that)
This way we avoid introducing yet more code to handle deprecated code.

It shouldn't result in any kind of problems, XDG_LOG_HOME will still be set in the meantime
for scripts and code that happen to use it and are not part of (upstream) guix.

WDYT?


Cheers,
Bruno
A
A
Andrew Tropin wrote on 7 Apr 14:46 +0200
(name . Bruno Victal)(address . mirai@makinata.eu)
875ya7x3kl.fsf@trop.in
On 2023-04-07 12:47, Bruno Victal wrote:

Toggle quote (31 lines)
> Hi Andrew,
>
> On 2023-04-07 09:45, Andrew Tropin wrote:
>> On 2023-03-05 15:19, Bruno Victal wrote:
>>> --- a/gnu/home/services/desktop.scm
>>> +++ b/gnu/home/services/desktop.scm
>>> @@ -206,8 +206,8 @@ (define (home-dbus-shepherd-services config)
>>> (default-environment-variables))
>>> #:log-file
>>> (format #f "~a/dbus.log"
>>> - (or (getenv "XDG_LOG_HOME")
>>> - (format #f "~a/.local/var/log"
>>> + (or (getenv "XDG_STATE_HOME")
>>> + (format #f "~a/.local/state"
>>
>> If we deprecate XDG_LOG_HOME, maybe it's a good idea to make a helper
>> function, which can be reused across different services?
>>
>> Also, how about appending /log subdirectory by default?
>>> WDYT?
>
> I'm wondering if this continued usage of XDG_LOG_HOME was a good idea,
> maybe the service should just start using XDG_STATE_HOME as soon as possible?
> (in which case, this patch will have to be reworked to reflect that)
> This way we avoid introducing yet more code to handle deprecated code.
>
> It shouldn't result in any kind of problems, XDG_LOG_HOME will still be set in the meantime
> for scripts and code that happen to use it and are not part of (upstream) guix.
>
> WDYT?

I meant introducing something like this
(define (get-log-dir)
(string-append
(getenv "XDG_STATE_HOME") "/log"))

and use it instead of
(or (getenv "XDG_STATE_HOME")
(format #f "~a/.local/state" (getenv "HOME")))

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQwEKoACgkQIgjSCVjB
3rD0Tw/+Kn9fjK0gunUgwz0wWZ9T/+uvK8PFedGXRpDMH/ZV/iwHXC3AiS5R0I++
eHMTF0slJ6H06buDmaMwSZYy750R5GBJ7Ec4XQjLa+TSLSLaOIjP3BhviMFqxWJP
zmGVqzT4ajsUgLHAbTAF7XymZMuHnggN8UZJzg1ZVEiF7amGIygP9CtE3GQbehao
Erylha2O1ZZFMvwepmYBF9auhN1pyD5Um5Tn/IijAllc4VpCIsTIQBmozlNUIR0G
GktkYIwo6C9H/R5v+O8C/ROFVjjMl/k4GMm/I8pLHUCQiy0FSfoKQmcSzbprY4TT
nYVJvnvSnEtZ+CeamdB2l2O3Yqu/v4QdaPOvbq+j2+b818g378ffp5Je4BQ0n32U
WmIEfq3W+vWHuffhWyozcb3RTbO14UxIECjVyPSSQezeolNWhJtJnvI8gphsBb+8
MOlm4suVDSpBJPjDkX5vVOn2tayMDyuI4AgqhUKWjDKZ4IaG1Cl+ML3msMqbdyjR
9hkYxnkBK+EeBDizPhuzDjRlFirXxmHUo3FmN6U/r0U127xlUWc52Bpn1tc8Yj0c
XSFMn/GHOotJVLTIozd/Q8LFFbAvt6RNmeXg7oWpo3exDdQ730F9Kci0dZsdc+DL
Ek0Pkb5yOPPuazbgR3oz85yEEmuyr31USpuaq3o3CKZqVBAtinU=
=szw0
-----END PGP SIGNATURE-----

P
P
Philip McGrath wrote on 9 Apr 21:09 +0200
(address . 61982@debbugs.gnu.org)
92d07a8a-aac9-42c7-809d-66373358c77b@app.fastmail.com
Hi,

On Fri, Apr 7, 2023, at 8:46 AM, Andrew Tropin wrote:
Toggle quote (39 lines)
> On 2023-04-07 12:47, Bruno Victal wrote:
>
>> Hi Andrew,
>>
>> On 2023-04-07 09:45, Andrew Tropin wrote:
>>> On 2023-03-05 15:19, Bruno Victal wrote:
>>>> --- a/gnu/home/services/desktop.scm
>>>> +++ b/gnu/home/services/desktop.scm
>>>> @@ -206,8 +206,8 @@ (define (home-dbus-shepherd-services config)
>>>> (default-environment-variables))
>>>> #:log-file
>>>> (format #f "~a/dbus.log"
>>>> - (or (getenv "XDG_LOG_HOME")
>>>> - (format #f "~a/.local/var/log"
>>>> + (or (getenv "XDG_STATE_HOME")
>>>> + (format #f "~a/.local/state"
>>>
>>> If we deprecate XDG_LOG_HOME, maybe it's a good idea to make a helper
>>> function, which can be reused across different services?
>>>
>>> Also, how about appending /log subdirectory by default?
>>>> WDYT?
>>
>> I'm wondering if this continued usage of XDG_LOG_HOME was a good idea,
>> maybe the service should just start using XDG_STATE_HOME as soon as possible?
>> (in which case, this patch will have to be reworked to reflect that)
>> This way we avoid introducing yet more code to handle deprecated code.
>>
>> It shouldn't result in any kind of problems, XDG_LOG_HOME will still be set in the meantime
>> for scripts and code that happen to use it and are not part of (upstream) guix.
>>
>> WDYT?
>
> I meant introducing something like this
> (define (get-log-dir)
> (string-append
> (getenv "XDG_STATE_HOME") "/log"))
>

Within the XDG directories, I think (unless perhaps you only use a single file) you are supposed to keep everything in a subdirectory named for your application (or with a well-known name for things shared among multiple applications). For example, on my system, I can find log files in "$XDG_DATA_HOME/akonadi/Akonadi.error", "$XDG_DATA_HOME/akonadi/Akonadi.error.old", "$XDG_DATA_HOME/sddm/wayland-session.log", and "$XDG_DATA_HOME/sddm/xorg-session.log". (Apparently SDDM and Akonadi haven't been updated to use $XDG_STATE_HOME.) I think Guix Home services should follow that convention, rather than putting all logs together in "$XDG_STATE_HOME/log/".

Toggle quote (6 lines)
>
> and use it instead of
> (or (getenv "XDG_STATE_HOME")
> (format #f "~a/.local/state" (getenv "HOME")))
>

Perhaps my least-favorite part of the XDG Base Directory specification is having to repeat the default values so many times. But I understood the conclusion from https://issues.guix.gnu.org/56050#3 to be that Guix should be able to assume that the XDG variables are all explicitly set, either by Guix System or by the installation process for Guix on a foreign distro.

-Philip
(
(address . 61982@debbugs.gnu.org)
CRSHOENTZGT6.2A5WD1YC8VIRO@guix-framework
On Sun Apr 9, 2023 at 8:09 PM BST, Philip McGrath wrote:
Toggle quote (8 lines)
> > I meant introducing something like this
> > (define (get-log-dir)
> > (string-append
> > (getenv "XDG_STATE_HOME") "/log"))
> >
>
> Within the XDG directories, I think (unless perhaps you only use a single file) you are supposed to keep everything in a subdirectory named for your application (or with a well-known name for things shared among multiple applications). For example, on my system, I can find log files in "$XDG_DATA_HOME/akonadi/Akonadi.error", "$XDG_DATA_HOME/akonadi/Akonadi.error.old", "$XDG_DATA_HOME/sddm/wayland-session.log", and "$XDG_DATA_HOME/sddm/xorg-session.log". (Apparently SDDM and Akonadi haven't been updated to use $XDG_STATE_HOME.) I think Guix Home services should follow that convention, rather than putting all logs together in "$XDG_STATE_HOME/log/".

So it turns out Shepherd provides these gems squirreled away inside its
(shepherd support) module:

```
(define %user-config-dir
;; Default config directory if shepherd is run as a normal user.
(string-append (or (getenv "XDG_CONFIG_HOME")
(string-append user-homedir "/.config"))
"/shepherd"))

(define %user-log-dir
;; Default log directory if shepherd is run as a normal user.
(string-append (or (getenv "XDG_STATE_HOME")
(string-append user-homedir "/.local/state"))
"/shepherd"))

(define %user-runtime-dir
;; Default runtime directory if shepherd is run as a normal user.
(string-append (or (getenv "XDG_RUNTIME_DIR")
(format #f "/run/user/~s" (getuid)))))
```

Shepherd already provides us with a %USER-LOG-DIR variable :D

-- (
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEE6Vh10NblKE5doNlW7ImHg/nqI20FAmQzGMMACgkQ7ImHg/nq
I23uLwv/VOu1QciGvXiSykavq7Lo3K7lZ5o+dxhzPLpPeOqlhA9ybQkLRVJ26TQe
JS4wQLUv7Fc+b1XUKDnQ0VR1MtQ51T4Tkl4RHlbINJof89nOtrtrTvkFtEUeF3Jk
A+aiFbH0L7hAsQ+KPkiE0C77Tv79WQ5Ig/I/xexi96DD+my5rnyNfwk9M2hRjqti
jnwmWhrV1PtHI+9thdlDtrByrrvg80kNzW14eSWIhKRBWcE4dtOTsxNI8UYWKK4v
X82rAz2Qp/rARVH3IiRZKe+mh9IJ+vRhkKVtYoquEoMprWy+dGTof8J2lWihEmiS
7QPx08y3oZHlYllq99y61SFfg1nka+V/NZ3qCqL5+HITv9lgUZM+tO7E2EtJvnVE
2v/e/5k/DJE5eI0lHQO3Qu+VUGVBm7b0ND1nrEiW/l+maB1P/eDSH8qfLhRM2dCy
WfFapUkkBtlZSvxcWarkgoqXVK9iwf92rkf2pGyCheFlyeMCtC2R8qglSLrLi32m
Rzvg3Az6
=OMIV
-----END PGP SIGNATURE-----


(
(address . 61982@debbugs.gnu.org)
CRSHRE5JL5CQ.Q3NXT9GFJAPM@guix-framework
On Sun Apr 9, 2023 at 8:57 PM BST, ( via Guix-patches via wrote:
Toggle quote (2 lines)
> Shepherd already provides us with a %USER-LOG-DIR variable :D

One thing I will note is that it might be good if (shepherd support) was one
of the modules imported into shepherd service gexps by default.

-- (
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEE6Vh10NblKE5doNlW7ImHg/nqI20FAmQzGa0ACgkQ7ImHg/nq
I23ZOgv/Q4ZsSBdNMntoOF/rrzfQoq9qtlbLLvsAAdCIqMw14PNr+omSuvr2mmtK
kcMXe9UCYCLEjgdLbRDaGr44w72lOeakYFyoonVwT9z7+SqAiGknh0o/ajrsk91R
LrZBCJf+BUc+NMRqZSqSZ3J6X+IDJH4opcklnK9RbFg10cvvbqgqXo08jFdllgvD
80utEH31j6LeEnsC0Xbw0u6k2vTR4fORfLeeKiUMscl8fxhmXlkPqWfct5Xf3AF2
6VkPtAPt+9oShYggZslTmSIf/DXbgi4H2KAGiShfBG7lZrY+KFNG4/GUZuI+PE9G
eKCO1P1POJ7NtiKoRsWywnlvsdv19gDMGCbScDefXMDUNJFQ8NxJ9tGXM15d10Lr
qsDcd2SGext9vi8rT3cnc5aDyiI1nDdtK/wOS4iRjMBu8uxhd11w4Sldzej5jhhC
W1mngixGlor9cJYBUcIA08Kpxh9QeT6Hn6+r4sZ3thcoW7xIP7kcKolS5aB7KrRa
0A4vIEkB
=yf4j
-----END PGP SIGNATURE-----


(
(name . ()(address . paren@disroot.org)
878rexgsli.fsf@disroot.org
"( via Guix-patches" via <guix-patches@gnu.org> writes:
Toggle quote (2 lines)
> Shepherd already provides us with a %USER-LOG-DIR variable :D

Apparently I can't read. This is *Shepherd*'s log dir, not a general
log dir variable. Oops :) I suppose that would be a good thing to add
to (gnu build utils), then...
A
A
Andrew Tropin wrote on 12 Apr 19:17 +0200
87o7ntkojm.fsf@trop.in
On 2023-04-11 21:01, paren@disroot.org wrote:

Toggle quote (6 lines)
> "( via Guix-patches" via <guix-patches@gnu.org> writes:
>> Shepherd already provides us with a %USER-LOG-DIR variable :D
>
> Apparently I can't read. This is *Shepherd*'s log dir, not a general
> log dir variable. Oops :)

That's right :)

Toggle quote (3 lines)
> I suppose that would be a good thing to add to (gnu build utils),
> then...

Yep, I have the same idea.

--
Best regards,
Andrew Tropin
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmQ2570ACgkQIgjSCVjB
3rBFYA//ZZDIzzV2/xiEZFD2zRwxx6EFC3ha8DD+7c21RGcZXJNXsOQ2l1S4ruPS
cZ4hHa3hw8aC+N3T3zdCdF+48tfVsjmZKzTECEpl208hnh12JGhLdAxhIMJCF0hP
mtyLrt1b5AnjFPbfXj44R3JrUzstdkLszUhYnucMVcV7m/IJp8Cm/i4PKKpvquWe
sl4bZW+DuZdkq7mT3Te4aPrXlupXXyYXnBI5Q2MN6jl/YABDI1J48VlcKlVPZsQt
d7MW20tLq8OI36wMeETuxHnB0qo1baPCWREuuISwRKDvnHtNYX1laFNc3qzNNavI
Agm9qU8fsquPLObpQuUepvY2RaCgb1L9BO/W2cqWJJoQ9NXN3U8a6ozjM4+P8GWq
xS0WZdkhw6jAHgSxotsMX+byg0BybZqrXKIVgPKXi569yuX7KDtRAqoEBwg1TuA8
AdFCCzX/EMe8EwCPhSTHYkuZbSfp3A78dBpqquClJ0kMhCAosvYuyN3E1kjD5J1D
JVq0J5CSaOiGAoxWJreeJ65Iaz+53KbrXMYjgctTAHLvD2D1nkLmq7i7L3DOxW5O
1/2eEW2s7HCtM5BUgUuaeqR94vGJ6PLOsbiTy5864tw68MsDzrHkrbkknwRZ1IIz
CMWE4GtxUqthYrWnNX1yCjonTs5OlXeBL7PGcO1deSfTbciGEC8=
=WQn+
-----END PGP SIGNATURE-----

?