97 lines
2.6 KiB
Bash
Executable file
97 lines
2.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Deps:
|
|
# - jq
|
|
# - mozilla-addons-to-nix
|
|
# - alejandra
|
|
# - updateImages
|
|
|
|
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"
|
|
|
|
# For Firefox addons
|
|
sed -i "s,sha256 = .*,sha256 = \"$HASH\";," "$FILE"
|
|
}
|
|
|
|
updateDocker() {
|
|
find "$FLAKE/devices/nos/modules/arion" \
|
|
-name "*compose.nix" \
|
|
-exec sh -c 'updateImages $(dirname "{}")' \;
|
|
}
|
|
|
|
updateFFZ() {
|
|
FILE="$FLAKE/home/firefox/addons/default.nix"
|
|
URL="https://cdn.frankerfacez.com/script/frankerfacez-4.0-an+fx.xpi"
|
|
|
|
parseFetchurl "$URL" "$FILE"
|
|
}
|
|
|
|
updateFirefoxAddons() {
|
|
echo "Updating firefox addons using mozilla-addons-to-nix"
|
|
|
|
(
|
|
cd "$FLAKE/home/firefox/addons" || return;
|
|
|
|
file=generated-firefox-addons.nix
|
|
if [[ -f $file ]]; then
|
|
printf "\nOld versions: \n"
|
|
|
|
grep -A 1 --no-group-separator 'pname' "$file" |
|
|
awk '{ gsub(/"/, ""); gsub(/;/, ""); print $3 }' |
|
|
awk 'NR%2{printf $0" version ";next;}1' | paste -sd'\n' -
|
|
|
|
printf "\nNew versions: \n"
|
|
fi
|
|
|
|
mozilla-addons-to-nix addons.json generated-firefox-addons.nix
|
|
)
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
|
|
doAll() {
|
|
updateDocker
|
|
updateFFZ
|
|
updateFirefoxAddons
|
|
updateVuetorrent
|
|
}
|
|
|
|
doAllWithoutDocker() {
|
|
updateFFZ
|
|
updateFirefoxAddons
|
|
updateVuetorrent
|
|
}
|
|
|
|
|
|
[[ "$1" == "-a" || "$1" == "--all" ]] && doAll
|
|
[[ "$1" == "-ad" || "$1" == "--all-no-docker" ]] && doAllWithoutDocker
|
|
[[ "$1" == "-d" || "$1" == "--docker" ]] && updateDocker
|
|
[[ "$1" == "-f" || "$1" == "--firefox" ]] && updateFirefoxAddons
|
|
[[ "$1" == "-ffz" || "$1" == "--frankerfacez" ]] && updateFFZ
|
|
[[ "$1" == "-v" || "$1" == "--vuetorrent" ]] && updateVuetorrent
|
|
|
|
alejandra "$FLAKE"
|