about summary refs log tree commit diff
path: root/home/scripts/bc-to-nas.nix
blob: efa95d2a5dfea70490f124743866b4901b6a5549 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 ]; }; }