Files
nixos/modules/audio/default.nix

126 lines
3.1 KiB
Nix

{ pkgs, ... }:
let
linkSinksScript = pkgs.writeShellApplication {
name = "link-virtual-sinks";
runtimeInputs = with pkgs; [
coreutils
gnugrep
pipewire
];
runtimeEnv = {
USB_C_SINK = "alsa_output.usb-HP__Inc_HyperX_Cloud_III_Wireless_0000000000000000-00.analog-stereo";
};
text = builtins.readFile ./linkSinks.sh;
};
in
{
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
# disable automatic gain control for specific apps
extraConfig.pipewire-pulse."10-block-source-volume.conf"."pulse.rules" = [
{
matches = [
{ "application.name" = "~Chromium.*"; }
{ "application.process.binary" = "Discord"; }
{ "application.process.binary" = "vesktop"; }
# TODO: add element to this list
];
actions.quirks = [ "block-source-volume" ];
}
];
extraConfig.pipewire."91-virtual-sinks" = {
"context.objects" = [
{
factory = "adapter";
args = {
"factory.name" = "support.null-audio-sink";
"node.name" = "game";
"node.description" = "game";
"media.class" = "Audio/Sink";
"audio.position" = "FL,FR";
};
}
{
factory = "adapter";
args = {
"factory.name" = "support.null-audio-sink";
"node.name" = "clementine";
"node.description" = "clementine";
"media.class" = "Audio/Sink";
"audio.position" = "FL,FR";
};
}
{
factory = "adapter";
args = {
"factory.name" = "support.null-audio-sink";
"node.name" = "element";
"node.description" = "element";
"media.class" = "Audio/Sink";
"audio.position" = "FL,FR";
};
}
{
factory = "adapter";
args = {
"factory.name" = "support.null-audio-sink";
"node.name" = "combine";
"node.description" = "combine";
"media.class" = "Audio/Sink";
"audio.position" = "FL,FR";
};
}
];
};
wireplumber.extraConfig."91-default-sink" = {
"wireplumber.settings" = {
"default.audio.sink" = "combine";
};
};
};
programs.nix-ld.libraries = [ pkgs.pipewire ];
systemd.user.services.link-virtual-sinks = {
description = "Link virtual PipeWire sinks";
wantedBy = [ "graphical-session.target" ];
wants = [
"pipewire.service"
"wireplumber.service"
];
after = [
"pipewire.service"
"wireplumber.service"
];
serviceConfig = {
Type = "oneshot";
ExecStart = "${linkSinksScript}/bin/link-virtual-sinks";
RemainAfterExit = true;
};
};
# home-manager.users.djai.home.packages = with pkgs; [
# pavucontrol
# qpwgraph
# ];
users.users.djai.packages = with pkgs; [
pavucontrol
pipewire
qpwgraph
];
}