home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

pulseaudio.nix (1479B)


      1 { config, lib, pkgs, ... }:
      2 
      3 with lib;
      4 let
      5   cfg = config.profiles.pulseaudio;
      6 in
      7 {
      8   options = {
      9     profiles.pulseaudio = {
     10       enable = mkEnableOption "Enable pulseaudio profile";
     11       tcp = mkOption {
     12         default = false;
     13         description = "Enable pulseaudio tcp";
     14         type = types.bool;
     15       };
     16     };
     17   };
     18   config = mkIf cfg.enable {
     19     hardware = {
     20       pulseaudio = {
     21         enable = true;
     22         support32Bit = true;
     23         zeroconf = {
     24           discovery.enable = cfg.tcp;
     25           publish.enable = cfg.tcp;
     26         };
     27         tcp = {
     28           enable = cfg.tcp;
     29           anonymousClients = {
     30             allowAll = true;
     31             allowedIpRanges = [ "127.0.0.1" "192.168.12.0/24" "10.0.0.0/24" ];
     32           };
     33         };
     34         package = pkgs.pulseaudioFull;
     35       };
     36     };
     37     sound.mediaKeys.enable = true;
     38 
     39     security.pam.loginLimits = [
     40       { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; }
     41       { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; }
     42       { domain = "@audio"; item = "nofile"; type = "-"; value = "99999"; }
     43     ];
     44 
     45     # spotify & pulseaudio
     46     networking.firewall = {
     47       allowedTCPPorts = [ 57621 57622 4713 ];
     48       allowedUDPPorts = [ 57621 57622 ];
     49     };
     50     environment.systemPackages = with pkgs; [
     51       apulse # allow alsa application to use pulse
     52       pavucontrol # pulseaudio volume control
     53       pasystray # systray application
     54       playerctl
     55     ];
     56   };
     57 }