Fix PipeWire configuration: use extraConfig.pipewire and remove duplicates

- Use proper services.pipewire.extraConfig.pipewire for noise suppression
- Add rnnoise-plugin to system packages
- Remove duplicate environment.etc configuration
- Simplify configuration structure
This commit is contained in:
Geir Okkenhaug Jerstad 2025-06-18 21:00:14 +02:00
parent 9c9dcdc196
commit ee6c5287b4

View file

@ -15,19 +15,61 @@
alsa.support32Bit = true; alsa.support32Bit = true;
pulse.enable = true; pulse.enable = true;
jack.enable = true; jack.enable = true;
# Enable WirePlumber session manager # Enable WirePlumber session manager
wireplumber.enable = true; wireplumber.enable = true;
# Add noise suppression and audio processing packages # Extra configuration for noise suppression
extraPackages = with pkgs; [ extraConfig.pipewire."10-noise-suppression" = {
rnnoise-plugin # RNNoise noise suppression "context.properties" = {
easyeffects # Modern audio effects and filters "default.clock.rate" = 48000;
]; "default.clock.quantum" = 1024;
"default.clock.min-quantum" = 32;
"default.clock.max-quantum" = 2048;
};
"context.modules" = [
{
name = "libpipewire-module-filter-chain";
args = {
"node.description" = "Noise Canceling Source";
"media.name" = "Noise Canceling Source";
"filter.graph" = {
nodes = [
{
type = "ladspa";
name = "rnnoise";
plugin = "${pkgs.rnnoise-plugin}/lib/ladspa/librnnoise_ladspa.so";
label = "noise_suppressor_stereo";
control = {
"VAD Threshold (%)" = 50.0;
"VAD Grace Period (ms)" = 200;
"Retroactive VAD Grace (ms)" = 0;
};
}
];
};
"capture.props" = {
"node.name" = "capture.rnnoise_source";
"node.passive" = true;
"audio.rate" = 48000;
};
"playback.props" = {
"node.name" = "rnnoise_source";
"media.class" = "Audio/Source";
"audio.rate" = 48000;
};
};
}
];
};
}; };
# Install audio management and GUI applications # Install audio management and GUI applications
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# Noise suppression plugin
rnnoise-plugin # RNNoise LADSPA plugin
# Audio control and monitoring # Audio control and monitoring
pavucontrol # PulseAudio volume control (works with PipeWire) pavucontrol # PulseAudio volume control (works with PipeWire)
helvum # Graphical patchbay for PipeWire helvum # Graphical patchbay for PipeWire
@ -49,107 +91,6 @@
# carla # Audio plugin host # carla # Audio plugin host
]; ];
# System-wide PipeWire configuration
environment.etc = {
# Main PipeWire configuration
"pipewire/pipewire.conf.d/10-noise-suppression.conf".text = ''
context.properties = {
default.clock.rate = 48000
default.clock.quantum = 1024
default.clock.min-quantum = 32
default.clock.max-quantum = 2048
}
context.modules = [
{
name = libpipewire-module-filter-chain
args = {
node.description = "Noise Canceling Source"
media.name = "Noise Canceling Source"
filter.graph = {
nodes = [
{
type = ladspa
name = rnnoise
plugin = ${pkgs.rnnoise-plugin}/lib/ladspa/librnnoise_ladspa.so
label = noise_suppressor_stereo
control = {
"VAD Threshold (%)" = 50.0
"VAD Grace Period (ms)" = 200
"Retroactive VAD Grace (ms)" = 0
}
}
]
}
capture.props = {
node.name = "capture.rnnoise_source"
node.passive = true
audio.rate = 48000
}
playback.props = {
node.name = "rnnoise_source"
media.class = "Audio/Source"
audio.rate = 48000
}
}
}
]
'';
# WirePlumber configuration for noise suppression
"wireplumber/wireplumber.conf.d/51-noise-suppression.conf".text = ''
monitor.alsa.rules = [
{
matches = [
{
device.name = "~alsa_card.*"
}
]
actions = {
update-props = {
device.profile-set = "auto"
device.auto-profile = true
}
}
}
]
monitor.bluez.rules = [
{
matches = [
{
device.name = "~bluez_card.*"
}
]
actions = {
update-props = {
bluez5.auto-connect = [ "hfp_hf" "hsp_hs" "a2dp_sink" ]
bluez5.hw-volume = [ "hfp_hf" "hsp_hs" "a2dp_sink" ]
}
}
}
]
'';
# Audio quality and latency optimization
"pipewire/pipewire-pulse.conf.d/10-audio-quality.conf".text = ''
pulse.properties = {
pulse.min.req = 32/48000
pulse.default.req = 1024/48000
pulse.min.quantum = 32/48000
pulse.max.quantum = 2048/48000
}
stream.properties = {
node.latency = 1024/48000
resample.quality = 4
channelmix.normalize = false
channelmix.mix-lfe = false
session.suspend-timeout-seconds = 0
}
'';
};
# Enable real-time audio processing # Enable real-time audio processing
security.rtkit.enable = true; security.rtkit.enable = true;