diff options
author | Brian Cully <bjc@spork.org> | 2023-12-22 10:22:01 -0500 |
---|---|---|
committer | Oleg Pykhalov <go.wigust@gmail.com> | 2023-12-26 15:41:59 +0300 |
commit | afdbf7f271529573397474fdb8f1c9d00dceba37 (patch) | |
tree | bfe67443eed7d8c231168793f087caf5f2fd1edd /gnu/home | |
parent | a4a14ab6d79f6f1f926a82dd50db4655232042b7 (diff) | |
download | guix-afdbf7f271529573397474fdb8f1c9d00dceba37.tar guix-afdbf7f271529573397474fdb8f1c9d00dceba37.tar.gz |
gnu: home: Add home-pipewire service.
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-wireplumber-shepherd-service, home-pipewire-shepherd-services,
home-pipewire-asoundrc, home-pipewire-xdg-configuration,
home-pipewire-pulseaudio-shepherd-service): 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
Signed-off-by: Oleg Pykhalov <go.wigust@gmail.com>
Diffstat (limited to 'gnu/home')
-rw-r--r-- | gnu/home/services/sound.scm | 102 |
1 files changed, 101 insertions, 1 deletions
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 <ludo@gnu.org> +;;; Copyright © 2023 Brian Cully <bjc@spork.org> ;;; ;;; 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 <home-pipewire-configuration> + (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)))) ;;; |