From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 12 23:25:29 2022 Received: (at 59983) by debbugs.gnu.org; 13 Dec 2022 04:25:30 +0000 Received: from localhost ([127.0.0.1]:57679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4wrB-0004ZK-Gw for submit@debbugs.gnu.org; Mon, 12 Dec 2022 23:25:29 -0500 Received: from relay11.mail.gandi.net ([217.70.178.231]:52895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4wr9-0004Z7-Es for 59983@debbugs.gnu.org; Mon, 12 Dec 2022 23:25:28 -0500 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 74735100004; Tue, 13 Dec 2022 04:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1670905521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ezu/O+jjtbW4VOl6mdzYTGLNQKHJGzetDiIYvKx3Vw0=; b=WA3fvl4B+/oAiJlPirZeGHvsw0lUZnLjm2XZF959zWXabqJlR2OTz9wC65ENQ2HJ7ylNqf Hzuwm4zacLeQh8z/KjXT+S2+diTamOG+B4eU8GXhB/kmXyz4rfrbdph0o05egL4pl2LjXK XyEoRsFQ5CP6bqd+ndmW+rxionceoyA2ocOC1p/MPJ8PPlXUpPjkGuJcjE2q7qa96n3+JH CyxMloyWD3CrCOxQ9WnWZOEczuFX2RsXSfdxANsxFuHGiyuwVaQUCl9iDOuIk2GOy57R0d T3hEQTKHRqv1Jz3k2lvfulr8h7MoGcZwW91eUyOwBd31C5MdIElA5pOHGeBhHA== From: Andrew Tropin To: Antero Mejr via Guix-patches via , 59983@debbugs.gnu.org Subject: Re: [bug#59983] [PATCH] home: Let user configure XDG base directories. In-Reply-To: <20221212030049.4725-1-antero@mailbox.org> References: <20221212030049.4725-1-antero@mailbox.org> Date: Tue, 13 Dec 2022 08:25:16 +0400 Message-ID: <87cz8o9bgz.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59983 Cc: ludo@gnu.org, Antero Mejr X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 defaul= t. > --- > 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 >=20=20 > home-environment-with-provenance >=20=20 > @@ -71,7 +72,10 @@ (define-record-type* home-environme= nt > (location home-environment-location ; > (default (and=3D> (current-source-location) > source-properties->location)) > - (innate))) > + (innate)) > + > + (base-xdg-configuration home-environment-base-xdg-configuration > + (default (home-xdg-base-directories-configurat= ion)))) >=20=20 > (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) >=20=20 > (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) >=20=20 > (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 activati= on > ;; and will be provided by elogind or other service. > - (and (not (string=3D? "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=3D? "XDG_RUNTIME_DIR" variable)) > + (not (string=3D? ((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: =2D-8<---------------cut here---------------start------------->8--- (simple-service 'ensure-xdg-runtime-dir-exists home-activation-service-type #~(mkdir-p (getenv "XDG_RUNTIME_DIR"))) =2D-8<---------------cut here---------------end--------------->8--- =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmOX/qwACgkQIgjSCVjB 3rD81hAAkSvQI5SzFQT9K2+R7cnwgOYC6dNwbLgwpj6iaH2mTOalp4wXTMdyz7e+ 5z0qC07nIcKHdLYtqjnSRU3d9sRhXTAoxvBx62OWNx2EPes0lDK2h+OLBPTF5qoF wrH9JfryfmflT37dGf5A5dKr9yBumJapcQbmEWPQoy6/72gqbei1XHcneIpjz3uc WzHadbW7nSGi8BOQIIyIoztK9ZLEiaAjnr4V83wyo/q8/TVgrR4D8KU9aF2oIURI Y5T//8eyXV6cfHLM3U3J6KWx4m6NC+0SOsP/y9Xjg8WjugdjGVW22BHBGeB/Fz+H x9qkQdZTTw/g9MqYK2iTA/QcxArsOf+y8D4mVFe/d7tLRDCf4lu5YGcAwY0IwGtb Ei77a3vPzTQzkr69Ve4RvfqFSdjxDmj+KMSgvWAaX7zp9c8Iw4vz+xxIMBBIrXHb Kt+5vGaZK9PI2u10t8mu9jx+DItuy1t2nXSe6lf0JlEnIktKb2FvkNwHrqQbpZgh vBNYXY7uGtmij+Vg3oRMi5EuujQHkjtqYZPg8InPR97MscMDH1lPPJSgS/RaINS8 PQdTjFbGKP8CbCPqwidrXtLFEmi71t1jnv5a2dbZKUmNhyQW1ARMe8KvDmGVFCaY 4tyQhyOMqUnO4Lh5sLjOGuCLZ8xmnQUX/nHHfYCfLW9xWgtcpYY= =wELh -----END PGP SIGNATURE----- --=-=-=--