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";
|
2022-08-12 12:06:08 +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";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The wireplumber derivation to use.";
|
2022-01-13 20:06:32 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
assertions = [
|
2022-12-17 10:02:37 +00:00
|
|
|
{
|
|
|
|
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";
|
|
|
|
}
|
2022-01-13 20:06:32 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
2022-03-30 09:31:56 +00:00
|
|
|
|
|
|
|
environment.etc."wireplumber/main.lua.d/80-nixos.lua" = lib.mkIf (!pwUsedForAudio) {
|
2022-06-26 10:26:21 +00:00
|
|
|
text = ''
|
2022-04-03 18:54:34 +00:00
|
|
|
-- 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
|
|
|
|
'';
|
|
|
|
};
|
2022-06-26 10:26:21 +00:00
|
|
|
environment.etc."wireplumber/main.lua.d/80-systemwide.lua" = lib.mkIf config.services.pipewire.systemWide {
|
|
|
|
text = ''
|
|
|
|
-- 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
|
|
|
|
'';
|
|
|
|
};
|
2022-07-14 12:49:19 +00:00
|
|
|
environment.etc."wireplumber/bluetooth.lua.d/80-systemwide.lua" = lib.mkIf config.services.pipewire.systemWide {
|
|
|
|
text = ''
|
|
|
|
-- When running system-wide, logind-integration needs to be disabled.
|
|
|
|
bluez_monitor.properties["with-logind"] = false
|
|
|
|
'';
|
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
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" ];
|
2022-06-26 10:26:21 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
2022-01-13 20:06:32 +00:00
|
|
|
};
|
|
|
|
}
|