pipewire: Inline low latency module

This removes the nix-gaming dependency to achieve low latency.
This commit is contained in:
Donovan Glover 2023-06-22 09:50:04 -04:00
parent 6d5365f2b3
commit 1dcf95a7eb
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
3 changed files with 58 additions and 7 deletions

View File

@ -1,4 +1,3 @@
{ nix-gaming, ... }:
let VARIABLES = import ../src/variables.nix; in {
containers.wine = {
privateNetwork = true;
@ -36,9 +35,9 @@ let VARIABLES = import ../src/variables.nix; in {
config = { pkgs, ... }: {
imports = [
nix-gaming.nixosModules.pipewireLowLatency
../modules/pipewire.nix
];
programs = {
fish.enable = true;
neovim.enable = true;

View File

@ -1,10 +1,9 @@
{ home-manager, stylix, nix-gaming, ... }:
{ home-manager, stylix, ... }:
let VARIABLES = import ./src/variables.nix; in {
imports = [
home-manager.nixosModules.home-manager
stylix.nixosModules.stylix
nix-gaming.nixosModules.pipewireLowLatency
"${VARIABLES.hostHardwareConfiguration}"
./containers
./home

View File

@ -1,4 +1,11 @@
{ pkgs, ... }: {
{ pkgs, ... }:
let
quantum = 64;
rate = 48000;
qr = "${toString quantum}/${toString rate}";
json = pkgs.formats.json {};
in {
services.pipewire = {
enable = true;
@ -8,8 +15,6 @@
};
pulse.enable = true;
lowLatency.enable = true;
};
environment.systemPackages = with pkgs; [
@ -17,4 +22,52 @@
];
security.rtkit.enable = true;
environment.etc = {
"pipewire/pipewire.d/99-lowlatency.conf".source = json.generate "99-lowlatency.conf" {
context.properties.default.clock.min-quantum = quantum;
};
"pipewire/pipewire-pulse.d/99-lowlatency.conf".source = json.generate "99-lowlatency.conf" {
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-pulse";
args = {
pulse.min.req = qr;
pulse.min.quantum = qr;
pulse.min.frag = qr;
server.address = ["unix:native"];
};
}
];
stream.properties = {
node.latency = qr;
resample.quality = 1;
};
};
"wireplumber/main.lua.d/99-alsa-lowlatency.lua".text = /* lua */ ''
alsa_monitor.rules = {
{
matches = {{{ "node.name", "matches", "alsa_output.*" }}};
apply_properties = {
["audio.format"] = "S32LE",
["audio.rate"] = ${toString (rate * 2)},
["api.alsa.period-size"] = 2,
},
},
}
'';
};
}