From 1aff3aabc25fad85e9a91cc0182b508c51fd0ebc Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Tue, 14 Jun 2022 17:04:15 -0700 Subject: feat(home/beet): import albums on the NAS Two new scripts are created. The first one is to copy an album (usually in zip format) from my desktop to the NAS. Once the file is copied, the script calls the second script, which extract the album and call beet to get it imported in my music collection. Change-Id: I93509e0cc213ba884a9282e1f474a0f9298a1fb7 Reviewed-on: https://cl.fcuny.net/c/world/+/417 Tested-by: CI Reviewed-by: Franck Cuny --- home/scripts/bc-to-nas.nix | 14 ++++++++++++++ home/scripts/default.nix | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 home/scripts/bc-to-nas.nix (limited to 'home/scripts') 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 ]; }; } diff --git a/home/scripts/default.nix b/home/scripts/default.nix index bc19e44..741bade 100644 --- a/home/scripts/default.nix +++ b/home/scripts/default.nix @@ -1,5 +1,5 @@ { ... }: { - imports = [ ./perf-flamegraph.nix ]; + imports = [ ./perf-flamegraph.nix ./bc-to-nas.nix ]; } -- cgit 1.4.1