mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 15:33:13 +00:00
nixos/pipewire: introduce an explicit option to use Pipewire as audio server
This commit is contained in:
parent
1dbc26d995
commit
435a5b675b
@ -110,6 +110,11 @@ in {
|
||||
source = json.generate "v4l2-monitor.conf" configs.v4l2-monitor;
|
||||
};
|
||||
|
||||
environment.etc."pipewire/media-session.d/with-audio" =
|
||||
mkIf config.services.pipewire.audio.enable {
|
||||
text = "";
|
||||
};
|
||||
|
||||
environment.etc."pipewire/media-session.d/with-alsa" =
|
||||
mkIf config.services.pipewire.alsa.enable {
|
||||
text = "";
|
||||
|
@ -39,8 +39,6 @@ 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 = {
|
||||
@ -118,6 +116,16 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
audio = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
# this is for backwards compatibility
|
||||
default = cfg.alsa.enable || cfg.jack.enable || cfg.pulse.enable;
|
||||
defaultText = lib.literalExpression "config.services.pipewire.alsa.enable || config.services.pipewire.jack.enable || config.services.pipewire.pulse.enable";
|
||||
description = "Whether to use PipeWire as the primary sound server";
|
||||
};
|
||||
};
|
||||
|
||||
alsa = {
|
||||
enable = mkEnableOption "ALSA support";
|
||||
support32Bit = mkEnableOption "32-bit ALSA support on 64-bit systems";
|
||||
@ -154,13 +162,18 @@ in {
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
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.audio.enable -> !config.hardware.pulseaudio.enable;
|
||||
message = "Using PipeWire as the 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;
|
||||
message = "PipeWire based JACK emulation doesn't use the JACK service. This option requires `services.jack.jackd.enable` to be set to false";
|
||||
}
|
||||
{
|
||||
# JACK intentionally not checked, as PW-on-JACK setups are a thing that some people may want
|
||||
assertion = (cfg.alsa.enable || cfg.pulse.enable) -> cfg.audio.enable;
|
||||
message = "Using PipeWire's ALSA/PulseAudio compatibility layers requires running PipeWire as the sound server. Set `services.pipewire.audio.enable` to true.";
|
||||
}
|
||||
];
|
||||
|
||||
environment.systemPackages = [ cfg.package ]
|
||||
|
@ -3,7 +3,7 @@
|
||||
let
|
||||
pwCfg = config.services.pipewire;
|
||||
cfg = pwCfg.wireplumber;
|
||||
pwUsedForAudio = pwCfg.pulse.enable || pwCfg.alsa.enable || pwCfg.jack.enable;
|
||||
pwUsedForAudio = pwCfg.audio.enable;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.k900 ];
|
||||
@ -36,10 +36,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 "";
|
||||
environment.etc."wireplumber/main.lua.d/80-nixos.lua" = lib.mkIf (!pwUsedForAudio) {
|
||||
text = ''
|
||||
# Pipewire is not used for audio, so prevent it from grabbing audio devices
|
||||
alsa_monitor.enable = function() end
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.packages = [ cfg.package ];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user