{ pkgs, tree, nixosConfig, ... }: let # Requires secrets.{restic_music_env} secrets = nixosConfig.services.secrets.secrets; in { imports = with tree; [ home.apps.rclone home.apps.musicutil ]; home.packages = [ pkgs.nodePackages.html-minifier (pkgs.writeShellScriptBin "restic-music" '' env $(cat ${secrets.restic_music_env.path}) \ ${pkgs.restic}/bin/restic $@ '') ]; home.file."Music/music-sync.sh" = { executable = true; text = '' #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd "''${SCRIPT_DIR}" rclone sync -P . Storage:Music --exclude music-sync.sh,music-download.sh restic-music backup $(fd -t d --max-depth=1 && fd -t f --max-depth=1) TITLE="chaos's Music Library" DESCRIPTION="A listing of all music we listen to and have downloaded/brought" LINK_BASE="https://storage-http.owo.monster/Music" TMPDIR=$(mktemp -d) musicutil genhtml . "$TMPDIR" --title "$TITLE" --description "$DESCRIPTION" --link-base="$LINK_BASE" pushd "$TMPDIR" html-minifier \ --collapse-whitespace --remove-comments \ --remove-redundant-attributes --remove-script-type-attributes \ --remove-tag-whitespace --use-short-doctype \ index.html > index_min.html mv index_min.html index.html rsync --recursive ./ hetzner-arm:/var/lib/static-sites/music_library/ ssh hetzner-arm chown -R nginx:nginx /var/lib/static-sites/music_library popd ''; }; home.file."Music/music-download.sh" = { executable = true; text = '' #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd "''${SCRIPT_DIR}" rclone sync -P --exclude music-sync.sh,music-download.sh Storage:Music . ''; }; }