Create auto-updater

This commit is contained in:
Greg Hellings
2025-08-08 16:14:06 -05:00
parent 9066dcfeea
commit 4df117b535
3 changed files with 96 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
{
writeShellApplication,
gnugrep,
nix-prefetch,
subversion,
}:
writeShellApplication {
name = "sword-updater";
runtimeInputs = [
gnugrep
nix-prefetch
subversion
];
text = ''
url="https://www.crosswire.org/svn/sword/trunk"
old_rev="$(grep "${./flake.nix}" -e "rev = " | sed -E -e 's/.*"(.*)".*/\1/')"
echo "OLD_REV=$old_rev"
new_rev="$(svn info "$url" --show-item revision)"
echo "NEW_REV=$new_rev"
if [ "$new_rev" == "$old_rev" ]; then
#exit 0
else
echo "DO_UPDATE=1"
fi
hash="$(nix-prefetch \
--check-store \
--option extra-experimental-features flakes \
fetchsvn \
--url "$url" \
--rev "$new_rev" \
)"
echo "HASH=$hash"
sed -i flake.nix \
-e "s/rev = \"$old_rev\"/rev = \"$new_rev\"/"
'';
}