2022-01-13 20:06:32 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2022-03-30 09:31:56 +00:00
|
|
|
pwCfg = config.services.pipewire;
|
|
|
|
cfg = pwCfg.wireplumber;
|
|
|
|
pwUsedForAudio = pwCfg.audio.enable;
|
2022-01-13 20:06:32 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
meta.maintainers = [ lib.maintainers.k900 ];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.pipewire.wireplumber = {
|
2022-03-05 16:20:37 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = config.services.pipewire.enable;
|
|
|
|
defaultText = lib.literalExpression "config.services.pipewire.enable";
|
2024-02-29 20:09:43 +00:00
|
|
|
description = lib.mdDoc "Whether to enable WirePlumber, a modular session / policy manager for PipeWire";
|
2022-03-05 16:20:37 +00:00
|
|
|
};
|
2022-01-13 20:06:32 +00:00
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
default = pkgs.wireplumber;
|
|
|
|
defaultText = lib.literalExpression "pkgs.wireplumber";
|
2024-02-29 20:09:43 +00:00
|
|
|
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.
|
|
|
|
'';
|
2022-01-13 20:06:32 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
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].
|
2022-01-13 20:06:32 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
Config packages have their required LV2 plugins added automatically,
|
|
|
|
so they don't need to be specified here.
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
[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
|
2022-03-30 09:31:56 +00:00
|
|
|
alsa_monitor.enable = function() end
|
|
|
|
'';
|
2024-02-29 20:09:43 +00:00
|
|
|
systemwideConfigPkg = pkgs.writeTextDir "share/wireplumber/main.lua.d/80-systemwide.lua" ''
|
2022-06-26 10:26:21 +00:00
|
|
|
-- 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
|
|
|
|
'';
|
2024-02-29 20:09:43 +00:00
|
|
|
systemwideBluetoothConfigPkg = pkgs.writeTextDir "share/wireplumber/bluetooth.lua.d/80-systemwide.lua" ''
|
2022-07-14 12:49:19 +00:00
|
|
|
-- When running system-wide, logind-integration needs to be disabled.
|
|
|
|
bluez_monitor.properties["with-logind"] = false
|
|
|
|
'';
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
configPackages = cfg.configPackages
|
|
|
|
++ lib.optional (!pwUsedForAudio) pwNotForAudioConfigPkg
|
|
|
|
++ lib.optionals config.services.pipewire.systemWide [ systemwideConfigPkg systemwideBluetoothConfigPkg ];
|
2022-01-13 20:06:32 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
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";
|
2022-01-13 20:06:32 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
systemd.packages = [ cfg.package ];
|
2022-06-26 10:26:21 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
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";
|
2022-06-26 10:26:21 +00:00
|
|
|
};
|
2022-01-13 20:06:32 +00:00
|
|
|
}
|