Commit 59b591b7156d

Vincent Demeester <vincent@sbr.pm>
2020-03-13 10:51:12
Add profiles.audio with mpd 🎵
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 7cd3c22
Changed files (3)
machines/wakasu.nix
@@ -7,6 +7,14 @@
   profiles.zsh = {
     enable = true;
   };
+  profiles.audio = {
+    enable = true;
+    mpd = {
+      enable = true;
+      musicDir = "/mnt/synodine/volumeUSB2/usbshare/music";
+    };
+    shairport-sync = true;
+  };
   profiles.cloud.google.enable = true;
   profiles.dev = {
     go.enable = true;
@@ -40,5 +48,4 @@
     gnome3.zenity # use rofi instead
     oathToolkit
   ];
-  services.shairport-sync.enable = true;
 }
modules/profiles/audio.nix
@@ -0,0 +1,48 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.audio;
+in
+{
+  options = {
+    profiles.audio = {
+      enable = mkEnableOption "Enable audio profile";
+      shairport-sync = mkEnableOption "Enable shairport-sync";
+      mpd = {
+        enable = mkEnableOption "Enable mpd";
+        musicDir = mkOption {
+          description = "Data where to find the music for mpd";
+          type = types.string;
+        };
+      };
+    };
+  };
+  config = mkIf cfg.enable (mkMerge [
+    {
+      services.shairport-sync.enable = cfg.shairport-sync;
+    }
+    (mkIf cfg.mpd.enable {
+      services.mpd = {
+        enable = true;
+        musicDirectory = cfg.mpd.musicDir;
+        network.listenAddress = "any";
+        extraConfig = ''
+        audio_output {
+          type    "pulse"
+          name    "Local MPD"
+        }
+        '';
+      };
+      home.packages = with pkgs; [
+        mpc_cli
+        ncmpcpp
+      ];
+    })
+    (mkIf (cfg.mpd.enable && config.profiles.desktop.enable) {
+      home.packages = with pkgs; [
+        ario
+      ];
+    })
+  ]);
+}
modules/module-list.nix
@@ -1,5 +1,6 @@
 {
   imports = [
+    ./profiles/audio.nix
     ./profiles/bash.nix
     ./profiles/containers.nix
     ./profiles/desktop.nix