1 { writeScript, runtimeShell }:
3 writeScript "update-mendeley" ''
8 NEWURL=$(curl -m20 -sI "$URL" -o /dev/null -w '%{redirect_url}')
9 [ -z "$NEWURL" ] && break
10 [[ $NEWURL = $URL ]] && (echo "redirect loop?!"; exit 1)
11 echo "Following $URL -> $NEWURL ..." >&2
18 amd64URL=$(follow https://www.mendeley.com/repositories/ubuntu/stable/amd64/mendeleydesktop-latest)
19 amd64V=$(basename $amd64URL|grep -m1 -o "[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?")
20 i386URL=$(follow https://www.mendeley.com/repositories/ubuntu/stable/i386/mendeleydesktop-latest)
21 i386V=$(basename $i386URL|grep -m1 -o "[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?")
23 echo "amd64 version: $amd64V"
24 echo "i386 version: $i386V"
25 if [[ $amd64V != $i386V ]]; then
26 echo "Versions not the same!"
30 if grep -q -F "$amd64V" ${./default.nix}; then
31 echo "No new version yet, nothing to do."
32 echo "Have a nice day!"
36 amd64OldHash=$(nix-instantiate --eval --strict -A "mendeley.src.drvAttrs.outputHash" --argstr system "x86_64-linux"| tr -d '"')
37 i386OldHash=$(nix-instantiate --eval --strict -A "mendeley.src.drvAttrs.outputHash" --argstr system "i686-linux"| tr -d '"')
39 echo "Prefetching amd64..."
40 amd64NewHash=$(nix-prefetch-url $amd64URL)
41 echo "Prefetching i386..."
42 i386NewHash=$(nix-prefetch-url $i386URL)
44 # Don't actually update, just report that an update is available
48 Time to update to $amd64V !
57 Exiting so this information is seen...
58 (no update is actually performed here)