From patchwork Sat Apr 23 14:39:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liliana Marie Prikler X-Patchwork-Id: 38772 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 5F31E27BBEA; Sat, 23 Apr 2022 18:07:40 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS 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 E0A1127BBE9 for ; Sat, 23 Apr 2022 18:07:39 +0100 (BST) Received: from localhost ([::1]:42946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niJER-0005tX-31 for patchwork@mira.cbaines.net; 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 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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))