nixos/pipewire: unbreak mixed Pulse/Pipewire setups

Fixes #163066
This commit is contained in:
K900 2022-03-22 11:10:47 +03:00
parent 74c1fd0b5e
commit 1dbc26d995
2 changed files with 13 additions and 3 deletions

View File

@ -39,6 +39,8 @@ let
pipewire = recursiveUpdate (if useSessionManager then defaults.pipewire else defaults.minimal) cfg.config.pipewire;
pipewire-pulse = recursiveUpdate defaults.pipewire-pulse cfg.config.pipewire-pulse;
};
usedForAudio = cfg.pulse.enable || cfg.alsa.enable || cfg.jack.enable;
in {
meta = {
@ -152,8 +154,8 @@ in {
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.pulse.enable -> !config.hardware.pulseaudio.enable;
message = "PipeWire based PulseAudio server emulation replaces PulseAudio. This option requires `hardware.pulseaudio.enable` to be set to false";
assertion = usedForAudio -> !config.hardware.pulseaudio.enable;
message = "Using PipeWire as a sound server conflicts with PulseAudio. This option requires `hardware.pulseaudio.enable` to be set to false";
}
{
assertion = cfg.jack.enable -> !config.services.jack.jackd.enable;

View File

@ -1,7 +1,9 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.pipewire.wireplumber;
pwCfg = config.services.pipewire;
cfg = pwCfg.wireplumber;
pwUsedForAudio = pwCfg.pulse.enable || pwCfg.alsa.enable || pwCfg.jack.enable;
in
{
meta.maintainers = [ lib.maintainers.k900 ];
@ -33,6 +35,12 @@ in
];
environment.systemPackages = [ cfg.package ];
environment.etc.wireplumber."main.lua.d"."80-nixos.lua".text = if !pwUsedForAudio then ''
# Pipewire is not used for audio, so prevent it from grabbing audio devices
alsa_monitor.enable = function() end
'' else "";
systemd.packages = [ cfg.package ];
systemd.services.wireplumber.enable = config.services.pipewire.systemWide;