c7cb07f092
GitOrigin-RevId: 1536926ef5621b09bba54035ae2bb6d806d72ac8
136 lines
5 KiB
Nix
136 lines
5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
pwCfg = config.services.pipewire;
|
|
cfg = pwCfg.wireplumber;
|
|
pwUsedForAudio = pwCfg.audio.enable;
|
|
in
|
|
{
|
|
meta.maintainers = [ lib.maintainers.k900 ];
|
|
|
|
options = {
|
|
services.pipewire.wireplumber = {
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = config.services.pipewire.enable;
|
|
defaultText = lib.literalExpression "config.services.pipewire.enable";
|
|
description = lib.mdDoc "Whether to enable WirePlumber, a modular session / policy manager for PipeWire";
|
|
};
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = pkgs.wireplumber;
|
|
defaultText = lib.literalExpression "pkgs.wireplumber";
|
|
description = lib.mdDoc "The WirePlumber derivation to use.";
|
|
};
|
|
|
|
configPackages = lib.mkOption {
|
|
type = lib.types.listOf lib.types.package;
|
|
default = [ ];
|
|
description = lib.mdDoc ''
|
|
List of packages that provide WirePlumber configuration, in the form of
|
|
`share/wireplumber/*/*.lua` files.
|
|
'';
|
|
};
|
|
|
|
extraLv2Packages = lib.mkOption {
|
|
type = lib.types.listOf lib.types.package;
|
|
default = [];
|
|
example = lib.literalExpression "[ pkgs.lsp-plugins ]";
|
|
description = lib.mdDoc ''
|
|
List of packages that provide LV2 plugins in `lib/lv2` that should
|
|
be made available to WirePlumber for [filter chains][wiki-filter-chain].
|
|
|
|
Config packages have their required LV2 plugins added automatically,
|
|
so they don't need to be specified here.
|
|
|
|
[wiki-filter-chain]: https://docs.pipewire.org/page_module_filter_chain.html
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config =
|
|
let
|
|
pwNotForAudioConfigPkg = pkgs.writeTextDir "share/wireplumber/main.lua.d/80-pw-not-for-audio.lua" ''
|
|
-- PipeWire is not used for audio, so prevent it from grabbing audio devices
|
|
alsa_monitor.enable = function() end
|
|
'';
|
|
systemwideConfigPkg = pkgs.writeTextDir "share/wireplumber/main.lua.d/80-systemwide.lua" ''
|
|
-- When running system-wide, these settings need to be disabled (they
|
|
-- use functions that aren't available on the system dbus).
|
|
alsa_monitor.properties["alsa.reserve"] = false
|
|
default_access.properties["enable-flatpak-portal"] = false
|
|
'';
|
|
systemwideBluetoothConfigPkg = pkgs.writeTextDir "share/wireplumber/bluetooth.lua.d/80-systemwide.lua" ''
|
|
-- When running system-wide, logind-integration needs to be disabled.
|
|
bluez_monitor.properties["with-logind"] = false
|
|
'';
|
|
|
|
configPackages = cfg.configPackages
|
|
++ lib.optional (!pwUsedForAudio) pwNotForAudioConfigPkg
|
|
++ lib.optionals config.services.pipewire.systemWide [ systemwideConfigPkg systemwideBluetoothConfigPkg ];
|
|
|
|
configs = pkgs.buildEnv {
|
|
name = "wireplumber-configs";
|
|
paths = configPackages;
|
|
pathsToLink = [ "/share/wireplumber" ];
|
|
};
|
|
|
|
requiredLv2Packages = lib.flatten
|
|
(
|
|
lib.concatMap
|
|
(p:
|
|
lib.attrByPath ["passthru" "requiredLv2Packages"] [] p
|
|
)
|
|
configPackages
|
|
);
|
|
|
|
lv2Plugins = pkgs.buildEnv {
|
|
name = "wireplumber-lv2-plugins";
|
|
paths = cfg.extraLv2Packages ++ requiredLv2Packages;
|
|
pathsToLink = [ "/lib/lv2" ];
|
|
};
|
|
in
|
|
lib.mkIf cfg.enable {
|
|
assertions = [
|
|
{
|
|
assertion = !config.hardware.bluetooth.hsphfpd.enable;
|
|
message = "Using WirePlumber conflicts with hsphfpd, as it provides the same functionality. `hardware.bluetooth.hsphfpd.enable` needs be set to false";
|
|
}
|
|
{
|
|
assertion = builtins.length
|
|
(builtins.attrNames
|
|
(
|
|
lib.filterAttrs
|
|
(name: value:
|
|
lib.hasPrefix "wireplumber/" name || name == "wireplumber"
|
|
)
|
|
config.environment.etc
|
|
)) == 1;
|
|
message = "Using `environment.etc.\"wireplumber<...>\"` directly is no longer supported in 24.05. Use `services.wireplumber.configPackages` instead.";
|
|
}
|
|
];
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
environment.etc.wireplumber.source = "${configs}/share/wireplumber";
|
|
|
|
systemd.packages = [ cfg.package ];
|
|
|
|
systemd.services.wireplumber.enable = config.services.pipewire.systemWide;
|
|
systemd.user.services.wireplumber.enable = !config.services.pipewire.systemWide;
|
|
|
|
systemd.services.wireplumber.wantedBy = [ "pipewire.service" ];
|
|
systemd.user.services.wireplumber.wantedBy = [ "pipewire.service" ];
|
|
|
|
systemd.services.wireplumber.environment = lib.mkIf config.services.pipewire.systemWide {
|
|
# Force WirePlumber to use system dbus.
|
|
DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/dbus/system_bus_socket";
|
|
LV2_PATH = "${lv2Plugins}/lib/lv2";
|
|
};
|
|
|
|
systemd.user.services.wireplumber.environment.LV2_PATH =
|
|
lib.mkIf (!config.services.pipewire.systemWide) "${lv2Plugins}/lib/lv2";
|
|
};
|
|
}
|