From patchwork Sun Mar 5 15:19:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 47698 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 08DE716B8B; Sun, 5 Mar 2023 15:20:35 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A583516CA9 for ; Sun, 5 Mar 2023 15:20:31 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYq9f-0002Gj-3Q; Sun, 05 Mar 2023 10:20:07 -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 1pYq9b-0002G8-Uy for guix-patches@gnu.org; Sun, 05 Mar 2023 10:20:03 -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 1pYq9b-0004RX-FJ for guix-patches@gnu.org; Sun, 05 Mar 2023 10:20:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pYq9b-0003jA-74 for guix-patches@gnu.org; Sun, 05 Mar 2023 10:20:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61982] [PATCH 1/2] home: services: xdg-base-directories: Set correct value for XDG_STATE_HOME. References: In-Reply-To: Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 05 Mar 2023 15:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61982 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61982@debbugs.gnu.org Cc: Bruno Victal , philip@philipmcgrath.com Received: via spool by 61982-submit@debbugs.gnu.org id=B61982.167802956414288 (code B ref 61982); Sun, 05 Mar 2023 15:20:03 +0000 Received: (at 61982) by debbugs.gnu.org; 5 Mar 2023 15:19:24 +0000 Received: from localhost ([127.0.0.1]:40320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYq8y-0003iO-4H for submit@debbugs.gnu.org; Sun, 05 Mar 2023 10:19:24 -0500 Received: from smtpmciv1.myservices.hosting ([185.26.107.237]:33358) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYq8v-0003iB-Vg for 61982@debbugs.gnu.org; Sun, 05 Mar 2023 10:19:22 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpmciv1.myservices.hosting (Postfix) with ESMTP id D8CC420608; Sun, 5 Mar 2023 16:19:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 71D4680098; Sun, 5 Mar 2023 16:19:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aeppnyUCeKte; Sun, 5 Mar 2023 16:19:20 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id C220D80079; Sun, 5 Mar 2023 16:19:19 +0100 (CET) From: Bruno Victal Date: Sun, 5 Mar 2023 15:19:13 +0000 Message-Id: <3005f8a58ec5afc447f2baf40958956bd0d16099.1678029530.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches XDG Base Directory Specification 0.8 officially introduces the XDG_STATE_HOME environment variable. Fixes . * 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(-) base-commit: d92ec2f2812c76b23aab778e26708cf353542ae9 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 From patchwork Sun Mar 5 15:19:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 47697 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 613EB16D4B; Sun, 5 Mar 2023 15:20:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A4EF716B8B for ; Sun, 5 Mar 2023 15:20:30 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYq9f-0002HG-Cz; Sun, 05 Mar 2023 10:20:07 -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 1pYq9c-0002GW-HT for guix-patches@gnu.org; Sun, 05 Mar 2023 10:20:04 -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 1pYq9c-0004T8-8G for guix-patches@gnu.org; Sun, 05 Mar 2023 10:20:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pYq9b-0003jH-T8 for guix-patches@gnu.org; Sun, 05 Mar 2023 10:20:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61982] [PATCH 2/2] home: services: xdg-base-directories: Deprecate XDG_LOG_HOME. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 05 Mar 2023 15:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61982 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61982@debbugs.gnu.org Cc: Bruno Victal , philip@philipmcgrath.com Received: via spool by 61982-submit@debbugs.gnu.org id=B61982.167802956614295 (code B ref 61982); Sun, 05 Mar 2023 15:20:03 +0000 Received: (at 61982) by debbugs.gnu.org; 5 Mar 2023 15:19:26 +0000 Received: from localhost ([127.0.0.1]:40322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYq8z-0003iV-Ny for submit@debbugs.gnu.org; Sun, 05 Mar 2023 10:19:26 -0500 Received: from smtpm3.myservices.hosting ([185.26.105.234]:49886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYq8w-0003iC-Lh for 61982@debbugs.gnu.org; Sun, 05 Mar 2023 10:19:23 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm3.myservices.hosting (Postfix) with ESMTP id 946F920F3C; Sun, 5 Mar 2023 16:19:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 1DF9780079; Sun, 5 Mar 2023 16:19:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NnrXK_30Lla1; Sun, 5 Mar 2023 16:19:20 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-119-177.dsl.telepac.pt [85.242.119.177]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 3EEB680097; Sun, 5 Mar 2023 16:19:20 +0100 (CET) From: Bruno Victal Date: Sun, 5 Mar 2023 15:19:14 +0000 Message-Id: <0a0764da3fa04f9a02f37a7960a0c9608782854d.1678029530.git.mirai@makinata.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <3005f8a58ec5afc447f2baf40958956bd0d16099.1678029530.git.mirai@makinata.eu> References: <3005f8a58ec5afc447f2baf40958956bd0d16099.1678029530.git.mirai@makinata.eu> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches XDG_LOG_HOME is non-standard and log files should go to XDG_STATE_HOME according to the XDG Base Directory Specification. Fixes . * 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 ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2023 Bruno Victal ;;; ;;; 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).")))