Merge pull request #263661 from SuperSandro2000/pulseaudio-no-avahi

nixos/pulseaudio: don't create config file or enable avahi when pulse…
This commit is contained in:
Peder Bergebakken Sundt 2023-12-18 00:10:29 +01:00 committed by GitHub
commit 0f92e92565
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,8 +8,6 @@ let
cfg = config.hardware.pulseaudio; cfg = config.hardware.pulseaudio;
alsaCfg = config.sound; alsaCfg = config.sound;
systemWide = cfg.enable && cfg.systemWide;
nonSystemWide = cfg.enable && !cfg.systemWide;
hasZeroconf = let z = cfg.zeroconf; in z.publish.enable || z.discovery.enable; hasZeroconf = let z = cfg.zeroconf; in z.publish.enable || z.discovery.enable;
overriddenPackage = cfg.package.override overriddenPackage = cfg.package.override
@ -217,16 +215,10 @@ in {
}; };
config = mkMerge [ config = lib.mkIf cfg.enable (mkMerge [
{ {
environment.etc = { environment.etc."pulse/client.conf".source = clientConf;
"pulse/client.conf".source = clientConf;
};
hardware.pulseaudio.configFile = mkDefault "${getBin overriddenPackage}/etc/pulse/default.pa";
}
(mkIf cfg.enable {
environment.systemPackages = [ overriddenPackage ]; environment.systemPackages = [ overriddenPackage ];
sound.enable = true; sound.enable = true;
@ -242,6 +234,8 @@ in {
"libao.conf".source = writeText "libao.conf" "default_driver=pulse"; "libao.conf".source = writeText "libao.conf" "default_driver=pulse";
}; };
hardware.pulseaudio.configFile = mkDefault "${getBin overriddenPackage}/etc/pulse/default.pa";
# Disable flat volumes to enable relative ones # Disable flat volumes to enable relative ones
hardware.pulseaudio.daemon.config.flat-volumes = mkDefault "no"; hardware.pulseaudio.daemon.config.flat-volumes = mkDefault "no";
@ -255,7 +249,7 @@ in {
# PulseAudio is packaged with udev rules to handle various audio device quirks # PulseAudio is packaged with udev rules to handle various audio device quirks
services.udev.packages = [ overriddenPackage ]; services.udev.packages = [ overriddenPackage ];
}) }
(mkIf (cfg.extraModules != []) { (mkIf (cfg.extraModules != []) {
hardware.pulseaudio.daemon.config.dl-search-path = let hardware.pulseaudio.daemon.config.dl-search-path = let
@ -277,7 +271,7 @@ in {
services.avahi.publish.userServices = true; services.avahi.publish.userServices = true;
}) })
(mkIf nonSystemWide { (mkIf (!cfg.systemWide) {
environment.etc = { environment.etc = {
"pulse/default.pa".source = myConfigFile; "pulse/default.pa".source = myConfigFile;
}; };
@ -297,7 +291,7 @@ in {
}; };
}) })
(mkIf systemWide { (mkIf cfg.systemWide {
users.users.pulse = { users.users.pulse = {
# For some reason, PulseAudio wants UID == GID. # For some reason, PulseAudio wants UID == GID.
uid = assert uid == gid; uid; uid = assert uid == gid; uid;
@ -328,6 +322,6 @@ in {
environment.variables.PULSE_COOKIE = "${stateDir}/.config/pulse/cookie"; environment.variables.PULSE_COOKIE = "${stateDir}/.config/pulse/cookie";
}) })
]; ]);
} }