refactor(wip): fix some stuff in update script

This commit is contained in:
matt1432 2023-12-03 21:35:30 -05:00
parent 699666bf48
commit 89e9df4ad1

View file

@ -1,19 +1,14 @@
#!/usr/bin/env bash
parseNurl() {
REV=$(nurl -j "$1" | jq '.["args"].["rev"]')
HASH=$(nurl -j "$1" | jq '.["args"].["hash"]')
REV=$(nurl -j "$1" | jq '.["args"].["rev"]')
HASH=$(nurl -j "$1" | jq '.["args"].["hash"]')
sed -i "s,rev = .*,rev = $REV;," "$2"
sed -i "s,hash = .*,hash = $HASH;," "$2"
}
updateVencord() {
parseNurl https://github.com/Vendicated/Vencord /home/matt/.nix/common/overlays/vencord.nix
sed -i "s,rev = .*,rev = $REV;," "$2"
sed -i "s,hash = .*,hash = $HASH;," "$2"
}
# TODO
#parseNurl "https://github.com/lukas-reineke/indent-blankline.nvim"
# https://github.com/dracula/xresources
# https://github.com/dracula/plymouth
@ -26,20 +21,20 @@ updateVencord() {
updateFirefoxAddons() {
echo "Updating firefox addons using mozilla-addons-to-nix"
(cd /home/matt/.nix/modules/firefox/addons || return;
(cd /home/matt/.nix/home/firefox/addons || return;
file=generated-firefox-addons.nix
if [[ -f $file ]]; then
printf "\nOld versions: \n"
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' -
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
printf "\nNew versions: \n"
fi
mozilla-addons-to-nix addons.json generated-firefox-addons.nix)
mozilla-addons-to-nix addons.json generated-firefox-addons.nix)
}
doAll() {
@ -47,5 +42,6 @@ doAll() {
}
[[ "$1" == "-a" || "$1" == "--all" ]] && doAll
[[ "$1" == "-v" || "$1" == "--vencord" ]] && updateVencord
[[ "$1" == "-f" || "$1" == "--firefox" ]] && updateFirefoxAddons
alejandra /home/matt/.nix