From patchwork Fri Jun 2 23:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brian Cully X-Patchwork-Id: 50555 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 7093227BBEA; Sat, 3 Jun 2023 00:06:23 +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_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 541FD27BBE2 for ; Sat, 3 Jun 2023 00:06:21 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5DqO-0006W0-Oz; Fri, 02 Jun 2023 19:06:04 -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 1q5DqN-0006Vl-7S for guix-patches@gnu.org; Fri, 02 Jun 2023 19:06:03 -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 1q5DqM-0003bD-Ve for guix-patches@gnu.org; Fri, 02 Jun 2023 19:06:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5DqM-0002dW-Q2 for guix-patches@gnu.org; Fri, 02 Jun 2023 19:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63863] [PATCH] gnu: home: Add support for home-pipewire-service Resent-From: Brian Cully Original-Sender: "Debbugs-submit" Resent-CC: , guix-patches@gnu.org Resent-Date: Fri, 02 Jun 2023 23:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 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-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: ( , Andrew Tropin , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by submit@debbugs.gnu.org id=B.168574713410089 (code B ref -1); Fri, 02 Jun 2023 23:06:02 +0000 Received: (at submit) by debbugs.gnu.org; 2 Jun 2023 23:05:34 +0000 Received: from localhost ([127.0.0.1]:41012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Dpu-0002cf-2N for submit@debbugs.gnu.org; Fri, 02 Jun 2023 19:05:34 -0400 Received: from lists.gnu.org ([209.51.188.17]:39362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Dpr-0002cW-Hg for submit@debbugs.gnu.org; Fri, 02 Jun 2023 19:05:32 -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 1q5Dpr-0006TH-9y for guix-patches@gnu.org; Fri, 02 Jun 2023 19:05:31 -0400 Received: from coleridge.kublai.com ([166.84.7.167] helo=mail.spork.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5Dpp-0003TB-7q for guix-patches@gnu.org; Fri, 02 Jun 2023 19:05:31 -0400 Received: from psyduck.jhoto.kublai.com (ool-18b8e9e7.dyn.optonline.net [24.184.233.231]) by mail.spork.org (Postfix) with ESMTPSA id 91003D002; Fri, 2 Jun 2023 19:04:42 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=spork.org; s=dkim; t=1685747083; bh=trixCC09+EKP+B1IEuTU2r2r64MHz2Kwb7LDrEIjMSQ=; h=From:To:Cc:Subject:Date; b=DP+CIh2SrwIyxVHxaYAeMHLiChTWtVwgJ8AdvFRba4asAaYefsyVgnK4cP35ip3zy mutAeU0wYDDlrg4sYaOgGmq+7vturhDdBXkWNxU4Bkged/hPfNHXMWsoD9QzeraDlo ySyi+I4cBw9+bZi1SS7IMs+ME4kbGKjWoxh7Bp4E= Date: Fri, 2 Jun 2023 19:04:27 -0400 Message-Id: <13252a733171e18f4d39d0185ddf3e8e3c06bc15.1685747062.git.bjc@spork.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Received-SPF: pass client-ip=166.84.7.167; envelope-from=bjc@spork.org; helo=mail.spork.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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 X-Patchwork-Original-From: Brian Cully via Guix-patches via From: Brian Cully Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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), (generate-doc): new procedures. (home-pipewire-service-type): new service type. (home-pipewire-configuration): new struct. * doc/guix.texi (Sound Home Services): document it. --- doc/guix.texi | 34 +++++++++++++++++ gnu/home/services/sound.scm | 74 ++++++++++++++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 1 deletion(-) base-commit: c11b92a8aae6fe7fad0da8257ec28f5009c37b35 diff --git a/doc/guix.texi b/doc/guix.texi index 7f8d8d66e9..0b19c9301f 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 @@ -43563,6 +43564,39 @@ 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. + +@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 + +@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) +Enable PulseAudio replacement. +@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..94d8bc7482 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,77 @@ (define-module (gnu home services sound) #:use-module (gnu home services) #:use-module (gnu home services shepherd) + #: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 (srfi srfi-26) #: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) "Enable PulseAudio replacement.")) + +(define (home-pipewire-shepherd-service config) + (shepherd-service + (documentation "PipeWire screen and audio sharing.") + (provision '(pipewire)) + (requirement '(dbus)) + (start #~(make-forkexec-constructor + (list #$(file-append + (home-pipewire-configuration-pipewire config) + "/bin/pipewire")))))) + +(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")))))) + +(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")))))) + +(define (home-pipewire-shepherd-services config) + (define shepherd-services + (filter + identity + (list home-pipewire-shepherd-service home-wireplumber-shepherd-service + (and (home-pipewire-configuration-enable-pulseaudio? config) + home-pipewire-pulseaudio-shepherd-service)))) + (map (cut <> config) shepherd-services)) + +(define home-pipewire-service-type + (service-type + (name 'pipewire) + (extensions + (list (service-extension home-shepherd-service-type + home-pipewire-shepherd-services))) + (description + "Start essential PipeWire services.") + (default-value (home-pipewire-configuration)))) ;;; @@ -149,3 +214,10 @@ (define home-pulseaudio-rtp-source-service-type "Define a PulseAudio source to receive audio broadcasted over RTP by another PulseAudio instance.") (default-value %pulseaudio-rtp-multicast-address))) + + +;;; +;;; Generate documentation. +;;; +(define (generate-doc) + (configuration->documentation 'home-pipewire-configuration))