1
0
forked from c3d2/nix-config

Move audio specific settings from pulsebert to audioserver

This commit is contained in:
Sandro - 2023-04-29 23:05:39 +02:00
parent 9b70709d50
commit a23f73e88b
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5
2 changed files with 76 additions and 64 deletions

View File

@ -66,12 +66,9 @@
domain = "hq.c3d2.de"; domain = "hq.c3d2.de";
firewall = { firewall = {
allowedTCPPorts = [ allowedTCPPorts = [
80 # ledfx
4713 # pulseaudio/pipewire network sync
5355 # llmnr 5355 # llmnr
]; ];
allowedUDPPorts = [ allowedUDPPorts = [
5353 # mdns
5355 # llmnr 5355 # llmnr
]; ];
}; };
@ -80,14 +77,6 @@
interfaces.eth0.useDHCP = true; interfaces.eth0.useDHCP = true;
}; };
environment.systemPackages = with pkgs; [
mpd
mpv
ncmpcpp
ncpamixer
pulseaudio # required for pactl
];
# https://github.com/dump-dvb/nix-config/blob/310ceedca5ab2d5c22070bd73c603926b6100a74/hardware/configuration-rpi-3b.nix#L16 # https://github.com/dump-dvb/nix-config/blob/310ceedca5ab2d5c22070bd73c603926b6100a74/hardware/configuration-rpi-3b.nix#L16
sdImage = lib.mkForce { sdImage = lib.mkForce {
populateFirmwareCommands = populateFirmwareCommands =
@ -144,25 +133,17 @@
''; '';
}; };
security = { security.sudo = {
rtkit.enable = true; enable = true;
sudo = { wheelNeedsPassword = false;
enable = true;
wheelNeedsPassword = false;
};
}; };
services = { services = {
avahi.nssmdns = true;
# Do not log to flash but also breaks journalctl --user # Do not log to flash but also breaks journalctl --user
# journald.extraConfig = '' # journald.extraConfig = ''
# Storage=volatile # Storage=volatile
# ''; # '';
openssh = {
enable = true;
};
nginx = { nginx = {
enable = true; enable = true;
virtualHosts = { virtualHosts = {

View File

@ -6,41 +6,62 @@
}; };
config = lib.mkIf config.c3d2.audioServer.enable { config = lib.mkIf config.c3d2.audioServer.enable {
sound.enable = true; environment.systemPackages = with pkgs; [
hardware.bluetooth = { mpd
enable = lib.mkDefault true; mpv
settings = { ncmpcpp
Policy.AutoEnable = true; ncpamixer
General.DiscoverableTimeout = 0; pulseaudio # required for pactl
];
hardware = {
bluetooth = {
enable = lib.mkDefault true;
settings = {
Policy.AutoEnable = true;
General.DiscoverableTimeout = 0;
};
};
pulseaudio = {
enable = !config.services.pipewire.pulse.enable;
systemWide = true;
tcp = {
enable = true;
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"
"2a0f:5382:acab:1400::/56"
];
};
zeroconf.publish.enable = true;
package = (pkgs.pulseaudio.override {
bluetoothSupport = true;
advancedBluetoothCodecs = true;
zeroconfSupport = true;
}).overrideAttrs (_: {
# one test times out
doCheck = false;
});
}; };
}; };
hardware.pulseaudio = { networking.firewall = {
enable = !config.services.pipewire.pulse.enable; allowedTCPPorts = [
systemWide = true; 80 # ledfx
tcp = { 4713 # pulseaudio/pipewire network sync
enable = true; ];
anonymousClients.allowedIpRanges = [ allowedUDPPorts = [
"127.0.0.0/8" 5353 # mdns
"::1/128" ];
"fd23:42:c3d2:500::/56"
"172.22.99.0/24"
"172.20.72.0/21"
"2a00:8180:2c00:200::/56"
"2a0f:5382:acab:1400::/56"
];
};
zeroconf.publish.enable = true;
package = (pkgs.pulseaudio.override {
bluetoothSupport = true;
advancedBluetoothCodecs = true;
zeroconfSupport = true;
}).overrideAttrs (_: {
# one test times out
doCheck = false;
});
}; };
security.rtkit.enable = true;
services.pipewire = { services.pipewire = {
enable = true; enable = true;
alsa.enable = true; # required for ledfx alsa.enable = true; # required for ledfx
@ -74,11 +95,10 @@
pulse.enable = true; pulse.enable = true;
}; };
security.rtkit.enable = true;
# tell Avahi to publish services like Pipewire/PulseAudio # tell Avahi to publish services like Pipewire/PulseAudio
services.avahi = { services.avahi = {
enable = true; enable = true;
nssmdns = true;
publish = { publish = {
enable = true; enable = true;
addresses = true; addresses = true;
@ -86,6 +106,8 @@
}; };
}; };
sound.enable = true;
system.activationScripts.enableLingering = lib.optionalString config.services.pipewire.pulse.enable ('' system.activationScripts.enableLingering = lib.optionalString config.services.pipewire.pulse.enable (''
rm -r /var/lib/systemd/linger rm -r /var/lib/systemd/linger
mkdir /var/lib/systemd/linger mkdir /var/lib/systemd/linger
@ -93,16 +115,25 @@
touch /var/lib/systemd/linger/k-ot touch /var/lib/systemd/linger/k-ot
''); '');
systemd.services.bluetooth-agent = lib.mkIf config.hardware.bluetooth.enable { systemd = {
description = "Allow anyone to pair via Bluetooth"; services.bluetooth-agent = lib.mkIf config.hardware.bluetooth.enable {
wantedBy = [ "multi-user.target" ]; description = "Allow anyone to pair via Bluetooth";
requires = [ "bluetooth.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "bluetooth.service" ]; requires = [ "bluetooth.target" ];
serviceConfig = { after = [ "bluetooth.service" ];
Type = "simple"; serviceConfig = {
ExecStart = "${pkgs.bluez-tools}/bin/bt-agent -c NoInputNoOutput"; Type = "simple";
Restart = "on-failure"; ExecStart = "${pkgs.bluez-tools}/bin/bt-agent -c NoInputNoOutput";
RestartSec = 60; Restart = "on-failure";
RestartSec = 60;
};
};
user.services.ledfx = {
after = [ "pipewire.target" ];
wantedBy = [ "default.target" ];
serviceConfig = {
ExecStart = "${pkgs.ledfx}/bin/ledfx";
};
}; };
}; };