On 2022-12-12 03:00, Antero Mejr via Guix-patches via wrote: > * gnu/home.scm (home-environment)[base-xdg-configuration]: New field. > * gnu/home/services/xdg.scm (ensure-xdg-base-dirs-on-activation): Make > XDG_RUNTIME_DIR directory if the configuration changes it from the default. > --- > Allows making a runtime dir at ~/.local/runtime (or any other dir), > so users don't have to set up elogind or other greeters/PAM modules. > > gnu/home.scm | 9 +++++++-- > gnu/home/services/xdg.scm | 7 ++++++- > 2 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/gnu/home.scm b/gnu/home.scm > index c95d1e0818..f100b575e3 100644 > --- a/gnu/home.scm > +++ b/gnu/home.scm > @@ -39,6 +39,7 @@ (define-module (gnu home) > home-environment-essential-services > home-environment-services > home-environment-location > + home-environment-base-xdg-configuration > > home-environment-with-provenance > > @@ -71,7 +72,10 @@ (define-record-type* home-environment > (location home-environment-location ; > (default (and=> (current-source-location) > source-properties->location)) > - (innate))) > + (innate)) > + > + (base-xdg-configuration home-environment-base-xdg-configuration > + (default (home-xdg-base-directories-configuration)))) > > (define (home-environment-default-essential-services he) > "Return the list of essential services for home environment." > @@ -83,7 +87,8 @@ (define (home-environment-default-essential-services he) > (service home-symlink-manager-service-type) > > (service home-fontconfig-service-type) > - (service home-xdg-base-directories-service-type) > + (service home-xdg-base-directories-service-type > + (home-environment-base-xdg-configuration he)) This change is not needed, you can set xdg dirs by extending home-xdg-base-directories-service-type with adjusted home-xdg-base-directories-configuration. > (service home-shell-profile-service-type) > > (service home-service-type) > diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm > index 865f8b81d7..b62580461e 100644 > --- a/gnu/home/services/xdg.scm > +++ b/gnu/home/services/xdg.scm > @@ -133,7 +133,12 @@ (define (ensure-xdg-base-dirs-on-activation config) > (configuration-field-name field) 'upper)))) > ;; XDG_RUNTIME_DIR shouldn't be created during activation > ;; and will be provided by elogind or other service. > - (and (not (string=? "XDG_RUNTIME_DIR" variable)) > + ;; But if the user changes the value from the default, > + ;; then we can make XDG_RUNTIME_DIR. > + (and (or (not (string=? "XDG_RUNTIME_DIR" variable)) > + (not (string=? ((configuration-field-getter field) > + config) > + "${XDG_RUNTIME_DIR:-/run/user/$UID}"))) > variable))) > home-xdg-base-directories-configuration-fields))) There is no way to understand upfront if directory containing XDG_RUNTIME_DIR is writable and this is why it's a good idea to delegate initialization of it to external thing and never try to create it here, even if it has non-default value. But in case you are sure it's writable and want to ensure the directory created, just be this thing managing and providing XDG_RUNTIME_DIR and extend activation script with the following G-expression: #~(mkdir-p (getenv "XDG_RUNTIME_DIR")) The full snippet: --8<---------------cut here---------------start------------->8--- (simple-service 'ensure-xdg-runtime-dir-exists home-activation-service-type #~(mkdir-p (getenv "XDG_RUNTIME_DIR"))) --8<---------------cut here---------------end--------------->8--- -- Best regards, Andrew Tropin