From 4313ea9351318bdad026139a1b0d10b4c3f96d16 Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Sat, 15 May 2021 19:23:43 +0700 Subject: [PATCH] pipewire --- cfg/winter/audio.nix | 107 +++++++++++++++++++++++++++++++++++++++++++ cfg/winter/main.nix | 4 +- 2 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 cfg/winter/audio.nix diff --git a/cfg/winter/audio.nix b/cfg/winter/audio.nix new file mode 100644 index 0000000..dadfab7 --- /dev/null +++ b/cfg/winter/audio.nix @@ -0,0 +1,107 @@ +{ config, ... }: +let + int = { + quantum = { + min = 128; + def = 256; + max = 2048; + }; + rate = 48000; + }; + str = { + quantum = { + min = toString int.quantum.min; + def = toString int.quantum.def; + max = toString int.quantum.max; + }; + rate = toString int.rate; + }; +in { + sound.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + + config.pipewire = { + "context.properties" = { + "link.max-buffers" = 16; + "default.clock.rate" = int.rate; + "default.clock.quantum" = int.quantum.def; + "default.clock.min-quantum" = int.quantum.min; + "default.clock.max-quantum" = int.quantum.max; + "core.daemon" = true; + "core.name" = "pipewire-0"; + }; + + "context.modules" = [ + { + name = "libpipewire-module-rtkit"; + args = { + "nice.level" = -15; + "rt.prio" = 88; + "rt.time.soft" = 200000; + "rt.time.hard" = 200000; + }; + flags = [ "ifexists" "nofail" ]; + } + { name = "libpipewire-module-protocol-native"; } + { name = "libpipewire-module-profiler"; } + { name = "libpipewire-module-metadata"; } + { name = "libpipewire-module-spa-device-factory"; } + { name = "libpipewire-module-spa-node-factory"; } + { name = "libpipewire-module-client-node"; } + { name = "libpipewire-module-client-device"; } + { + name = "libpipewire-module-portal"; + flags = [ "ifexists" "nofail" ]; + } + { name = "libpipewire-module-access"; args = {}; } + { name = "libpipewire-module-adapter"; } + { name = "libpipewire-module-link-factory"; } + { name = "libpipewire-module-session-manager"; } + ]; + "stream.properties" = { + "node.latency" = "${str.quantum.min}/${str.rate}"; + "resample.quality" = 1; + }; + }; + config.pipewire-pulse = { + "context.modules" = [ + { + name = "libpipewire-module-rtkit"; + args = { + "nice.level" = -15; + "rt.prio" = 88; + "rt.time.soft" = 200000; + "rt.time.hard" = 200000; + }; + flags = [ "ifexists" "nofail" ]; + } + { name = "libpipewire-module-protocol-native"; } + { name = "libpipewire-module-client-node"; } + { name = "libpipewire-module-adapter"; } + { name = "libpipewire-module-metadata"; } + { + name = "libpipewire-module-protocol-pulse"; + args = { + "pulse.min.req" = "${str.quantum.min}/${str.rate}"; + "pulse.default.req" = "${str.quantum.def}/${str.rate}"; + "pulse.max.req" = "${str.quantum.max}/${str.rate}"; + "pulse.min.quantum" = "${str.quantum.min}/${str.rate}"; + "pulse.max.quantum" = "${str.quantum.max}/${str.rate}"; + "server.address" = [ "unix:native" ]; + }; + } + ]; + "stream.properties" = { + "node.latency" = "${str.quantum.min}/${str.rate}"; + "resample.quality" = 1; + }; + }; + }; +} + diff --git a/cfg/winter/main.nix b/cfg/winter/main.nix index d1bb863..66167dd 100644 --- a/cfg/winter/main.nix +++ b/cfg/winter/main.nix @@ -5,6 +5,7 @@ environment.etc."machine-id".source = "/mnt/bcachefs/machine-id"; imports = [ + ./audio.nix ./gui.nix ./hardware-configuration.nix ./kernel.nix @@ -31,9 +32,6 @@ # time.timeZone = ""; i18n.defaultLocale = "en_GB.UTF-8"; - sound.enable = true; - hardware.pulseaudio.enable = true; - users.mutableUsers = false; users.users.lava = { isNormalUser = true;