commit 8e297037db8f3033f857ec974bda93b49f2bb9db
parent 69eb15d52f22ce8798b987ec1695ed107b4f02b9
Author: Vincent Demeester <vincent@sbr.pm>
Date: Wed, 27 Jul 2022 14:55:10 +0200
systems/modules: preparing to move toward hardware.audio
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
2 files changed, 49 insertions(+), 21 deletions(-)
diff --git a/systems/modules/hardware/audio.nix b/systems/modules/hardware/audio.nix
@@ -1,31 +1,57 @@
{ config, lib, pkgs, ... }:
let
- inherit (lib) mkEnableOption mkIf;
+ inherit (lib) mkEnableOption mkIf mkMerge mkOption types;
cfg = config.modules.hardware.audio;
in
{
options.modules.hardware.audio = {
enable = mkEnableOption "enable audio";
- };
- config = mkIf cfg.enable {
- # Add extra packages
- environment.systemPackages = with pkgs; [
- apulse # allow alsa application to use pulse
- pavucontrol # pulseaudio volume control
- pasystray # systray application
- ];
- # Enable sound (alsa)
- sound.enable = true;
- # Enable and configure pulseaudio
- hardware.pulseaudio = {
- enable = true;
- support32Bit = true;
+ tcp = mkOption {
+ default = false;
+ description = "enable pulseaudio tcp";
+ type = types.bool;
};
- # FIXME is it needed
- security.pam.loginLimits = [
- { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; }
- { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; }
- { domain = "@audio"; item = "nofile"; type = "-"; value = "99999"; }
- ];
};
+ config = mkIf cfg.enable (mkMerge [
+ {
+ # Add extra packages
+ environment.systemPackages = with pkgs; [
+ apulse # allow alsa application to use pulse
+ pavucontrol # pulseaudio volume control
+ pasystray # systray application
+ ];
+ # Enable sound (alsa)
+ sound.enable = true;
+ # Enable and configure pulseaudio
+ hardware.pulseaudio = {
+ enable = true;
+ support32Bit = true;
+ package = pkgs.pulseaudioFull;
+ };
+ # FIXME is it needed
+ security.pam.loginLimits = [
+ { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; }
+ { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; }
+ { domain = "@audio"; item = "nofile"; type = "-"; value = "99999"; }
+ ];
+ }
+ (mkIf cfg.tcp {
+ hardware.pulseaudio = {
+ zeroconf = {
+ discovery.enable = cfg.tcp;
+ publish.enable = cfg.tcp;
+ };
+ tcp = {
+ enable = cfg.tcp;
+ anonymousClients = {
+ allowAll = true;
+ allowedIpRanges = [ "127.0.0.1" "192.168.12.0/24" "10.0.0.0/24" ];
+ };
+ };
+ };
+ networking.firewall = {
+ allowedTCPPorts = [ 4713 ];
+ };
+ })
+ ]);
}
diff --git a/systems/modules/profiles/pulseaudio.nix b/systems/modules/profiles/pulseaudio.nix
@@ -46,6 +46,8 @@ in
networking.firewall = {
allowedTCPPorts = [ 57621 57622 4713 ];
allowedUDPPorts = [ 57621 57622 ];
+ # 57621 57622 spotify
+ # 4713 pulseaudio
};
environment.systemPackages = with pkgs; [
apulse # allow alsa application to use pulse