2018-01-30 17:58:56 +00:00
|
|
|
# pipewire service.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2018-07-06 05:00:10 +01:00
|
|
|
let
|
|
|
|
cfg = config.services.pipewire;
|
2020-07-23 19:47:11 +01:00
|
|
|
enable32BitAlsaPlugins = cfg.alsa.support32Bit
|
|
|
|
&& pkgs.stdenv.isx86_64
|
|
|
|
&& pkgs.pkgsi686Linux.pipewire != null;
|
2018-07-06 05:00:10 +01:00
|
|
|
|
2020-07-25 04:28:07 +01:00
|
|
|
jack-libs = pkgs.runCommand "jack-libs" {} ''
|
|
|
|
mkdir -p "$out/lib"
|
|
|
|
ln -s "${pkgs.pipewire.lib}/lib/pipewire-0.3/jack" "$out/lib/pipewire"
|
|
|
|
'';
|
|
|
|
pulse-libs = pkgs.runCommand "pulse-libs" {} ''
|
|
|
|
mkdir -p "$out/lib"
|
|
|
|
ln -s "${pkgs.pipewire.lib}/lib/pipewire-0.3/pulse" "$out/lib/pipewire"
|
|
|
|
'';
|
2018-07-06 05:00:10 +01:00
|
|
|
in {
|
2020-04-02 01:16:24 +01:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = teams.freedesktop.members;
|
|
|
|
};
|
|
|
|
|
2018-01-30 17:58:56 +00:00
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.pipewire = {
|
|
|
|
enable = mkEnableOption "pipewire service";
|
2018-07-06 05:00:10 +01:00
|
|
|
|
|
|
|
socketActivation = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Automatically run pipewire when connections are made to the pipewire socket.
|
|
|
|
'';
|
|
|
|
};
|
2020-07-23 19:47:11 +01:00
|
|
|
|
|
|
|
alsa = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Route audio to/from generic ALSA-using applications via the ALSA PIPEWIRE PCM plugin.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
support32Bit = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Whether to support sound for 32-bit ALSA applications on a 64-bit system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-07-25 04:28:07 +01:00
|
|
|
|
|
|
|
jack = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Enable transparent JACK audio emulation using LD_LIBRARY_PATH.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
pulse = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Enable transparent PulseAudio emulation using LD_LIBRARY_PATH.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2018-01-30 17:58:56 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
2018-07-06 05:00:10 +01:00
|
|
|
config = mkIf cfg.enable {
|
2020-07-25 04:28:07 +01:00
|
|
|
environment.systemPackages = [ pkgs.pipewire ]
|
|
|
|
++ lib.optional cfg.jack.enable jack-libs
|
|
|
|
++ lib.optional cfg.pulse.enable pulse-libs;
|
2018-07-06 05:00:10 +01:00
|
|
|
|
2020-07-23 19:47:11 +01:00
|
|
|
systemd.packages = [ pkgs.pipewire ];
|
2018-01-30 17:58:56 +00:00
|
|
|
|
2018-07-06 05:00:10 +01:00
|
|
|
systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ];
|
2018-01-30 17:58:56 +00:00
|
|
|
|
2020-07-23 19:47:11 +01:00
|
|
|
sound.extraConfig = mkIf cfg.alsa.enable ''
|
|
|
|
pcm_type.pipewire {
|
|
|
|
libs.native = ${pkgs.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;
|
|
|
|
${optionalString enable32BitAlsaPlugins
|
|
|
|
"libs.32Bit = ${pkgs.pkgsi686Linux.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;"}
|
|
|
|
}
|
|
|
|
pcm.!default {
|
|
|
|
@func getenv
|
|
|
|
vars [ PCM ]
|
|
|
|
default "plug:pipewire"
|
|
|
|
playback_mode "-1"
|
|
|
|
capture_mode "-1"
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable {
|
|
|
|
source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf";
|
|
|
|
};
|
2020-07-25 04:28:07 +01:00
|
|
|
environment.sessionVariables.LD_LIBRARY_PATH = "/run/current-system/sw/lib/pipewire";
|
2020-07-23 19:47:11 +01:00
|
|
|
};
|
2018-01-30 17:58:56 +00:00
|
|
|
}
|