From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oOEpHeL+l2OADgEAbAwnHQ (envelope-from ) for ; Tue, 13 Dec 2022 05:26:10 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 2OM7HOL+l2MheAEAG6o9tA (envelope-from ) for ; Tue, 13 Dec 2022 05:26:10 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AC28015FD7 for ; Tue, 13 Dec 2022 05:26:09 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4wrj-0008VB-SB; Mon, 12 Dec 2022 23:26:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4wri-0008Us-Jv for guix-patches@gnu.org; Mon, 12 Dec 2022 23:26:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p4wri-0003L0-CF for guix-patches@gnu.org; Mon, 12 Dec 2022 23:26:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p4wrh-0004Zn-Pp for guix-patches@gnu.org; Mon, 12 Dec 2022 23:26:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59983] [PATCH] home: Let user configure XDG base directories. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 13 Dec 2022 04:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59983 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59983@debbugs.gnu.org Cc: ludo@gnu.org, Antero Mejr X-Debbugs-Original-To: Antero Mejr via Guix-patches via , 59983@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167090553317577 (code B ref -1); Tue, 13 Dec 2022 04:26:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Dec 2022 04:25:33 +0000 Received: from localhost ([127.0.0.1]:57681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4wrE-0004ZR-Uh for submit@debbugs.gnu.org; Mon, 12 Dec 2022 23:25:33 -0500 Received: from lists.gnu.org ([209.51.188.17]:55790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p4wrA-0004ZE-NJ for submit@debbugs.gnu.org; Mon, 12 Dec 2022 23:25:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4wrA-0008OO-7L for guix-patches@gnu.org; Mon, 12 Dec 2022 23:25:28 -0500 Received: from relay11.mail.gandi.net ([2001:4b98:dc4:8::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4wr8-0003Bw-Bp; Mon, 12 Dec 2022 23:25:27 -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 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" Received-SPF: pass client-ip=2001:4b98:dc4:8::231; envelope-from=andrew@trop.in; helo=relay11.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1670905570; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=Ezu/O+jjtbW4VOl6mdzYTGLNQKHJGzetDiIYvKx3Vw0=; b=GVMcFadorAQIxIZWTNomiH6dz3+aiyh0Zcly5u5fId6QyWVwWMolA1XwB/Im4ljGyMocL3 RdIUt7OhreJgrEgrHnyUnjRLHhmrUERR3dehBvt0V874FZoQ6uPZb4W1GwIbNPww6KhGb2 xcyPJvHUhIDUzRByL1nR8IDzk9od819ZmYGQeFhCOGJlLDIObVbn/h/IjD+NZasf8CMJP+ uMo/LSdRml/OfFAEc/0sg52Sj7sVd1lfe9wthSWulEV2hq1Uz82nYRPycEjxvcEFByEQLl dUaWaWDdb5oxGeCuqjG1i+yRD5CatcrJYUwYx/seVR7sf9JMqFbmtb91hqBOYw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=WA3fvl4B; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1670905570; a=rsa-sha256; cv=none; b=OHY6G1ReVPNbq3q6CJW9Q91l5NWo4IUSE/XwiDYvhMlkc37JkLa5EnvGgA6OPOhhIoNRxl 10tvQTw69n9Pe8myImqtIrCnC4UwOQa2/KkXQbTSaSq8YiJHUA8ncq/ftUBrqfQEbIVr+e qW695HtxQ0Q+M1TPNpnFuzHBGM/h7uPuei3a+PGjk9RyroINg1j3cUzILuU62iK7jliAFG WQHmp0SLmEeL1lTkk9bOstoSeJPS4UsyEtKJvrac9vCgl0P3vucHF6nrx2s1265IJwofbj rDurG/r2xCi4+9AyXLRTAzJzfkJjuXF9dcPbqf+CpV3cvFadH9D+TGCTDKTySw== X-Migadu-Spam-Score: -2.36 X-Spam-Score: -2.36 X-Migadu-Queue-Id: AC28015FD7 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=WA3fvl4B; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none X-TUID: EuufJ6GNbj+o --=-=-= 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----- --=-=-=--