modules/ryan-services/pipewire.scm
c12f78564d0d7f98bd0440ea743cdd66449d3366
· 4.1 KB · 99 lines
raw
| 1 | (define-module (ryan-services pipewire) |
| 2 | #:use-module (gnu packages) |
| 3 | #:use-module (gnu packages linux) |
| 4 | #:use-module (gnu services) |
| 5 | #:use-module (gnu services configuration) |
| 6 | #:use-module (gnu home services) |
| 7 | #:use-module (gnu home services shepherd) |
| 8 | #:use-module (guix gexp)) |
| 9 | |
| 10 | (define (home-pipewire-profile-service config) |
| 11 | (map specification->package |
| 12 | (list "pipewire" |
| 13 | "wireplumber"))) |
| 14 | |
| 15 | (define (home-pipewire-shepherd-service config) |
| 16 | (list |
| 17 | ;; Pipewire daemon |
| 18 | (shepherd-service |
| 19 | (requirement '(dbus)) |
| 20 | (provision '(pipewire)) |
| 21 | (stop #~(make-kill-destructor)) |
| 22 | (start #~(make-forkexec-constructor |
| 23 | (list #$(file-append pipewire "/bin/pipewire")) |
| 24 | #:log-file (string-append |
| 25 | (or (getenv "XDG_LOG_HOME") |
| 26 | (format #f "~a/.local/var/log" |
| 27 | (getenv "HOME"))) |
| 28 | "/pipewire.log") |
| 29 | #:environment-variables |
| 30 | (append (list "DISABLE_RTKIT=0") |
| 31 | (default-environment-variables))))) |
| 32 | ;; Pipewire-pulse |
| 33 | (shepherd-service |
| 34 | (requirement '(pipewire)) |
| 35 | (provision '(pipewire-pulse)) |
| 36 | (stop #~(make-kill-destructor)) |
| 37 | (start #~(make-forkexec-constructor |
| 38 | (list #$(file-append pipewire "/bin/pipewire-pulse")) |
| 39 | #:log-file (string-append |
| 40 | (or (getenv "XDG_LOG_HOME") |
| 41 | (format #f "~a/.local/var/log" |
| 42 | (getenv "HOME"))) |
| 43 | "/pipewire-pulse.log") |
| 44 | #:environment-variables |
| 45 | (append (list "DISABLE_RTKIT=0") |
| 46 | (default-environment-variables))))) |
| 47 | ;; Wireplumber |
| 48 | (shepherd-service |
| 49 | (requirement '(pipewire)) |
| 50 | (provision '(wireplumber)) |
| 51 | (stop #~(make-kill-destructor)) |
| 52 | (start #~(make-forkexec-constructor |
| 53 | (list #$(file-append wireplumber "/bin/wireplumber")) |
| 54 | #:log-file (string-append |
| 55 | (or (getenv "XDG_LOG_HOME") |
| 56 | (format #f "~a/.local/var/log" |
| 57 | (getenv "HOME"))) |
| 58 | "/wireplumber.log") |
| 59 | #:environment-variables |
| 60 | (append (list "DISABLE_RTKIT=0") |
| 61 | (default-environment-variables))))))) |
| 62 | |
| 63 | (define (home-pipewire-xdg-configuration-service config) |
| 64 | `(("alsa/asoundrc" |
| 65 | ,(mixed-text-file |
| 66 | "asoundrc" |
| 67 | #~(string-append |
| 68 | "<" |
| 69 | #$(file-append |
| 70 | pipewire "/share/alsa/alsa.conf.d/50-pipewire.conf") |
| 71 | ">\n<" |
| 72 | #$(file-append |
| 73 | pipewire "/share/alsa/alsa.conf.d/99-pipewire-default.conf") |
| 74 | ">\n" |
| 75 | " |
| 76 | pcm_type.pipewire { |
| 77 | lib " #$(file-append pipewire "/lib/alsa-lib/libasound_module_pcm_pipewire.so") |
| 78 | " |
| 79 | } |
| 80 | ctl_type.pipewire { |
| 81 | lib " #$(file-append pipewire "/lib/alsa-lib/libasound_module_ctl_pipewire.so") |
| 82 | " |
| 83 | } |
| 84 | "))))) |
| 85 | |
| 86 | (define-public home-pipewire-service-type |
| 87 | (service-type (name 'home-pipewire) |
| 88 | (extensions |
| 89 | (list (service-extension |
| 90 | home-profile-service-type |
| 91 | home-pipewire-profile-service) |
| 92 | (service-extension |
| 93 | home-shepherd-service-type |
| 94 | home-pipewire-shepherd-service) |
| 95 | (service-extension |
| 96 | home-xdg-configuration-files-service-type |
| 97 | home-pipewire-xdg-configuration-service))) |
| 98 | (default-value #f) |
| 99 | (description "Configures and runs Pipewire and Wireplumber"))) |