From 00000704ef2cb2637956e602e070ea72d6d54486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 24 May 2023 00:41:47 +0200 Subject: [PATCH] audio-server: fix pipewire config --- modules/audio-server.nix | 102 +++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/modules/audio-server.nix b/modules/audio-server.nix index a892310a..d07c4bb3 100644 --- a/modules/audio-server.nix +++ b/modules/audio-server.nix @@ -1,5 +1,40 @@ -{ config, lib, pkgs, ... }: +{ config, is2305, lib, pkgs, ... }: +let + # _____ _______ ____ _____ + # / ____|__ __/ __ \| __ \ + # | (___ | | | | | | |__) | + # \___ \ | | | | | | ___/ + # ____) | | | | |__| | | + # |_____/ |_| \____/|_| + # + # errors such as: + # mod.zeroconf-publish: error id:47 seq:349 res:-2 (No such file or directory): enum params id:16 (Spa:Enum:ParamId:ProcessLatency) failed + # are harmless and can be ignored. You most likely want to restart your local avahi-daemon: sudo systemctl restart avahi-daemon + pipewireCfg = contextExec: { + "context.exec" = contextExec ++ [ + { + "path" = "pactl"; + "args" = "load-module module-zeroconf-publish"; + } + ]; + "pulse.properties" = { + "auth-ip-acl" = [ + "127.0.0.0/8" + "::1/128" + "fd23:42:c3d2:500::/56" + "172.22.99.0/24" + "172.20.72.0/21" + "2a00:8180:2c00:200::/56" + "2a0f:5382:acab:1400::/56" + ]; + "server.address" = [ + "unix:native" + "tcp:4713" + ]; + }; + }; +in { options.c3d2.audioServer = { enable = lib.mkEnableOption "Enable PulseAudio and Bluetooth sinks"; @@ -8,14 +43,19 @@ config = lib.mkIf config.c3d2.audioServer.enable { boot.kernelPackages = lib.mkOverride 900 pkgs.linuxPackages-rt_latest; - environment.systemPackages = with pkgs; [ - mpd - mpv - ncmpcpp - ncpamixer - pulseaudio # required for pactl - somafm-cli - ]; + environment = { + etc = lib.optionalAttrs is2305 { + "pipewire/pipewire.conf.d/audio-server.conf".text = builtins.toJSON (pipewireCfg [ ]); + }; + systemPackages = with pkgs; [ + mpd + mpv + ncmpcpp + ncpamixer + pulseaudio # required for pactl + somafm-cli + ]; + }; hardware = { bluetooth.settings = { @@ -90,43 +130,13 @@ services.pipewire = { enable = true; alsa.enable = true; # required for ledfx - config.pipewire-pulse = - let - default-pipewire-pulse = lib.importJSON (pkgs.path + "/nixos/modules/services/desktops/pipewire/daemon/pipewire-pulse.conf.json"); - in - # _____ _______ ____ _____ - # / ____|__ __/ __ \| __ \ - # | (___ | | | | | | |__) | - # \___ \ | | | | | | ___/ - # ____) | | | | |__| | | - # |_____/ |_| \____/|_| - # - # errors such as: - # mod.zeroconf-publish: error id:47 seq:349 res:-2 (No such file or directory): enum params id:16 (Spa:Enum:ParamId:ProcessLatency) failed - # are harmless and can be ignored. You most likely want to restart your local avahi-daemon: sudo systemctl restart avahi-daemon - default-pipewire-pulse // { - "context.exec" = default-pipewire-pulse."context.exec" ++ [ - { - "path" = "pactl"; - "args" = "load-module module-zeroconf-publish"; - } - ]; - "pulse.properties" = { - "auth-ip-acl" = [ - "127.0.0.0/8" - "::1/128" - "fd23:42:c3d2:500::/56" - "172.22.99.0/24" - "172.20.72.0/21" - "2a00:8180:2c00:200::/56" - "2a0f:5382:acab:1400::/56" - ]; - "server.address" = [ - "unix:native" - "tcp:4713" - ]; - }; - }; + config = lib.mkIf (!is2305) { + pipewire-pulse = + let + default-pipewire-pulse = lib.importJSON (pkgs.path + "/nixos/modules/services/desktops/pipewire/daemon/pipewire-pulse.conf.json"); + in + default-pipewire-pulse // (pipewireCfg default-pipewire-pulse."context.exec"); + }; pulse.enable = true; };