From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id EGQmM5YPi2T4+gAASxT56A (envelope-from ) for ; Thu, 15 Jun 2023 15:18:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CGAfMpYPi2TGRgAAG6o9tA (envelope-from ) for ; Thu, 15 Jun 2023 15:18:14 +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 0CE893C0F2 for ; Thu, 15 Jun 2023 15:18:14 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q9mrT-0006Li-5V; Thu, 15 Jun 2023 09:18:03 -0400 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 1q9mrS-0006La-5F for guix-patches@gnu.org; Thu, 15 Jun 2023 09:18:02 -0400 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 1q9mrR-00051Z-Se for guix-patches@gnu.org; Thu, 15 Jun 2023 09:18:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q9mrR-0004TJ-N5 for guix-patches@gnu.org; Thu, 15 Jun 2023 09:18:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63863] [PATCH v2] 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: Thu, 15 Jun 2023 13:18: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.168683507917181 (code B ref 63863); Thu, 15 Jun 2023 13:18:01 +0000 Received: (at 63863) by debbugs.gnu.org; 15 Jun 2023 13:17:59 +0000 Received: from localhost ([127.0.0.1]:46440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9mrO-0004T2-Ig for submit@debbugs.gnu.org; Thu, 15 Jun 2023 09:17:59 -0400 Received: from coleridge.kublai.com ([166.84.7.167]:63736 helo=mail.spork.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q9mrL-0004St-JY for 63863@debbugs.gnu.org; Thu, 15 Jun 2023 09:17:57 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id BEFDFE76C; Thu, 15 Jun 2023 09:17:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1686835074; bh=KRn/mJjip4CdE66iRv4NI0greoLNEgDHe0XvbhR4RKk=; h=From:To:Cc:Subject:Date; b=lCvcPmbv9EF2jTe/0tNPjooMHU6AEneta0LR9/nr8pDx1nkxv3r96sZfw4JKkZ2Fl kjquJoMQwE8YNxcfnFvN97DCPuhb9r4qz/NFrCNXM2polvLiEaynCuoNPOtpx/57bZ rZeGGHDIJRXveLORjg+R3QnY4jApBoBgMevgeoCw= Date: Thu, 15 Jun 2023 09:16:34 -0400 Message-Id: <92a7e4009704b62b5ceddfa3fdd5bd12fb6ef91c.1686834990.git.bjc@spork.org> X-Mailer: git-send-email 2.40.1 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1686835094; 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=/I6siLhjSq8FdYYnhkUBKV1kf7xOocg9T+d5GGJX6gk=; b=ViktASGpmktH6WP/eWe2L1of6zVM+8DcTHksQxwoOw9QGO9x4oiON6JKC+xMn+ARYeR03l f4JT02ug2hBMRYnz8LIDjqRQFS3zs5YeaJ5FyyC35xBgTtdHOyLcgh1kHFC6qbwUldQ7ZL jVzB0UhI+3RPtZ4oOveE2znmyZbgTOI3gx9DuHQ4u0sJdr3r1/od9OO5O07m9FA7h4nz+y U9QUtYnD30H3eQmYXb52X3fxhSdFezjkBCDwcVhZbFzTnELL8hDzDXokrmLyWT4CeYZh4O gvt1HWykiCmc7BwPiBdJG4PZiJ6TCt3qyzXyd+HHHrizVx5+FK3WLOApCjv+nw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=lCvcPmbv; dmarc=pass (policy=none) header.from=gnu.org; 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=1686835094; a=rsa-sha256; cv=none; b=gsty88eJIkTXniaIDs+O7uQHTfEqHdSlrnNMYSzwnP8/ePCbPHVGFqMUcoWqEupIUyB5bQ /L0vCzh5uzaWDVw3SOMvi8M1Z4n8NRsgkCqkobJw2/Ju8d+ae0OfaMpc2Vye5cOqngkgme ev1Ibgeqc+pDThfLbq0H6UOG6kyoo2b3gyBeBgUovQOe1wqWR5O4sENHFGEYikWNe4kHUX WX5D0B7mBd1PnFb/5mSBi3nEAK2mmZWQ5iRGneiTWDrM4bzvtJnVOmPLu/Ln68SuWHsyOi YUxZvCcE18Nv9f3iJh8HChyuLIhp4wyy2K0toLkoe69G7nrNjonTx05K7xIw/g== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -3.73 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=spork.org header.s=dkim header.b=lCvcPmbv; dmarc=pass (policy=none) header.from=gnu.org; 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: 0CE893C0F2 X-Spam-Score: -3.73 X-TUID: 76yQVfxsn8B0 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-pulse-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. --- doc/guix.texi | 47 +++++++++++++++ gnu/home/services/sound.scm | 115 +++++++++++++++++++++++++++++++++++- 2 files changed, 161 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index 9232c82b4b..ee50d7a324 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -116,6 +116,7 @@ Copyright @copyright{} 2023 Karl Hallsby@* Copyright @copyright{} 2023 Nathaniel Nicandro@* Copyright @copyright{} 2023 Tanguy Le Carrour@* +Copyright @copyright{} 2023 Brian Cully@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -43635,6 +43636,52 @@ Sound Home Services This is the multicast address used by default by the two services above. @end defvar +@cindex 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. + +@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..5463255e8c 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,125 @@ (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) + (mixed-text-file + "asoundrc" + #~(string-append + "<" + #$(file-append + (home-pipewire-configuration-pipewire config) + "/share/alsa/alsa.conf.d/50-pipewire.conf") + ">\n" + "<" + #$(file-append + (home-pipewire-configuration-pipewire config) + "/share/alsa/alsa.conf.d/99-pipewire-default.conf") + ">\n" + "pcm_type.pipewire {\n" + " lib \"" + #$(file-append + (home-pipewire-configuration-pipewire config) + "/lib/alsa-lib/libasound_module_pcm_pipewire.so") + "\"\n}\n" + "ctl_type.pipewire {\n" + " lib \"" + #$(file-append + (home-pipewire-configuration-pipewire config) + "/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: f74df2ab879fc5457982bbc85b7455a90e82317d -- 2.40.1