From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 QJZ+AF0yZGJIXQAAbAwnHQ (envelope-from ) for ; Sat, 23 Apr 2022 19:07:41 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id iPOrAF0yZGJSXQAA9RJhRA (envelope-from ) for ; Sat, 23 Apr 2022 19:07:41 +0200 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 9E35631A59 for ; Sat, 23 Apr 2022 19:07:40 +0200 (CEST) Received: from localhost ([::1]:42946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niJER-0005tX-QE for larch@yhetil.org; Sat, 23 Apr 2022 13:07:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niJDr-0005QM-J0 for guix-patches@gnu.org; Sat, 23 Apr 2022 13:07:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niJDr-0008WN-9I for guix-patches@gnu.org; Sat, 23 Apr 2022 13:07:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1niJDr-00074l-4w for guix-patches@gnu.org; Sat, 23 Apr 2022 13:07:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54986] [PATCH v2 3/3 WIP] services: mpd: Support socket activation. References: <9d4cc9d3ebb05d2aabf8f06e1890efe9b0b9a849.camel@gmail.com> In-Reply-To: <9d4cc9d3ebb05d2aabf8f06e1890efe9b0b9a849.camel@gmail.com> Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 23 Apr 2022 17:07:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54986 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54986@debbugs.gnu.org Cc: ludo@gnu.org Received: via spool by 54986-submit@debbugs.gnu.org id=B54986.165073360927159 (code B ref 54986); Sat, 23 Apr 2022 17:07:03 +0000 Received: (at 54986) by debbugs.gnu.org; 23 Apr 2022 17:06:49 +0000 Received: from localhost ([127.0.0.1]:57145 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1niJDd-00073u-Dq for submit@debbugs.gnu.org; Sat, 23 Apr 2022 13:06:49 -0400 Received: from mail-ej1-f68.google.com ([209.85.218.68]:35398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1niJDZ-00073A-Mt for 54986@debbugs.gnu.org; Sat, 23 Apr 2022 13:06:46 -0400 Received: by mail-ej1-f68.google.com with SMTP id l7so21987973ejn.2 for <54986@debbugs.gnu.org>; Sat, 23 Apr 2022 10:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:subject:to:cc:content-transfer-encoding:message-id :mime-version; bh=GhG4FwS5ELWHR4F8p1PH7qpP3YNN3wC1YRNv76XE5aU=; b=MLdyAEhMSHHslR5QukLaOp3EA3vMnfOW9/Q+17V3knSwgS5HgZnnoHDwkFUY1FSR0P 5EYuiVF2NoqEj/WuQ3jyguVyzFeF6BB40X3DIvdroady3RflOcTy9AJP40un0SQgCcnx IPBDFZWEMisrpEksCqncq9TKt6NF6jE/HGDrq4aZf/4OntRjPyZQzTypB4Ew5aVAi61T Izy0TnutrXdTzN4pnpOBFsRzdW7fVKji8/Tz63duvmkCPqAqR+7RjW8W4mH4qDCbCx4V B+98zmzehp7qCL8aJXw+zOMeraD01h9mTrf1Yyiy9Vpw0rMvlaMwugq9sdZpYIDEedwg STEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:subject:to:cc :content-transfer-encoding:message-id:mime-version; bh=GhG4FwS5ELWHR4F8p1PH7qpP3YNN3wC1YRNv76XE5aU=; b=D8ZkpPGUqUn6vySxJo3lsIoyk0qn9avUTfi46ZKvRpp7qys9QM5O2xCGG4YMnHjxZz Z9PzFO1EbVyi9jZf85twZxTE0SpVff7Kp/osswJcrDewJw/Jf1kyZ22/DuOvJrsdrNGO dJGQ06swgM9Lizdc5SgxyfQTQXpKo17mKL83E5GVSJdywCjXd4epVeqpOj7rL1C/Y4yT xJdMp0CppmgwEhk3UaGtvMaOnsOa5tFLkUo3Oim5NK+26UsLYZnJPerQ3q6F0FUfDDsT f4YvRUTk9Tzal7DZh1f00ZlnpjIlbUkT2w9LhI6xAIaK0cvMKjoBa/Q/kt+/hL54gTv0 c2KQ== X-Gm-Message-State: AOAM531X5d1vbH1EZjXu15ZPbi7NP4piNRGVhooI/LorTWDYvfGqeRnf bAkFot2F4TAQRjqTIpL9gQQPleUIL6A= X-Google-Smtp-Source: ABdhPJzi9eNyO/fId5sKJ/vujBN2zh7qJZSoiIylRvOvBdyVhNLk1ED9hNHrIbo/y2UnWzL6cNVpbw== X-Received: by 2002:a17:907:9805:b0:6db:4c33:7883 with SMTP id ji5-20020a170907980500b006db4c337883mr9273235ejc.555.1650733600150; Sat, 23 Apr 2022 10:06:40 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id b7-20020a170906708700b006da8440d642sm1855481ejk.113.2022.04.23.10.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 10:06:39 -0700 (PDT) From: Liliana Marie Prikler Date: Sat, 23 Apr 2022 16:39:59 +0200 Content-Transfer-Encoding: 7bit Message-ID: <155723efbcf08c6e0bb6552b8f6341d4a1f20ecb.camel@gmail.com> 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650733660; 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:dkim-signature; bh=GhG4FwS5ELWHR4F8p1PH7qpP3YNN3wC1YRNv76XE5aU=; b=HVhoO+wmz0MU7I5D9oZubW3LajrOwJh6bBA8nJNufH+3PFnoCJo4RYcC30M1fQ3OLZBvPp rruUQ6GiqKqw2UCcocpOTgiDxGx9fI2Y0290isLF4h3YWkYc757AA7V5cr5Sg/ilCLp4pO 2v42iNM3hgfdgTQ1o0hZvTfCzGPU9CFos6EDvEi+GNxEEvjHOKNugt6RpZOCpDWFPGqVt5 snYpcj2+nNUiDtmg8/VTSCptPyNt82SWlryIn12add9MaWEX9b9/Jm/sYHVsTydXIRQiBt 5on8WantA6utm/SbjCGB5lRUFkPHBiWbFuCkvP9zIAXNIwoyTMZTCrvNbF8W1w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650733660; a=rsa-sha256; cv=none; b=LSaMPyefAJJUSql6wRO4ISYrbdgWcR3I1zo3aKu/znAs2gwt5uk+VPC2Z92Y2sdNLjGWd+ wNd8aptwtBFUZqsS6Tpfc8XzWoGYLR47trpbuTW6GFauaRWRHg3heieyq0AT1qNS0yEn5f U6JkwlRjAeJT3ZHC+LzTtr0YPN2MRxm5baBRVUxLInqJZRxCPB1o9WfynyQ5QDr6ftgfvX mmW9a0Ht4xBkbjb1Kn3UqnV3mf5m/2qPzCKDpiS/hHJ5gTOxOlYD3omu29+lY4OVhd8Rip X0GhF/HcOazJwoLrPN7mK4gpnUP4HESHI/ItBpaaAgAqvelmoj4hXf6AWbHsPw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=MLdyAEhM; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: 4.68 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=MLdyAEhM; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Queue-Id: 9E35631A59 X-Spam-Score: 4.68 X-Migadu-Scanner: scn0.migadu.com X-TUID: wHQuVv7qfw6O * gnu/services/audio.scm ()[shepherd-endpoints]: New field. (mpd-shepherd-service): Use it. * doc/guix.texi (Music Player Daemon): Document it. --- doc/guix.texi | 7 +++++++ gnu/services/audio.scm | 45 ++++++++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 38aeda1d2d..6bfa854b1d 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -30883,6 +30883,13 @@ The port to run mpd on. The address that mpd will bind to. To use a Unix domain socket, an absolute path can be specified here. +@item @code{shepherd-endpoints} (default: @code{'()}) +The endpoints shepherd shall bind and spawn MPD from. If this field is +not empty (checked via @code{null?}), a systemd-style service is used +rather than a forkexec-service. This delays the start of MPD until the +first client connects. As a side effect @code{port} and @code{address} +may be ignored. + @item @code{outputs} (default: @code{"(list (mpd-output))"}) The audio outputs that MPD can use. By default this is a single output using pulseaudio. diff --git a/gnu/services/audio.scm b/gnu/services/audio.scm index c60053f33c..b184ac596a 100644 --- a/gnu/services/audio.scm +++ b/gnu/services/audio.scm @@ -78,6 +78,8 @@ (define-record-type* (default "6600")) (address mpd-configuration-address (default "any")) + (shepherd-endpoints mpd-configuration-shepherd-endpoints + (default '())) ; list of (outputs mpd-configuration-outputs (default (list (mpd-output))))) @@ -140,19 +142,36 @@ (define (mpd-shepherd-service config) (documentation "Run the MPD (Music Player Daemon)") (requirement '(user-processes)) (provision '(mpd)) - (start #~(make-forkexec-constructor - (list #$(file-append mpd "/bin/mpd") - "--no-daemon" - #$(mpd-config->file config)) - #: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 #$(mpd-configuration-user config)))))) - #:log-file #$(mpd-file-name config "log"))) - (stop #~(make-kill-destructor)))) + (start (if (null? (mpd-configuration-shepherd-endpoints config)) + #~(make-forkexec-constructor + (list #$(file-append mpd "/bin/mpd") + "--no-daemon" + #$(mpd-config->file config)) + #: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 #$(mpd-configuration-user config)))))) + #:log-file #$(mpd-file-name config "log")) + #~(make-systemd-constructor + (list #$(file-append mpd "/bin/mpd") + "--systemd" + #$(mpd-config->file config)) + (list #$@(map shepherd-endpoint->sexp + (mpd-configuration-shepherd-endpoints config))) + #: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 #$(mpd-configuration-user config)))))) + #:log-file #$(mpd-file-name config "log")))) + (stop (if (null? (mpd-configuration-shepherd-endpoints config)) + #~(make-kill-destructor) + #~(make-systemd-destructor))))) (define (mpd-service-activation config) (with-imported-modules '((guix build utils)) -- 2.35.1