about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hosts/common/server/navidrome.nix24
-rw-r--r--hosts/profiles/nas.nix13
-rw-r--r--modules/services/navidrome/default.nix37
3 files changed, 46 insertions, 28 deletions
diff --git a/hosts/common/server/navidrome.nix b/hosts/common/server/navidrome.nix
deleted file mode 100644
index e37ccfe..0000000
--- a/hosts/common/server/navidrome.nix
+++ /dev/null
@@ -1,24 +0,0 @@
-{ config, pkgs, lib, ... }:
-
-{
-  services.navidrome = {
-    enable = true;
-    settings = {
-      MusicFolder = "/data/fast/music";
-      Address = "0.0.0.0";
-      httpPort = "4533";
-    };
-  };
-
-  services.restic.backups = {
-    navidrome = {
-      paths = [ "/var/lib/navidrome/" ];
-      repository = "/data/slow/backups/systems";
-      passwordFile = config.age.secrets.restic-repo-systems.path;
-      timerConfig = { OnCalendar = "00:35"; };
-      initialize = true;
-      extraBackupArgs = [ "--tag navidrome" ];
-      pruneOpts = [ "--keep-daily 7" "--keep-weekly 4 --keep-monthly 6" ];
-    };
-  };
-}
diff --git a/hosts/profiles/nas.nix b/hosts/profiles/nas.nix
index dcc73e2..aaeee75 100644
--- a/hosts/profiles/nas.nix
+++ b/hosts/profiles/nas.nix
@@ -9,7 +9,6 @@
     ../common/server/unifi.nix
     ../common/server/gitea.nix
     ../common/server/rclone.nix
-    ../common/server/navidrome.nix
   ];
 
   users.groups.nas.gid = 5000;
@@ -19,9 +18,15 @@
     isSystemUser = true;
   };
 
-  my.services.samba = {
-    enable = true;
-    publicShares = [ "/data/fast/music" "/data/fast/videos" ];
+  my.services = {
+    samba = {
+      enable = true;
+      publicShares = [ "/data/fast/music" "/data/fast/videos" ];
+    };
+    navidrome = {
+      enable = true;
+      musicFolder = "/data/fast/music";
+    };
   };
 
   services.restic.backups = {
diff --git a/modules/services/navidrome/default.nix b/modules/services/navidrome/default.nix
new file mode 100644
index 0000000..1c3725b
--- /dev/null
+++ b/modules/services/navidrome/default.nix
@@ -0,0 +1,37 @@
+{ config, pkgs, lib, ... }:
+let cfg = config.my.services.navidrome;
+in {
+  options.my.services.navidrome = with lib; {
+    enable = mkEnableOption "Navidrome Music Server";
+    musicFolder = mkOption {
+      type = types.str;
+      example = "/data/fast/music";
+      description = "Music folder";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    services.navidrome = {
+      enable = true;
+      settings = {
+        MusicFolder = cfg.musicFolder;
+        Address = "0.0.0.0";
+        httpPort = "4533";
+      };
+    };
+
+    services.restic.backups = {
+      navidrome = {
+        paths = [ "/var/lib/navidrome/" ];
+        repository = "/data/slow/backups/systems";
+        passwordFile = config.age.secrets.restic-repo-systems.path;
+        timerConfig = { OnCalendar = "00:35"; };
+        initialize = true;
+        extraBackupArgs = [ "--tag navidrome" ];
+        pruneOpts = [ "--keep-daily 7" "--keep-weekly 4" ];
+      };
+    };
+
+    networking.firewall.allowedTCPPorts = [ 4533 ];
+  };
+}