From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YCGOIq4Y3GN3TAEAbAwnHQ (envelope-from ) for ; Thu, 02 Feb 2023 21:10:22 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id wD+2Ia4Y3GOVkAAAG6o9tA (envelope-from ) for ; Thu, 02 Feb 2023 21:10:22 +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 549FF2EEE5 for ; Thu, 2 Feb 2023 21:10:22 +0100 (CET) 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 Content-Transfer-Encoding: 8bit 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=1675368622; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: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; bh=B73pZuyy0zHifNtgMjpayctdqmtXwPdoTnXynGT/1WA=; b=sQQ8wXskWA3WLejZuCwhJ192wldO4baKE7bVe65b5LITgmBXwToOee46lBfs0h4kLwXDuf pTqclP1jkxuu6IW5hPtN+RsmWRJlwdW73sH3gGsP208VcD7o5ewfvo6UCoGVzFCo3ZA3wI RMaxi69M1CyUQuDbuZ/hamoObwfL6wFLdGZOYcAiq8oE64z/35nHOLzVtZYc72BZMLX8i9 DKTk+I1xCBxRKxYH57OJdv+XmSfFPVcyiaRR6H2qszNkxmnGK0cb8kHpWFi1fTQQ67s312 +TKorm/XGOgSpIzbNamWvI3GOlxZ/sEKl39IolYgQOAQNHEvyeSroEBu7NJwIQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675368622; a=rsa-sha256; cv=none; b=HfIMdFDc8Bpk0rhLl6cuyl1PFEX0KsgqyKQxuZsx6jE1N4OaxgNE990CZ/2JiDVYjYGk+n yeq08re5RfR8wQsTNucQRZXNQ8ZHg/HS3IDbOx1ORuAY4kXnHps2RH5MOM674nNHqdt5r1 lNDlMDNKfO9wgKrr+CS0H2RB2K/lWjJJlN87iE4RNh4oqEJsQxPi34DgcqJyGlht/3/5wc h+6UDc0q8bQhniUVnsabXmF1lJxcxIfrnMuvR3iuuRhL3sDGXZSyBax7UkvPf1m6D31iFu l7WS84zrzTNO/15BWarL0hsyYb3iiEofB2AO+GbLHdPLvAlJ/1Rtx3WubCkM7A== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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" X-Migadu-Spam-Score: -0.08 X-Spam-Score: -0.08 X-Migadu-Queue-Id: 549FF2EEE5 X-TUID: z79VnDKeN3kL 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) -- 2.38.1