about summary refs log tree commit diff
path: root/home/scripts/bc-to-nas.nix
diff options
context:
space:
mode:
Diffstat (limited to 'home/scripts/bc-to-nas.nix')
-rw-r--r--home/scripts/bc-to-nas.nix14
1 files changed, 14 insertions, 0 deletions
diff --git a/home/scripts/bc-to-nas.nix b/home/scripts/bc-to-nas.nix
new file mode 100644
index 0000000..efa95d2
--- /dev/null
+++ b/home/scripts/bc-to-nas.nix
@@ -0,0 +1,14 @@
+{ lib, pkgs, ... }:
+let
+  bc-to-nas = pkgs.writeShellScriptBin "bc-to-nas" ''
+    set -euo pipefail
+
+    ALBUM_PATH="''${1}"
+    ALBUM_NAME=$(basename "''${ALBUM_PATH}")
+    NAS=$(${pkgs.tailscale}/bin/tailscale status --json | ${pkgs.jq}/bin/jq -r '.Peer | map(select(.HostName == "tahoe"))[0].TailscaleIPs[0]')
+
+    scp "''${ALBUM_PATH}" "''${NAS}:~/import/album.zip"
+    ssh "''${NAS}" bc-to-beet ~/import/album.zip
+  '';
+in
+{ config = { home.packages = with pkgs; [ bc-to-nas ]; }; }