mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 09:23:01 +00:00
nixos/pipewire: add ALSA routing
This code is based on the similar implementation for JACK.
This commit is contained in:
parent
7fcc9a4eaa
commit
cd81d4043e
@ -5,7 +5,9 @@ with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.pipewire;
|
||||
packages = with pkgs; [ pipewire ];
|
||||
enable32BitAlsaPlugins = cfg.alsa.support32Bit
|
||||
&& pkgs.stdenv.isx86_64
|
||||
&& pkgs.pkgsi686Linux.pipewire != null;
|
||||
|
||||
in {
|
||||
|
||||
@ -25,17 +27,52 @@ in {
|
||||
Automatically run pipewire when connections are made to the pipewire socket.
|
||||
'';
|
||||
};
|
||||
|
||||
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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
###### implementation
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = packages;
|
||||
environment.systemPackages = [ pkgs.pipewire ];
|
||||
|
||||
systemd.packages = packages;
|
||||
systemd.packages = [ pkgs.pipewire ];
|
||||
|
||||
systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ];
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user