From d5507357ec592c858422ff330b081815e2f71c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sun, 25 Sep 2022 19:47:58 +0200 Subject: [PATCH] =?UTF-8?q?Switch=20pulsebert=20to=20pipewire=20?= =?UTF-8?q?=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/audio-server/default.nix | 49 ++++++++++++--- .../audio-server/pipewire-pulse.conf.in.json | 54 ++++++++--------- config/audio-server/pipewire-pulse.conf.json | 60 ++++++++----------- flake.nix | 8 ++- hosts/pulsebert/default.nix | 6 +- 5 files changed, 100 insertions(+), 77 deletions(-) diff --git a/config/audio-server/default.nix b/config/audio-server/default.nix index 04d9b713..9b72c767 100644 --- a/config/audio-server/default.nix +++ b/config/audio-server/default.nix @@ -16,7 +16,7 @@ }; hardware.pulseaudio = { - enable = true; + enable = !config.services.pipewire.pulse.enable; systemWide = true; tcp = { enable = true; @@ -41,14 +41,38 @@ }); }; - # pipewire has no systemwide pipewire-pulse - # services.pipewire = { - # enable = true; - # config.pipewire-pulse = lib.importJSON ./pipewire-pulse.conf.json; - # pulse.enable = true; - # socketActivation = false; - # systemWide = true; - # }; + services.pipewire = { + enable = true; + # config.pipewire-pulse = lib.importJSON ./pipewire-pulse.conf.json; + config.pipewire-pulse = + let + default-pipewire-pulse = lib.importJSON (pkgs.path + "/nixos/modules/services/desktops/pipewire/daemon/pipewire-pulse.conf.json"); + in + 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" + ]; + }; + }; + pulse.enable = true; + }; security.rtkit.enable = true; @@ -62,6 +86,13 @@ }; }; + system.activationScripts.enableLingering = lib.optionalString config.services.pipewire.pulse.enable ('' + rm -r /var/lib/systemd/linger + mkdir /var/lib/systemd/linger + '' + lib.optionalString config.c3d2.k-ot.enable '' + touch /var/lib/systemd/linger/k-ot + ''); + systemd.services.bluetooth-agent = lib.mkIf config.hardware.bluetooth.enable { description = "Allow anyone to pair via Bluetooth"; wantedBy = [ "multi-user.target" ]; diff --git a/config/audio-server/pipewire-pulse.conf.in.json b/config/audio-server/pipewire-pulse.conf.in.json index 42e6824c..37cbe15e 100644 --- a/config/audio-server/pipewire-pulse.conf.in.json +++ b/config/audio-server/pipewire-pulse.conf.in.json @@ -1,32 +1,30 @@ { - "context.modules": [ + "context.exec": [ { - "name": "libpipewire-module-zeroconf-publish" - }, - { - "name": "libpipewire-module-protocol-pulse", - "args": { - "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" - ], - "pulse.min.req": "256/48000", - "pulse.default.req": "960/48000", - "pulse.min.frag": "256/48000", - "pulse.default.frag": "96000/48000", - "pulse.default.tlength": "96000/48000", - "pulse.min.quantum": "256/48000", - "pulse.default.format": "F32" - } + "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" + ], + "pulse.min.req": "256/48000", + "pulse.default.req": "960/48000", + "pulse.min.frag": "256/48000", + "pulse.default.frag": "96000/48000", + "pulse.default.tlength": "96000/48000", + "pulse.min.quantum": "256/48000", + "pulse.default.format": "F32", + "server.address": [ + "unix:native", + "tcp:4713" + ] + } } diff --git a/config/audio-server/pipewire-pulse.conf.json b/config/audio-server/pipewire-pulse.conf.json index cb905a99..794eebea 100644 --- a/config/audio-server/pipewire-pulse.conf.json +++ b/config/audio-server/pipewire-pulse.conf.json @@ -1,4 +1,10 @@ { + "context.exec": [ + { + "path": "pactl", + "args": "load-module module-always-sink" + } + ], "context.modules": [ { "args": { @@ -23,35 +29,6 @@ "name": "libpipewire-module-metadata" }, { - "args": {}, - "name": "libpipewire-module-protocol-pulse" - }, - { - "name": "libpipewire-module-zeroconf-publish" - }, - { - "args": { - "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" - ], - "pulse.default.format": "F32", - "pulse.default.frag": "96000/48000", - "pulse.default.req": "960/48000", - "pulse.default.tlength": "96000/48000", - "pulse.min.frag": "256/48000", - "pulse.min.quantum": "256/48000", - "pulse.min.req": "256/48000", - "server.address": [ - "unix:native", - "tcp:4713" - ] - }, "name": "libpipewire-module-protocol-pulse" } ], @@ -60,16 +37,27 @@ "audio.convert.*": "audioconvert/libspa-audioconvert", "support.*": "support/libspa-support" }, - "context.exec": [ - { - "path": "pactl", - "args": "load-module module-always-sink" - } - ], "stream.properties": {}, "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" + ], + "pulse.default.format": "F32", + "pulse.default.frag": "96000/48000", + "pulse.default.req": "960/48000", + "pulse.default.tlength": "96000/48000", + "pulse.min.frag": "256/48000", + "pulse.min.quantum": "256/48000", + "pulse.min.req": "256/48000", "server.address": [ - "unix:native" + "unix:native", + "tcp:4713" ], "vm.overrides": { "pulse.min.quantum": "1024/48000" diff --git a/flake.nix b/flake.nix index af0c5d0c..83e83cdf 100644 --- a/flake.nix +++ b/flake.nix @@ -597,10 +597,14 @@ # build: outputs.nixosConfigurations.pulsebert.config.system.build.sdImage # run: unzstd -cd result/sd-image/nixos-sd-image-*-aarch64-linux.img.zst | pv -br | sudo dd bs=4M of=/dev/sdX "${inputs.nixos-unstable}/nixos/modules/installer/sd-card/sd-image-aarch64-new-kernel.nix" + { + nixpkgs = { + hostPlatform = "aarch64-linux"; + # buildPlatform = "x86_64-linux"; + }; + } ]; nixpkgs = inputs.nixos-unstable; - # system = "x86_64-linux"; - system = "aarch64-linux"; }; radiobert = nixosSystem' { diff --git a/hosts/pulsebert/default.nix b/hosts/pulsebert/default.nix index da191c05..c7c9f702 100644 --- a/hosts/pulsebert/default.nix +++ b/hosts/pulsebert/default.nix @@ -34,8 +34,10 @@ }; nix = { - buildCores = 2; - maxJobs = 1; + settings = { + cores = 2; + max-jobs = 1; + }; }; nixpkgs.config.packageOverrides = pkgs: {