From patchwork Thu Feb 2 20:07:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 46609 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 F30A327BBED; Thu, 2 Feb 2023 20:10:22 +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=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS 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 4185027BBEB for ; Thu, 2 Feb 2023 20:10:22 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNfuQ-0003qS-MS; Thu, 02 Feb 2023 15:10:14 -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 1pNfuF-0003oB-8c for guix-patches@gnu.org; Thu, 02 Feb 2023 15:10: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 1pNfuE-0004o4-GV for guix-patches@gnu.org; Thu, 02 Feb 2023 15:10:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNfuE-0007dR-CX for guix-patches@gnu.org; Thu, 02 Feb 2023 15:10:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59866] [PATCH v6 3/3] services: mpd: Do not hardcode environment variables. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 02 Feb 2023 20:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59866 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59866@debbugs.gnu.org Cc: Bruno Victal , liliana.prikler@gmail.com Received: via spool by 59866-submit@debbugs.gnu.org id=B59866.167536859229328 (code B ref 59866); Thu, 02 Feb 2023 20:10:02 +0000 Received: (at 59866) by debbugs.gnu.org; 2 Feb 2023 20:09:52 +0000 Received: from localhost ([127.0.0.1]:35887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNfu3-0007cx-L2 for submit@debbugs.gnu.org; Thu, 02 Feb 2023 15:09:51 -0500 Received: from smtpmciv6.myservices.hosting ([185.26.106.201]:47066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNfu1-0007cp-E3 for 59866@debbugs.gnu.org; Thu, 02 Feb 2023 15:09:50 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.172]) by smtpmciv6.myservices.hosting (Postfix) with ESMTP id 7B85320DE9; Thu, 2 Feb 2023 21:09:48 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 2EFF680098; Thu, 2 Feb 2023 21:09:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-1.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rtrGhNt4uFWV; Thu, 2 Feb 2023 21:09:47 +0100 (CET) Received: from guix-nuc.home.arpa (bl9-118-236.dsl.telepac.pt [85.242.118.236]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id A5A7880097; Thu, 2 Feb 2023 21:09:47 +0100 (CET) From: Bruno Victal Date: Thu, 2 Feb 2023 20:07:38 +0000 Message-Id: <6b51304098d50a01c207abddb3b02ba863034e56.1675367583.git.mirai@makinata.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <23b0f83d1fd58fce9262d0b281b34e9678e21471.1675367583.git.mirai@makinata.eu> References: <23b0f83d1fd58fce9262d0b281b34e9678e21471.1675367583.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 Services should not expect for XDG_RUNTIME_DIR to be set. Inferring from the past comment, this seemed to resolve an issue when the service was launched with an _interactive_ user-account, which tends to have this variable set by the login-manager. This is not the case for system accounts and setting this variable results in PulseAudio (launched by the same system user) failing to start since it attempts to use a nonexistent directory. Ideally, this service should have a home-service counterpart but the old behavior can be emulated by setting the environment-variables field to: (environment-variables (list (string-append "XDG_RUNTIME_DIR=/run/user/" (number->string (passwd:uid (getpwnam "myuser")))))) * gnu/services/audio.scm (mpd-configuration)[environment-variables]: New field. (mpd-shepherd-service)[start]: Use new field. * doc/guix.texi (Audio Services)[Music Player Daemon]: Document it. --- Notable changes since v5: * NEW. Fixes PulseAudio issues resulting from hardcoded environment variables. doc/guix.texi | 3 +++ gnu/services/audio.scm | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 8e220e0631..05c216bec4 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -33199,6 +33199,9 @@ Audio Services This is a list of symbols naming Shepherd services that this service will depend on. +@item @code{environment-variables} (default: @code{()}) (type: list-of-string) +A list of strings specifying environment variables. + @item @code{log-file} (default: @code{"/var/log/mpd/log"}) (type: maybe-string) The location of the log file. Set to @code{syslog} to use the local syslog daemon or @code{%unset-value} to omit this directive from the diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index 7168320635..96b27660e5 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -316,6 +316,11 @@ (define-configuration mpd-configuration will depend on." empty-serializer) + (environment-variables + (list-of-string '()) + "A list of strings specifying environment variables." + empty-serializer) + (log-file (maybe-string "/var/log/mpd/log") "The location of the log file. Set to @code{syslog} to use the @@ -465,7 +470,8 @@ (define (mpd-log-rotation config) (define (mpd-shepherd-service config) (match-record config (user package shepherd-requirement log-file playlist-directory - db-file state-file sticker-file) + db-file state-file sticker-file + environment-variables) (let* ((config-file (mpd-serialize-configuration config))) (shepherd-service (documentation "Run the MPD (Music Player Daemon)") @@ -490,11 +496,7 @@ (define (mpd-shepherd-service config) (list #$(file-append package "/bin/mpd") "--no-daemon" #$config-file) - #:environment-variables - ;; Required to detect PulseAudio when run under a user account. - (list (string-append - "XDG_RUNTIME_DIR=/run/user/" - (number->string (passwd:uid (getpwnam #$user)))))))) + #:environment-variables '#$environment-variables))) (stop #~(make-kill-destructor)) (actions (list (shepherd-configuration-action config-file)