2 , lib, curl, runtimeShell, jq, coreutils, moreutils, nix, gnused }:
4 writeScript "update-standardnotes" ''
6 PATH=${lib.makeBinPath [ jq curl nix coreutils moreutils gnused ]}
12 srcJson=pkgs/applications/editors/standardnotes/src.json
13 jsonPath="$tmpDir"/latest
15 oldVersion=$(jq -r .version < "$srcJson")
17 curl https://api.github.com/repos/standardnotes/app/releases/latest > "$jsonPath"
19 tagName=$(jq -r .tag_name < "$jsonPath")
21 if [[ ! "$tagName" =~ "desktop" ]]; then
22 echo "latest release '$tagName' not a desktop release"
26 newVersion=$(jq -r .tag_name < "$jsonPath" | sed s,@standardnotes/desktop@,,g)
28 if [[ "$oldVersion" == "$newVersion" ]]; then
29 echo "version did not change"
33 function getDownloadUrl() {
34 jq -r ".assets[] | select(.name==\"standard-notes-$newVersion-$1.deb\") | .browser_download_url" < "$jsonPath"
37 function setJsonKey() {
38 jq "$1 = \"$2\"" "$srcJson" | sponge "$srcJson"
41 function updatePlatform() {
44 url=$(getDownloadUrl "$upstreamPlatform")
45 hash=$(nix-prefetch-url "$url" --type sha512)
46 sriHash=$(nix hash to-sri --type sha512 $hash)
47 setJsonKey .deb[\""$nixPlatform"\"].url "$url"
48 setJsonKey .deb[\""$nixPlatform"\"].hash "$sriHash"
51 updatePlatform x86_64-linux linux-amd64
52 updatePlatform aarch64-linux linux-arm64
53 setJsonKey .version "$newVersion"