Commit c8ef999b0096

Vincent Demeester <vincent@sbr.pm>
2022-07-28 11:54:00
systems/modules: migrate profiles.pulseaudio to modules.hardware.audio
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent c346090
systems/modules/hardware/audio.nix
@@ -26,7 +26,6 @@ in
       hardware.pulseaudio = {
         enable = true;
         support32Bit = true;
-        package = pkgs.pulseaudioFull;
       };
       # FIXME is it needed
       security.pam.loginLimits = [
systems/modules/hardware/bluetooth.nix
@@ -20,8 +20,6 @@ in
         # PulseAudio to be installed.  Only the full build has Bluetooth
         # support, so it must be selected here.
         package = pkgs.pulseaudioFull;
-        # Enable additional codecs
-        extraModules = [ pkgs.pulseaudio-modules-bt ];
       };
     })
     (mkIf (stable && config.modules.hardware.audio.enable) {
systems/modules/profiles/desktop.nix
@@ -13,9 +13,9 @@ in
         description = "Enable avahi  with the desktop profile";
         type = types.bool;
       };
-      pulseaudio = mkOption {
+      audio = mkOption {
         default = true;
-        description = "Enable pulseaudio with the desktop profile";
+        description = "Enable audio with the desktop profile";
         type = types.bool;
       };
       syncthing = mkOption {
@@ -43,11 +43,14 @@ in
   config = mkIf cfg.enable {
     profiles.avahi.enable = cfg.avahi;
     profiles.printing.enable = cfg.printing;
-    profiles.pulseaudio.enable = cfg.pulseaudio;
+    # profiles.pulseaudio.enable = cfg.pulseaudio;
     profiles.scanning.enable = cfg.scanning;
     profiles.syncthing.enable = cfg.syncthing;
 
-    hardware.bluetooth.enable = true;
+    modules = {
+      hardware.bluetooth.enable = true;
+      hardware.audio.enable = cfg.audio;
+    };
 
     networking.networkmanager = {
       enable = cfg.networkmanager;
systems/modules/profiles/pulseaudio.nix
@@ -1,59 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-let
-  cfg = config.profiles.pulseaudio;
-in
-{
-  options = {
-    profiles.pulseaudio = {
-      enable = mkEnableOption "Enable pulseaudio profile";
-      tcp = mkOption {
-        default = false;
-        description = "Enable pulseaudio tcp";
-        type = types.bool;
-      };
-    };
-  };
-  config = mkIf cfg.enable {
-    hardware = {
-      pulseaudio = {
-        enable = true;
-        support32Bit = true;
-        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" ];
-          };
-        };
-        package = pkgs.pulseaudioFull;
-      };
-    };
-    sound.mediaKeys.enable = true;
-
-    security.pam.loginLimits = [
-      { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; }
-      { domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; }
-      { domain = "@audio"; item = "nofile"; type = "-"; value = "99999"; }
-    ];
-
-    # spotify & pulseaudio
-    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
-      pavucontrol # pulseaudio volume control
-      pasystray # systray application
-      playerctl
-    ];
-  };
-}
systems/modules/profiles/sway.nix
@@ -17,11 +17,14 @@ in
     #};
     profiles.avahi.enable = true;
     profiles.printing.enable = true;
-    profiles.pulseaudio.enable = true;
+    # profiles.pulseaudio.enable = true;
     profiles.scanning.enable = true;
     profiles.syncthing.enable = true;
 
-    hardware.bluetooth.enable = true;
+    modules = {
+      hardware.bluetooth.enable = true;
+      hardware.audio.enable = true;
+    };
 
     networking.networkmanager = {
       enable = true;
flake.nix
@@ -129,7 +129,6 @@
           ./systems/modules/profiles/laptop.nix
           ./systems/modules/profiles/mail.nix
           ./systems/modules/profiles/printing.nix
-          ./systems/modules/profiles/pulseaudio.nix
           ./systems/modules/profiles/qemu.nix
           ./systems/modules/profiles/redhat.nix
           ./systems/modules/profiles/scanning.nix