Commit b4f3049a83d3

Vincent Demeester <vincent@sbr.pm>
2018-11-23 17:13:27
modules: add pulseaudio and enable it by default with desktop
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent c13f70d
modules/profiles/desktop.nix
@@ -12,9 +12,14 @@ in
         description = "Enable desktop profile";
         type = types.bool;
       };
+      pulseaudio = mkOption {
+        default = true;
+        description = "Enable pulseaudio with the desktop profile";
+        type = types.bool;
+      };
     };
   };
   config = mkIf cfg.enable {
-  
+    profiles.pulseaudio.enable = cfg.pulseaudio;
   };
 }
modules/profiles/pulseaudio.nix
@@ -0,0 +1,52 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.pulseaudio;
+in
+{
+  options = {
+    profiles.pulseaudio = {
+      enable = mkOption {
+        default = false;
+        description = "Enable pulseaudio profile";
+        type = types.bool;
+      };
+    };
+  };
+  config = mkIf cfg.enable {
+    hardware = {
+      pulseaudio = {
+        enable = true;
+        support32Bit = true;
+        zeroconf = {
+          discovery.enable = true;
+          publish.enable = true;
+        };
+        tcp = {
+          enable = true;
+          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;
+  
+    # spotify & pulseaudio
+    networking.firewall = {
+      allowedTCPPorts = [ 57621 57622 4713 ];
+      allowedUDPPorts = [ 57621 57622 ];
+    };
+    environment.systemPackages = with pkgs; [
+      apulse       # allow alsa application to use pulse
+      pavucontrol  # pulseaudio volume control
+      pasystray    # systray application
+      playerctl
+    ];
+    # We assume xserver runs when pulseaudio does
+    services.xserver.displayManager.sessionCommands = "${pkgs.pasystray}/bin/pasystray &";
+  };
+}
modules/module-list.nix
@@ -8,9 +8,10 @@
     ./profiles/desktop.nix
     ./profiles/docker.nix
     ./profiles/i18n.nix
+    ./profiles/laptop.nix
     ./profiles/nix-config.nix
     ./profiles/nix-auto-update.nix
-    ./profiles/laptop.nix
+    ./profiles/pulseaudio.nix
     ./profiles/users.nix
     ./profiles/virtualization.nix
     ./programs/podman.nix
profiles/audio.nix
@@ -1,39 +0,0 @@
-{ config, pkgs, ... }:
-
-{
-  hardware = {
-    pulseaudio = {
-      enable = true;
-      support32Bit = true;
-      zeroconf = {
-        discovery.enable = true;
-        publish.enable = true;
-      };
-      tcp = {
-        enable = true;
-        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;
-
-  # spotify & pulseaudio
-  networking.firewall = {
-    allowedTCPPorts = [ 57621 57622 4713 ];
-    allowedUDPPorts = [ 57621 57622 ];
-  };
-
-  environment.systemPackages = with pkgs; [
-    apulse       # allow alsa application to use pulse
-    pavucontrol  # pulseaudio volume control
-    pasystray    # systray application
-    playerctl
-  ];
-
-  # We assume xserver runs when pulseaudio does
-  services.xserver.displayManager.sessionCommands = "${pkgs.pasystray}/bin/pasystray &";
-}
profiles/laptop.nix
@@ -2,13 +2,7 @@
 
 {
   imports = [
-    ./audio.nix
     ./desktop.nix
   ];
 
-  environment.systemPackages = with pkgs; [
-    lm_sensors
-    powertop
-    acpi
-  ];
 }