2023-10-12 13:58:03 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-01-09 13:13:04 -05:00
|
|
|
# Deps:
|
|
|
|
# - jq
|
|
|
|
# - mozilla-addons-to-nix
|
|
|
|
# - alejandra
|
2024-03-31 22:11:18 -04:00
|
|
|
# - updateImages
|
2024-04-22 13:51:31 -04:00
|
|
|
# - nix-fast-build
|
2024-01-09 13:13:04 -05:00
|
|
|
|
2023-12-13 19:10:25 -05:00
|
|
|
parseFetchurl() {
|
|
|
|
URL="$1"
|
|
|
|
FILE="$2"
|
|
|
|
HASH="$(nix store prefetch-file --refresh --json \
|
|
|
|
--hash-type sha256 "$URL" --name "escaped" | jq -r .hash)"
|
|
|
|
|
|
|
|
sed -i "s,url = .*,url = \"$URL\";," "$FILE"
|
|
|
|
sed -i "s,hash = .*,hash = \"$HASH\";," "$FILE"
|
2023-12-13 19:15:55 -05:00
|
|
|
|
|
|
|
# For Firefox addons
|
|
|
|
sed -i "s,sha256 = .*,sha256 = \"$HASH\";," "$FILE"
|
2023-12-13 19:10:25 -05:00
|
|
|
}
|
|
|
|
|
2024-03-31 22:11:18 -04:00
|
|
|
updateDocker() {
|
|
|
|
find "$FLAKE/devices/nos/modules/arion" \
|
|
|
|
-name "*compose.nix" \
|
2024-06-11 16:42:47 -04:00
|
|
|
-exec sh -c 'i="$1"; updateImages $(dirname "$i")' shell {} \;
|
2024-03-31 22:11:18 -04:00
|
|
|
}
|
|
|
|
|
2023-12-13 16:53:40 -05:00
|
|
|
updateFFZ() {
|
2024-01-09 13:13:04 -05:00
|
|
|
FILE="$FLAKE/home/firefox/addons/default.nix"
|
2023-12-13 16:53:40 -05:00
|
|
|
URL="https://cdn.frankerfacez.com/script/frankerfacez-4.0-an+fx.xpi"
|
|
|
|
|
2023-12-13 19:10:25 -05:00
|
|
|
parseFetchurl "$URL" "$FILE"
|
2023-12-13 16:53:40 -05:00
|
|
|
}
|
|
|
|
|
2023-10-12 13:58:03 -04:00
|
|
|
updateFirefoxAddons() {
|
|
|
|
echo "Updating firefox addons using mozilla-addons-to-nix"
|
|
|
|
|
2024-01-09 13:13:04 -05:00
|
|
|
(
|
|
|
|
cd "$FLAKE/home/firefox/addons" || return;
|
2023-10-12 13:58:03 -04:00
|
|
|
|
2024-01-09 13:13:04 -05:00
|
|
|
file=generated-firefox-addons.nix
|
|
|
|
if [[ -f $file ]]; then
|
2024-04-13 00:25:10 -04:00
|
|
|
readarray -t OLD_VERS <<< "$(grep -A 1 --no-group-separator 'pname' "$file" |
|
2024-01-09 13:13:04 -05:00
|
|
|
awk '{ gsub(/"/, ""); gsub(/;/, ""); print $3 }' |
|
2024-04-13 00:25:10 -04:00
|
|
|
awk 'NR%2{printf $0" version ";next;}1' | paste -sd'\n' -)"
|
|
|
|
|
2024-06-11 16:42:47 -04:00
|
|
|
readarray -t NEW_VERS <<< "$(sed 's/Fetched //' \
|
|
|
|
<(mozilla-addons-to-nix addons.json generated-firefox-addons.nix) |
|
|
|
|
sed 's/bitwarden-password-manager/bitwarden/' |
|
|
|
|
sed 's/600-sound-volume/sound-volume/' |
|
|
|
|
sed 's/styl-us/stylus/' |
|
2024-04-13 00:25:10 -04:00
|
|
|
sort)"
|
|
|
|
|
|
|
|
for (( i=0; i<${#OLD_VERS[@]}; i++ )); do
|
|
|
|
if [[ "${OLD_VERS[$i]}" != "${NEW_VERS[$i]}" ]]; then
|
|
|
|
echo "${OLD_VERS[$i]} -> $(echo "${NEW_VERS[$i]}" | awk '{print $NF}')"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
mozilla-addons-to-nix addons.json generated-firefox-addons.nix
|
2024-01-09 13:13:04 -05:00
|
|
|
fi
|
|
|
|
)
|
2023-10-12 13:58:03 -04:00
|
|
|
}
|
|
|
|
|
2024-03-28 13:51:07 -04:00
|
|
|
updateVuetorrent() {
|
|
|
|
FILE="$FLAKE/devices/nos/modules/qbittorrent/vuetorrent.nix"
|
|
|
|
|
|
|
|
release=$(curl -s https://api.github.com/repos/VueTorrent/VueTorrent/releases/latest)
|
|
|
|
version=$(echo "$release" | jq -r .tag_name | tr -d v)
|
|
|
|
url="https://github.com/VueTorrent/VueTorrent/releases/download/v${version}/vuetorrent.zip"
|
|
|
|
hash="$(nix store prefetch-file --refresh --json \
|
|
|
|
--hash-type sha256 "$url" --name "escaped" | jq -r .hash)"
|
|
|
|
|
|
|
|
{
|
|
|
|
echo '# This file was autogenerated. DO NOT EDIT!'
|
|
|
|
echo '{'
|
|
|
|
echo " version = \"$version\";"
|
|
|
|
echo " url = \"$url\";"
|
|
|
|
echo " hash = \"$hash\";"
|
|
|
|
echo '}'
|
|
|
|
} >"$FILE"
|
|
|
|
}
|
|
|
|
|
2023-12-13 19:23:34 -05:00
|
|
|
|
2023-10-12 13:58:03 -04:00
|
|
|
doAll() {
|
2024-04-14 15:02:19 -04:00
|
|
|
nix flake update
|
2024-03-31 22:11:18 -04:00
|
|
|
updateDocker
|
|
|
|
updateFFZ
|
|
|
|
updateFirefoxAddons
|
|
|
|
updateVuetorrent
|
2024-04-22 13:51:31 -04:00
|
|
|
nix-fast-build
|
2024-03-31 22:11:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
doAllWithoutDocker() {
|
2023-12-13 16:53:40 -05:00
|
|
|
updateFFZ
|
2023-10-12 13:58:03 -04:00
|
|
|
updateFirefoxAddons
|
2024-03-28 13:51:07 -04:00
|
|
|
updateVuetorrent
|
2023-10-12 13:58:03 -04:00
|
|
|
}
|
|
|
|
|
2023-12-13 19:23:34 -05:00
|
|
|
|
2023-10-12 13:58:03 -04:00
|
|
|
[[ "$1" == "-a" || "$1" == "--all" ]] && doAll
|
2024-03-31 22:11:18 -04:00
|
|
|
[[ "$1" == "-ad" || "$1" == "--all-no-docker" ]] && doAllWithoutDocker
|
|
|
|
[[ "$1" == "-d" || "$1" == "--docker" ]] && updateDocker
|
2023-10-12 13:58:03 -04:00
|
|
|
[[ "$1" == "-f" || "$1" == "--firefox" ]] && updateFirefoxAddons
|
2023-12-13 16:53:40 -05:00
|
|
|
[[ "$1" == "-ffz" || "$1" == "--frankerfacez" ]] && updateFFZ
|
2024-03-28 13:51:07 -04:00
|
|
|
[[ "$1" == "-v" || "$1" == "--vuetorrent" ]] && updateVuetorrent
|
2023-12-03 21:35:30 -05:00
|
|
|
|
2024-04-13 00:25:10 -04:00
|
|
|
alejandra -q "$FLAKE"
|