From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 2E87LuaphWXPXAEAkFu2QA (envelope-from ) for ; Fri, 22 Dec 2023 16:23:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id iIxqJuaphWW4jQAAe85BDQ (envelope-from ) for ; Fri, 22 Dec 2023 16:23:18 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=TjBMWhyA; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1703258598; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=8n2x3zUI6JNfwq6gM+gKVR3d+QeCcAqggejS8LCHPAI=; b=l/2RWLyWzQ31AxxfCaM0+OyC9kU0I/b0AgLh8rETW/xKUGP7JmNgDs0IU8VuqgLs4WFa9O AGCpEvrU73H4gtROv1qPkhK+SHClTqbrUFdDbG60mm053eJr4c2n4ls1xmIE5tonjuZzcv GW8W4e4wvOoN2D5JUSypVLvrC3IHtaatNiRoR7yN2TF1omnwvQUxRjzFwYRgvxNn9Yaldo 6BuwoKQc8KcpfCnMwt2bj6us2WmkMEYJFGcw5W4mPX+1dgpGR123FKgp5sMWhMavWi/GK3 ejEW/PC3FpWS4z8nvrb8bgMi/WNnAu2VWx3wmHkaAdXZWtPuv4G05rlUNGwT5g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1703258598; a=rsa-sha256; cv=none; b=MWAmlplDnExBBAEYxYOeM+VY4tSEsztJ/+Wl7yfN5LMBD4rKe/ZHpMprF2VVnj9LC3CV9x jPyx1c25ydQvcMf8bjCygKz0Giu4wPuy7P9Kjem7V4NaB8V0JISgnQ4BUShDu1nHRLxEP2 F42t43pCT264gidUBmGMJ8GqnogkTtn4/VlZuKrYJC4Z02PHYV5xQ5pIT/RGeSy9+zs1y0 kgD7F5JhYYr4o2x0fDCxdKhCRELDcILYb4eUOtjWG2LLvg4/MP7y5XDq8SU8BvHym9hDGf VF6zw/gJA2nRjIE8nqEv7jfT3atK2f0eqoUP0gLPnqv92vgUknH5XI2qZkUymw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=TjBMWhyA; 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"; dmarc=pass (policy=none) header.from=gnu.org 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 D363D407C5 for ; Fri, 22 Dec 2023 16:23:17 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGhMe-0007zN-Am; Fri, 22 Dec 2023 10:23:04 -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 1rGhMa-0007z2-QS for guix-patches@gnu.org; Fri, 22 Dec 2023 10:23:00 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGhMX-0005pM-KF for guix-patches@gnu.org; Fri, 22 Dec 2023 10:22:59 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rGhMb-0001ci-SE for guix-patches@gnu.org; Fri, 22 Dec 2023 10:23:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#63863] [PATCH v7] gnu: home: Add support for home-pipewire-service References: <13252a733171e18f4d39d0185ddf3e8e3c06bc15.1685747062.git.bjc@spork.org> In-Reply-To: <13252a733171e18f4d39d0185ddf3e8e3c06bc15.1685747062.git.bjc@spork.org> Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: , guix-patches@gnu.org Resent-Date: Fri, 22 Dec 2023 15:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63863@debbugs.gnu.org Cc: Brian Cully , ( , Andrew Tropin , Ludovic =?UTF-8?Q?Court=C3=A8s?= X-Debbugs-Original-Xcc: ( , Andrew Tropin , Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 63863-submit@debbugs.gnu.org id=B63863.17032585366168 (code B ref 63863); Fri, 22 Dec 2023 15:23:01 +0000 Received: (at 63863) by debbugs.gnu.org; 22 Dec 2023 15:22:16 +0000 Received: from localhost ([127.0.0.1]:47615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGhLr-0001bQ-U2 for submit@debbugs.gnu.org; Fri, 22 Dec 2023 10:22:16 -0500 Received: from coleridge.kublai.com ([166.84.7.167]:56339 helo=mail.spork.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGhLo-0001bE-Ph for 63863@debbugs.gnu.org; Fri, 22 Dec 2023 10:22:14 -0500 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id 5FED917CB; Fri, 22 Dec 2023 10:22:07 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1703258527; bh=LAtE3dl10OQrIYdFvh8cqZwRVWug4pHQsVkgodj1ZGI=; h=From:To:Cc:Subject:Date; b=TjBMWhyAbPNQ9o6lgAgPO8BI+B5T5cUgW8CqLfjqyYEybXmIPy/sPNvgvilfB9/dK rrZv+4t8ydF8nm1zW1pzGHk+WzeO7M/Wo9JKtNKthRvygB6UjUOwUf9Ep+Dn+3d2O+ cPV6tMPLO+h4PvCuHMO2SI08McLtq37gCtcsYel0= Date: Fri, 22 Dec 2023 10:22:01 -0500 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: , Reply-to: Brian Cully X-ACL-Warn: , Brian Cully via Guix-patches From: Brian Cully via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.70 X-Spam-Score: -6.70 X-Migadu-Queue-Id: D363D407C5 X-Migadu-Scanner: mx11.migadu.com X-TUID: C9hYVhUKSlrl This adds a set of home shepherd services which will start the required services for a functional pipewire setup. * gnu/home/services/sound.scm (home-pipewire-shepherd-service), (home-pipewire-pulseaudio-shepherd-service), (home-wireplumber-shepherd-service), (home-pipewire-shepherd-services) (home-pipewire-asoundrc), (home-pipewire-xdg-configuration): new procedures. (home-pipewire-service-type): new service type. (home-pipewire-configuration): new struct. (home-pipewire-disable-pulseaudio-auto-start): new variable. * doc/guix.texi (Sound Home Services): document it. Change-Id: I99e0ae860de91d459c3c554ec5503bf35f785a2a --- doc/guix.texi | 72 +++++++++++++++++++++++++ gnu/home/services/sound.scm | 102 +++++++++++++++++++++++++++++++++++- 2 files changed, 173 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index e61a893af9..90888a514f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -45050,6 +45050,7 @@ Sound Home Services @cindex PulseAudio, home service @cindex RTP, for PulseAudio +@subsubheading PulseAudio RTP Streaming Services The following services dynamically reconfigure the @uref{https://pulseaudio.org,PulseAudio sound server}: they let you @@ -45137,6 +45138,77 @@ Sound Home Services This is the multicast address used by default by the two services above. @end defvar +@cindex PipeWire, home service +@subsubheading PipeWire Home Service + +@uref{https://pipewire.org, PipeWire} provides a low-latency, +graph-based audio and video processing service. In addition to its +native protocol, it can also be used as a replacement for both JACK and +PulseAudio. + +While PipeWire provides the media processing and API, it does not, +directly, know about devices such as sound cards, nor how you might want +to connect applications, hardware, and media processing filters. +Instead, PipeWire relies on a @dfn{session manager} to specify all these +relationships. While you may use any session manager you wish, for most +people the @url{https://pipewire.pages.freedesktop.org/wireplumber/, +WirePlumber} session manager, a reference implementation provided by the +PipeWire project itself, suffices, and that is the one +@code{home-pipewire-service-type} uses. + +PipeWire can be used as a replacement for PulseAudio by setting +@code{enable-pulseaudio?} to @code{#t} in +@code{home-pipewire-configuration}, so that existing PulseAudio clients +may use it without any further configuration. + +In addition, JACK clients may connect to PipeWire by using the +@command{pw-jack} program, which comes with PipeWire. Simply prefix the +command with @command{pw-jack} when you run it, and audio data should go +through PipeWire: + +@example +pw-jack mpv -ao=jack sound-file.wav +@end example + +For more information on PulseAudio emulation, see +@uref{https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-PulseAudio}, +for JACK, see +@uref{https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-JACK}. + +As PipeWire does not use @code{dbus} to start its services on demand +(as PulseAudio does), @code{home-pipewire-service-type} uses Shepherd +to start services when logged in, provisioning the @code{pipewire}, +@code{wireplumber}, and, if configured, @code{pipewire-pulseaudio} +services. @xref{Shepherd Home Service}. + +@defvar home-pipewire-service-type +This provides the service definition for @command{pipewire}, which will +run on login. Its value is a @code{home-pipewire-configuration} object. + +To start the service, add it to the @code{service} field of your +@code{home-environment}, such as: + +@lisp +(service home-pipewire-service-type) +@end lisp +@end defvar + +@deftp {Data Type} home-pipewire-configuration +Available @code{home-pipewire-configuration} fields are: + +@table @asis +@item @code{pipewire} (default: @code{pipewire}) (type: file-like) +The PipeWire package to use. + +@item @code{wireplumber} (default: @code{wireplumber}) (type: file-like) +The WirePlumber package to use. + +@item @code{enable-pulseaudio?} (default: @code{#t}) (type: boolean) +When true, enable PipeWire's PulseAudio emulation support, allowing +PulseAudio clients to use PipeWire transparently. +@end table +@end deftp + @node Mail Home Services @subsection Mail Home Services diff --git a/gnu/home/services/sound.scm b/gnu/home/services/sound.scm index 22c1a99250..313a57305b 100644 --- a/gnu/home/services/sound.scm +++ b/gnu/home/services/sound.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2023 Ludovic Courtès +;;; Copyright © 2023 Brian Cully ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,13 +20,112 @@ (define-module (gnu home services sound) #:use-module (gnu home services) #:use-module (gnu home services shepherd) + #:use-module (gnu home services xdg) + #:use-module (gnu packages linux) + #:use-module (gnu services configuration) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (home-pulseaudio-rtp-sink-service-type home-pulseaudio-rtp-source-service-type - %pulseaudio-rtp-multicast-address)) + %pulseaudio-rtp-multicast-address + + home-pipewire-configuration + home-pipewire-service-type)) + + +;;; +;;; PipeWire support. +;;; + +(define-configuration/no-serialization home-pipewire-configuration + (pipewire + (file-like pipewire) + "The PipeWire package to use.") + (wireplumber + (file-like wireplumber) + "The WirePlumber package to use.") + (enable-pulseaudio? + (boolean #t) + "When true, enable PipeWire's PulseAudio emulation support, allowing +PulseAudio clients to use PipeWire transparently.")) + +(define (home-pipewire-shepherd-service config) + (shepherd-service + (documentation "PipeWire media processing.") + (provision '(pipewire)) + (requirement '(dbus)) + (start #~(make-forkexec-constructor + (list #$(file-append + (home-pipewire-configuration-pipewire config) + "/bin/pipewire")))) + (stop #~(make-kill-destructor)))) + +(define (home-pipewire-pulseaudio-shepherd-service config) + (shepherd-service + (documentation "Drop-in PulseAudio replacement service for PipeWire.") + (provision '(pipewire-pulseaudio)) + (requirement '(pipewire)) + (start #~(make-forkexec-constructor + (list #$(file-append + (home-pipewire-configuration-pipewire config) + "/bin/pipewire-pulse")))) + (stop #~(make-kill-destructor)))) + +(define (home-wireplumber-shepherd-service config) + (shepherd-service + (documentation "WirePlumber session management for PipeWire.") + (provision '(wireplumber)) + (requirement '(pipewire)) + (start #~(make-forkexec-constructor + (list #$(file-append + (home-pipewire-configuration-wireplumber config) + "/bin/wireplumber")))) + (stop #~(make-kill-destructor)))) + +(define (home-pipewire-shepherd-services config) + (cons* (home-pipewire-shepherd-service config) + (home-wireplumber-shepherd-service config) + (if (home-pipewire-configuration-enable-pulseaudio? config) + (list (home-pipewire-pulseaudio-shepherd-service config)) + '()))) + +(define (home-pipewire-asoundrc config) + (match-record config + (pipewire) + (mixed-text-file + "asoundrc" + "<" pipewire "/share/alsa/alsa.conf.d/50-pipewire.conf>\n" + "<" pipewire "/share/alsa/alsa.conf.d/99-pipewire-default.conf>\n" + "pcm_type.pipewire {\n" + " lib \"" pipewire "/lib/alsa-lib/libasound_module_pcm_pipewire.so\"\n" + "}\n" + "ctl_type.pipewire {\n" + " lib \"" pipewire "/lib/alsa-lib/libasound_module_ctl_pipewire.so\"\n" + "}\n"))) + +(define home-pipewire-disable-pulseaudio-auto-start + (plain-file "client.conf" "autospawn = no")) + +(define (home-pipewire-xdg-configuration config) + (cons* `("alsa/asoundrc" ,(home-pipewire-asoundrc config)) + (if (home-pipewire-configuration-enable-pulseaudio? config) + `(("pulse/client.conf" + ,home-pipewire-disable-pulseaudio-auto-start)) + '()))) + +(define home-pipewire-service-type + (service-type + (name 'pipewire) + (extensions + (list (service-extension home-shepherd-service-type + home-pipewire-shepherd-services) + (service-extension home-xdg-configuration-files-service-type + home-pipewire-xdg-configuration))) + (description + "Start essential PipeWire services.") + (default-value (home-pipewire-configuration)))) ;;; base-commit: d5298c5e334e56a9aabddcb62d312e63135864f6 -- 2.41.0