74 lines
2.3 KiB
Nix
74 lines
2.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
cfg = config.c3d2.audioStreaming;
|
|
release = lib.strings.fileContents "${pkgs.path}/.version";
|
|
in
|
|
{
|
|
options = {
|
|
c3d2.audioStreaming = lib.mkEnableOption "enable all services requires to audio stream to dacbert, glotzert or pulsebert";
|
|
};
|
|
|
|
config = lib.mkIf cfg {
|
|
environment.etc = lib.optionalAttrs (lib.versionAtLeast release "23.05") {
|
|
"pipewire/pipewire.conf.d/zeroconf.conf".text = builtins.toJSON {
|
|
"context.modules" = [ {
|
|
"name" = "libpipewire-module-zeroconf-discover";
|
|
} ];
|
|
};
|
|
};
|
|
|
|
environment.systemPackages = lib.mkIf config.services.xserver.enable (with pkgs; [
|
|
paprefs
|
|
pavucontrol
|
|
]);
|
|
|
|
hardware.pulseaudio = {
|
|
# enabling zeroconf discovery or publishing turns on zeroconfSupport for the configured pulseaudio package
|
|
# pulseaudioFull has that enabled plus it has a cache hit on cache.nixos.org
|
|
package = pkgs.pulseaudioFull;
|
|
zeroconf.discovery.enable = true;
|
|
};
|
|
|
|
# required for paprefs to be able to save
|
|
programs.dconf.enable = lib.mkIf config.services.xserver.enable true;
|
|
|
|
security.rtkit.enable = true;
|
|
|
|
services = {
|
|
avahi = {
|
|
enable = true;
|
|
nssmdns = true;
|
|
};
|
|
|
|
pipewire = lib.mkMerge [
|
|
(lib.optionalAttrs (lib.versionOlder release "23.05") {
|
|
config.pipewire-pulse =
|
|
let
|
|
default-pipewire-pulse = lib.importJSON (pkgs.path + "/nixos/modules/services/desktops/pipewire/daemon/pipewire-pulse.conf.json");
|
|
in
|
|
default-pipewire-pulse // {
|
|
"context.modules" = default-pipewire-pulse."context.modules" ++ [
|
|
{
|
|
"name" = "libpipewire-module-zeroconf-discover";
|
|
}
|
|
];
|
|
};
|
|
})
|
|
{
|
|
pulse.enable = true;
|
|
}
|
|
];
|
|
};
|
|
|
|
# TODO: rebuild using programs.dconf.profiles, see https://github.com/NixOS/nixpkgs/pull/234615
|
|
system.userActivationScripts.enableZeroconfDiscover.text = lib.mkIf config.services.xserver.enable ''
|
|
echo "[org/freedesktop/pulseaudio/module-groups/zeroconf-discover]
|
|
args0=''\''
|
|
enabled=true
|
|
name0='module-zeroconf-discover'
|
|
" | ${pkgs.dconf}/bin/dconf load /
|
|
'';
|
|
};
|
|
}
|