all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#63863] [PATCH] gnu: home: Add support for home-pipewire-service
@ 2023-06-02 23:04 Brian Cully via Guix-patches via
  2023-06-09 20:22 ` Ludovic Courtès
                   ` (12 more replies)
  0 siblings, 13 replies; 27+ messages in thread
From: Brian Cully via Guix-patches via @ 2023-06-02 23:04 UTC (permalink / raw)
  To: 63863; +Cc: Brian Cully

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(-)

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 <ludo@gnu.org>
+;;; Copyright © 2023 Brian Cully <bjc@spork.org>
 ;;;
 ;;; 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))
+
+\f
+;;;
+;;; 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))))
 
 \f
 ;;;
@@ -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)))
+
+\f
+;;;
+;;; Generate documentation.
+;;;
+(define (generate-doc)
+  (configuration->documentation 'home-pipewire-configuration))

base-commit: c11b92a8aae6fe7fad0da8257ec28f5009c37b35
-- 
2.40.1





^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-12-26 12:59 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02 23:04 [bug#63863] [PATCH] gnu: home: Add support for home-pipewire-service Brian Cully via Guix-patches via
2023-06-09 20:22 ` Ludovic Courtès
2023-06-12  5:50 ` Andrew Tropin
2023-06-12 15:56   ` Brian Cully via Guix-patches via
2023-06-13  4:39     ` Andrew Tropin
2023-06-13 12:20       ` Brian Cully via Guix-patches via
2023-06-14  9:08         ` Andrew Tropin
2023-06-15 13:16 ` [bug#63863] [PATCH v2] " Brian Cully via Guix-patches via
2023-06-15 13:19   ` Brian Cully via Guix-patches via
2023-06-15 13:26 ` [bug#63863] [PATCH v3] " Brian Cully via Guix-patches via
2023-06-15 13:27   ` Brian Cully via Guix-patches via
2023-06-20 12:41 ` [bug#63863] [PATCH v4 0/1] " Brian Cully via Guix-patches via
2023-06-20 12:41   ` [bug#63863] [PATCH v4 1/1] " Brian Cully via Guix-patches via
2023-07-02 12:39 ` [bug#63863] [PATCH v5 0/1] " Brian Cully via Guix-patches via
2023-07-02 12:39   ` [bug#63863] [PATCH v5 1/1] " Brian Cully via Guix-patches via
2023-11-12 14:14     ` Hilton Chain via Guix-patches via
2023-08-23  8:25 ` Tanguy LE CARROUR
2023-08-23 18:44   ` brian via Guix-patches via
2023-08-25  6:44     ` Tanguy LE CARROUR
2023-10-11 11:34 ` taosabella
2023-11-05 15:09 ` [bug#63863] (no subject) Jakob Honal
2023-12-16 15:17 ` [bug#63863] [PATCH v5 1/1] gnu: home: Add support for home-pipewire-service Brian Cully via Guix-patches via
2023-12-16 15:23 ` [bug#63863] [PATCH v6] " Brian Cully via Guix-patches via
2023-12-20  8:46   ` bug#63863: " Oleg Pykhalov
2023-12-22 15:22 ` [bug#63863] [PATCH v7] " Brian Cully via Guix-patches via
     [not found] ` <handler.63863.D63863.17030619999937.notifdone@debbugs.gnu.org>
2023-12-22 15:22   ` [bug#63863] closed (Re: [bug#63863] [PATCH v6] gnu: home: Add support for home-pipewire-service) Brian Cully via Guix-patches via
2023-12-26 12:57     ` bug#63863: " Oleg Pykhalov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.