* [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8. @ 2023-03-05 15:16 Bruno Victal 2023-03-05 15:19 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Bruno Victal 2023-04-11 20:01 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME ( via Guix-patches via 0 siblings, 2 replies; 18+ messages in thread From: Bruno Victal @ 2023-03-05 15:16 UTC (permalink / raw) To: 61982; +Cc: Bruno Victal, philip 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME. 2023-03-05 15:16 [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8 Bruno Victal @ 2023-03-05 15:19 ` Bruno Victal 2023-03-05 15:19 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME Bruno Victal 2023-04-07 6:43 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Andrew Tropin 2023-04-11 20:01 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME ( via Guix-patches via 1 sibling, 2 replies; 18+ messages in thread From: Bruno Victal @ 2023-03-05 15:19 UTC (permalink / raw) To: 61982; +Cc: Bruno Victal, philip 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") + "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 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-03-05 15:19 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Bruno Victal @ 2023-03-05 15:19 ` Bruno Victal 2023-04-07 8:45 ` Andrew Tropin 2023-06-15 9:35 ` bug#61982: " Andrew Tropin 2023-04-07 6:43 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Andrew Tropin 1 sibling, 2 replies; 18+ messages in thread From: Bruno Victal @ 2023-03-05 15:19 UTC (permalink / raw) To: 61982; +Cc: Bruno Victal, philip 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" (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 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-03-05 15:19 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME Bruno Victal @ 2023-04-07 8:45 ` Andrew Tropin 2023-04-07 11:47 ` Bruno Victal 2023-06-15 9:35 ` bug#61982: " Andrew Tropin 1 sibling, 1 reply; 18+ messages in thread From: Andrew Tropin @ 2023-04-07 8:45 UTC (permalink / raw) To: Bruno Victal, 61982; +Cc: Bruno Victal, philip [-- Attachment #1: Type: text/plain, Size: 9973 bytes --] On 2023-03-05 15:19, Bruno Victal wrote: > 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? > (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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-04-07 8:45 ` Andrew Tropin @ 2023-04-07 11:47 ` Bruno Victal 2023-04-07 12:46 ` Andrew Tropin 0 siblings, 1 reply; 18+ messages in thread From: Bruno Victal @ 2023-04-07 11:47 UTC (permalink / raw) To: Andrew Tropin; +Cc: philip, 61982 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? Cheers, Bruno ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-04-07 11:47 ` Bruno Victal @ 2023-04-07 12:46 ` Andrew Tropin 2023-04-09 19:09 ` Philip McGrath 0 siblings, 1 reply; 18+ messages in thread From: Andrew Tropin @ 2023-04-07 12:46 UTC (permalink / raw) To: Bruno Victal; +Cc: philip, 61982 [-- Attachment #1: Type: text/plain, Size: 1689 bytes --] 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")) and use it instead of (or (getenv "XDG_STATE_HOME") (format #f "~a/.local/state" (getenv "HOME"))) -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-04-07 12:46 ` Andrew Tropin @ 2023-04-09 19:09 ` Philip McGrath 2023-04-09 19:57 ` ( via Guix-patches via 0 siblings, 1 reply; 18+ messages in thread From: Philip McGrath @ 2023-04-09 19:09 UTC (permalink / raw) To: Andrew Tropin, Bruno Victal; +Cc: 61982 Hi, On Fri, Apr 7, 2023, at 8:46 AM, Andrew Tropin wrote: > 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/". > > 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-04-09 19:09 ` Philip McGrath @ 2023-04-09 19:57 ` ( via Guix-patches via 2023-04-09 20:01 ` ( via Guix-patches via 0 siblings, 1 reply; 18+ messages in thread From: ( via Guix-patches via @ 2023-04-09 19:57 UTC (permalink / raw) To: Philip McGrath, Andrew Tropin, Bruno Victal; +Cc: 61982 [-- Attachment #1: Type: text/plain, Size: 1736 bytes --] On Sun Apr 9, 2023 at 8:09 PM BST, Philip McGrath wrote: > > 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 -- ( [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 659 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-04-09 19:57 ` ( via Guix-patches via @ 2023-04-09 20:01 ` ( via Guix-patches via 0 siblings, 0 replies; 18+ messages in thread From: ( via Guix-patches via @ 2023-04-09 20:01 UTC (permalink / raw) To: (, Philip McGrath, Andrew Tropin, Bruno Victal; +Cc: 61982 [-- Attachment #1: Type: text/plain, Size: 288 bytes --] On Sun Apr 9, 2023 at 8:57 PM BST, ( via Guix-patches via wrote: > 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. -- ( [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 659 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* bug#61982: [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-03-05 15:19 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME Bruno Victal 2023-04-07 8:45 ` Andrew Tropin @ 2023-06-15 9:35 ` Andrew Tropin 2023-06-15 18:09 ` [bug#61982] " Philip McGrath 1 sibling, 1 reply; 18+ messages in thread From: Andrew Tropin @ 2023-06-15 9:35 UTC (permalink / raw) To: Bruno Victal, 61982-done, Ludovic Courtès; +Cc: Bruno Victal, philip [-- Attachment #1: Type: text/plain, Size: 10303 bytes --] On 2023-03-05 15:19, Bruno Victal wrote: > 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" > (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)."))) Hi Bruno, Applied, added log subdirectory, pushed, thank you for working on it. Hi Ludo, WDYT about adding (home-log-dir) function to (guix build utils)? So we can prevent copypasting the same code all over home modules. Something like: --8<---------------cut here---------------start------------->8--- (define (home-log-dir) "Returns a directory for user applications logs." (string-append (or (getenv "XDG_STATE_HOME") (format #f "~a/.local/state" (getenv "HOME"))) "/log")) --8<---------------cut here---------------end--------------->8--- -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-06-15 9:35 ` bug#61982: " Andrew Tropin @ 2023-06-15 18:09 ` Philip McGrath 2023-06-16 3:28 ` Andrew Tropin 0 siblings, 1 reply; 18+ messages in thread From: Philip McGrath @ 2023-06-15 18:09 UTC (permalink / raw) To: Andrew Tropin, Bruno Victal, 61982, Ludovic Courtès Hi, On Thu, Jun 15, 2023, at 5:35 AM, Andrew Tropin wrote: > > WDYT about adding (home-log-dir) function to (guix build utils)? > So we can prevent copypasting the same code all over home modules. > > Something like: > --8<---------------cut here---------------start------------->8--- > (define (home-log-dir) > "Returns a directory for user applications logs." > (string-append > (or (getenv "XDG_STATE_HOME") > (format #f "~a/.local/state" > (getenv "HOME"))) > "/log")) > --8<---------------cut here---------------end--------------->8--- > I still think idiomatic XDG structure is NOT to have a "/log" subdirectory like this, as I explained in <https://issues.guix.gnu.org/61982#7>. Aside from that, though, I thought the conclusion from <https://issues.guix.gnu.org/56050#3> was that it is the responsibility of Guix System or the installation mechanism for Guix on a foreign distribution (e.g. "/etc/profile.d/zzz-guix.sh") to initialize all of the XDG variables, so code like this can use `(getenv "XDG_STATE_HOME")` unconditionally (or indeed with a checked assertion). Maybe there's some context I'm forgetting, though. I've been looking into these things again as I attempt to solve <https://lists.gnu.org/archive/html/help-guix/2023-06/msg00031.html>: I noticed in the attached environment variables that entries under /home/philip/.guix-home/profile/ are duplicated in many search paths. -Philip ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-06-15 18:09 ` [bug#61982] " Philip McGrath @ 2023-06-16 3:28 ` Andrew Tropin 2023-06-17 18:22 ` Philip McGrath 0 siblings, 1 reply; 18+ messages in thread From: Andrew Tropin @ 2023-06-16 3:28 UTC (permalink / raw) To: Philip McGrath, Bruno Victal, 61982, Ludovic Courtès [-- Attachment #1: Type: text/plain, Size: 1959 bytes --] On 2023-06-15 14:09, Philip McGrath wrote: > Hi, > > On Thu, Jun 15, 2023, at 5:35 AM, Andrew Tropin wrote: >> >> WDYT about adding (home-log-dir) function to (guix build utils)? >> So we can prevent copypasting the same code all over home modules. >> >> Something like: >> --8<---------------cut here---------------start------------->8--- >> (define (home-log-dir) >> "Returns a directory for user applications logs." >> (string-append >> (or (getenv "XDG_STATE_HOME") >> (format #f "~a/.local/state" >> (getenv "HOME"))) >> "/log")) >> --8<---------------cut here---------------end--------------->8--- >> > > I still think idiomatic XDG structure is NOT to have a "/log" > subdirectory like this, as I explained in > <https://issues.guix.gnu.org/61982#7>. With a brief look I didn't find information about this idiom in specification, but you can highlight it with quote or link. Anyway, I'm ok with storing logs in app subdirectory or "/log", not so ok with storing them in the root of state home. > > Aside from that, though, I thought the conclusion from > <https://issues.guix.gnu.org/56050#3> was that it is the > responsibility of Guix System or the installation mechanism for Guix > on a foreign distribution (e.g. "/etc/profile.d/zzz-guix.sh") to > initialize all of the XDG variables, so code like this can use > `(getenv "XDG_STATE_HOME")` unconditionally (or indeed with a checked > assertion). Maybe there's some context I'm forgetting, though. I've > been looking into these things again as I attempt to solve > <https://lists.gnu.org/archive/html/help-guix/2023-06/msg00031.html>: > I noticed in the attached environment variables that entries under > /home/philip/.guix-home/profile/ are duplicated in many search paths. home-state-dir function can also be useful, which can later become just (getenv ("XDG_STATE_HOME")). -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-06-16 3:28 ` Andrew Tropin @ 2023-06-17 18:22 ` Philip McGrath 0 siblings, 0 replies; 18+ messages in thread From: Philip McGrath @ 2023-06-17 18:22 UTC (permalink / raw) To: Andrew Tropin, Bruno Victal, 61982, Ludovic Courtès Hi, On Thu, Jun 15, 2023, at 11:28 PM, Andrew Tropin wrote: > On 2023-06-15 14:09, Philip McGrath wrote: > >> Hi, >> >> On Thu, Jun 15, 2023, at 5:35 AM, Andrew Tropin wrote: >>> >>> WDYT about adding (home-log-dir) function to (guix build utils)? >>> So we can prevent copypasting the same code all over home modules. >>> >>> Something like: >>> --8<---------------cut here---------------start------------->8--- >>> (define (home-log-dir) >>> "Returns a directory for user applications logs." >>> (string-append >>> (or (getenv "XDG_STATE_HOME") >>> (format #f "~a/.local/state" >>> (getenv "HOME"))) >>> "/log")) >>> --8<---------------cut here---------------end--------------->8--- >>> >> >> I still think idiomatic XDG structure is NOT to have a "/log" >> subdirectory like this, as I explained in >> <https://issues.guix.gnu.org/61982#7>. > > With a brief look I didn't find information about this idiom in > specification, but you can highlight it with quote or link. > > Anyway, I'm ok with storing logs in app subdirectory or "/log", not so > ok with storing them in the root of state home. > You are right that the idiomatic usage isn't made very explicit in the specification. In the specification itself, the idiom is implicit in the "Referencing this specification" section, which always uses a subdirectory: > > Other specifications may reference this specification by specifying the location of a data file as $XDG_DATA_DIRS/subdir/filename. This implies that: > > - Such file should be installed to $datadir/subdir/filename with $datadir defaulting to /usr/share. > > - A user-specific version of the data file may be created in $XDG_DATA_HOME/subdir/filename, taking into account the default value for $XDG_DATA_HOME if $XDG_DATA_HOME is not set. > > - Lookups of the data file should search for ./subdir/filename relative to all base directories specified by $XDG_DATA_HOME and $XDG_DATA_DIRS . If an environment variable is either not set or empty, its default value as defined by this specification should be used instead. > > Specifications may reference this specification by specifying the location of a configuration file as $XDG_CONFIG_DIRS/subdir/filename. This implies that: > > - Default configuration files should be installed to $sysconfdir/xdg/subdir/filename with $sysconfdir defaulting to /etc. > > - A user-specific version of the configuration file may be created in $XDG_CONFIG_HOME/subdir/filename, taking into account the default value for $XDG_CONFIG_HOME if $XDG_CONFIG_HOME is not set. > > - Lookups of the configuration file should search for ./subdir/filename relative to all base directories indicated by $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS . If an environment variable is either not set or empty, its default value as defined by this specification should be used instead. > (Obviously $HOME/.local/bin is a special case, since using subdirectories there would defeat the point.) More than the text of the specification, I'd look at actual observed usage and documented best practices. The relevant Gnome Goal [1] (despite outbound linkrot) is consistent with every other developer guide I've seen in showing the use of subdirectories, e.g. in the Glib example code: ``` const char *cache_dir = g_get_user_cache_dir (); char *mydir = g_build_filename (cache_dir, "myapp", NULL); /* use it */ g_free (mydir); ``` (Glib now provides g_get_user_state_dir, too. [2]) The Arch wiki has a survey of XDG support status [3] that consistently shows applications using appropriate subdirectories. [1]: https://wiki.gnome.org/Initiatives/GnomeGoals/XDGConfigFolders [2]: https://docs.gtk.org/glib/func.get_user_state_dir.html [3]: https://wiki.archlinux.org/title/XDG_Base_Directory >> >> Aside from that, though, I thought the conclusion from >> <https://issues.guix.gnu.org/56050#3> was that it is the >> responsibility of Guix System or the installation mechanism for Guix >> on a foreign distribution (e.g. "/etc/profile.d/zzz-guix.sh") to >> initialize all of the XDG variables, so code like this can use >> `(getenv "XDG_STATE_HOME")` unconditionally (or indeed with a checked >> assertion). Maybe there's some context I'm forgetting, though. I've >> been looking into these things again as I attempt to solve >> <https://lists.gnu.org/archive/html/help-guix/2023-06/msg00031.html>: >> I noticed in the attached environment variables that entries under >> /home/philip/.guix-home/profile/ are duplicated in many search paths. > > home-state-dir function can also be useful, which can later become just > (getenv ("XDG_STATE_HOME")). > I'm not at all opposed to providing functions rather that using getenv everywhere: they could guard against typos, check invariants, and all the other usual helpful things. But---though maybe I'm missing some context---how often is it actually needed to pass these default values? As long as the upstream software supports XDG directories properly, I would think it should just do the right thing without having to pass a bunch of explicit configuration options. -Philip ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME. 2023-03-05 15:19 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Bruno Victal 2023-03-05 15:19 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME Bruno Victal @ 2023-04-07 6:43 ` Andrew Tropin 2023-06-09 21:01 ` [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8 Ludovic Courtès 1 sibling, 1 reply; 18+ messages in thread From: Andrew Tropin @ 2023-04-07 6:43 UTC (permalink / raw) To: Bruno Victal, 61982; +Cc: Bruno Victal, philip [-- Attachment #1: Type: text/plain, Size: 3058 bytes --] On 2023-03-05 15:19, Bruno Victal wrote: > 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 :) > + "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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8. 2023-04-07 6:43 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Andrew Tropin @ 2023-06-09 21:01 ` Ludovic Courtès 2023-06-14 9:27 ` Andrew Tropin 0 siblings, 1 reply; 18+ messages in thread From: Ludovic Courtès @ 2023-06-09 21:01 UTC (permalink / raw) To: Andrew Tropin; +Cc: Bruno Victal, 61982, philip Hi Andrew, Andrew Tropin <andrew@trop.in> skribis: > Applied and pushed the first patch as > 5c893787be78a79433fe1343f5b70cd647e8f667 > > Will think about the second one a little more and reply on that later. Could you take a look and apply it or close the issue? Thanks in advance, Ludo’. ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8. 2023-06-09 21:01 ` [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8 Ludovic Courtès @ 2023-06-14 9:27 ` Andrew Tropin 0 siblings, 0 replies; 18+ messages in thread From: Andrew Tropin @ 2023-06-14 9:27 UTC (permalink / raw) To: Ludovic Courtès; +Cc: Bruno Victal, 61982, philip [-- Attachment #1: Type: text/plain, Size: 431 bytes --] On 2023-06-09 23:01, Ludovic Courtès wrote: > Hi Andrew, > > Andrew Tropin <andrew@trop.in> skribis: > >> Applied and pushed the first patch as >> 5c893787be78a79433fe1343f5b70cd647e8f667 >> >> Will think about the second one a little more and reply on that later. > > Could you take a look and apply it or close the issue? Sure, added this thread to my agenda for this week. -- Best regards, Andrew Tropin [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-03-05 15:16 [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8 Bruno Victal 2023-03-05 15:19 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Bruno Victal @ 2023-04-11 20:01 ` ( via Guix-patches via 2023-04-12 17:17 ` Andrew Tropin 1 sibling, 1 reply; 18+ messages in thread From: ( via Guix-patches via @ 2023-04-11 20:01 UTC (permalink / raw) To: (; +Cc: 61982, mirai, philip, andrew "( 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 :) I suppose that would be a good thing to add to (gnu build utils), then... ^ permalink raw reply [flat|nested] 18+ messages in thread
* [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. 2023-04-11 20:01 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME ( via Guix-patches via @ 2023-04-12 17:17 ` Andrew Tropin 0 siblings, 0 replies; 18+ messages in thread From: Andrew Tropin @ 2023-04-12 17:17 UTC (permalink / raw) To: (, (; +Cc: mirai, philip, 61982 [-- Attachment #1: Type: text/plain, Size: 448 bytes --] On 2023-04-11 21:01, paren@disroot.org wrote: > "( 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 :) > 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 832 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2023-06-17 18:23 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-03-05 15:16 [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8 Bruno Victal 2023-03-05 15:19 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Bruno Victal 2023-03-05 15:19 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME Bruno Victal 2023-04-07 8:45 ` Andrew Tropin 2023-04-07 11:47 ` Bruno Victal 2023-04-07 12:46 ` Andrew Tropin 2023-04-09 19:09 ` Philip McGrath 2023-04-09 19:57 ` ( via Guix-patches via 2023-04-09 20:01 ` ( via Guix-patches via 2023-06-15 9:35 ` bug#61982: " Andrew Tropin 2023-06-15 18:09 ` [bug#61982] " Philip McGrath 2023-06-16 3:28 ` Andrew Tropin 2023-06-17 18:22 ` Philip McGrath 2023-04-07 6:43 ` [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME Andrew Tropin 2023-06-09 21:01 ` [bug#61982] [PATCH 0/2] Respect XDG Base Directory Specification 0.8 Ludovic Courtès 2023-06-14 9:27 ` Andrew Tropin 2023-04-11 20:01 ` [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME ( via Guix-patches via 2023-04-12 17:17 ` Andrew Tropin
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).