66 lines
1.7 KiB
Nix
66 lines
1.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
{
|
|
options.c3d2.audioServer = with lib; {
|
|
enable = mkEnableOption "Enable PulseAudio and Bluetooth sinks";
|
|
};
|
|
|
|
config = lib.mkIf config.c3d2.audioServer.enable {
|
|
# Enable sound.
|
|
sound.enable = true;
|
|
hardware.bluetooth = {
|
|
enable = lib.mkDefault true;
|
|
settings = {
|
|
Policy.AutoEnable = true;
|
|
General.DiscoverableTimeout = 0;
|
|
};
|
|
};
|
|
|
|
hardware.pulseaudio = {
|
|
enable = true;
|
|
systemWide = true;
|
|
tcp.enable = true;
|
|
tcp.anonymousClients.allowedIpRanges = [
|
|
"127.0.0.0/8"
|
|
"::1/128"
|
|
"fd23:42:c3d2:500::/56"
|
|
"172.22.99.0/24"
|
|
"172.20.72.0/21"
|
|
"2a00:8180:2c00:200::/56"
|
|
];
|
|
zeroconf.publish.enable = true;
|
|
package = pkgs.pulseaudioFull;
|
|
extraModules = [ pkgs.pulseaudio-modules-bt ];
|
|
};
|
|
#services.pipewire = {
|
|
# enable = true;
|
|
# alsa.enable = true;
|
|
# config.pipewire-pulse = lib.importJSON ./pipewire-pulse.conf.json;
|
|
# pulse.enable = true;
|
|
#};
|
|
security.rtkit.enable = true;
|
|
|
|
# tell Avahi to publish CUPS and PulseAudio
|
|
services.avahi = {
|
|
enable = true;
|
|
publish = {
|
|
enable = true;
|
|
addresses = true;
|
|
userServices = true;
|
|
};
|
|
};
|
|
|
|
systemd.services.bluetooth-agent = lib.mkIf config.hardware.bluetooth.enable {
|
|
description = "Allow anyone to pair via Bluetooth";
|
|
wantedBy = [ "multi-user.target" ];
|
|
requires = [ "bluetooth.target" ];
|
|
after = [ "bluetooth.service" ];
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
ExecStart = "${pkgs.bluez-tools}/bin/bt-agent -c NoInputNoOutput";
|
|
Restart = "on-failure";
|
|
RestartSec = 60;
|
|
};
|
|
};
|
|
};
|
|
}
|