diff options
author | Michal Koutenský <michal@koutensky.net> | 2023-10-14 18:23:04 +0200 |
---|---|---|
committer | Michal Koutenský <michal@koutensky.net> | 2023-10-14 18:23:04 +0200 |
commit | 61c299f1123a0ce94c276737d861d3a3908edbf2 (patch) | |
tree | 6b04e8b0def2e50b773152040c390aedcc940391 /pkgs/applications/networking/instant-messengers/ferdium | |
parent | 917f9137a7a6b4ab2926cd0188dad47f2fbee850 (diff) |
ferdium: add custom update script
Based on the Lidarr script:
https://github.com/NixOS/nixpkgs/blob/952869b980485e5d491eafb33516f5bd911fcd53/pkgs/servers/lidarr/update.sh
Diffstat (limited to 'pkgs/applications/networking/instant-messengers/ferdium')
-rw-r--r-- | pkgs/applications/networking/instant-messengers/ferdium/default.nix | 4 | ||||
-rwxr-xr-x | pkgs/applications/networking/instant-messengers/ferdium/update.sh | 40 |
2 files changed, 41 insertions, 3 deletions
diff --git a/pkgs/applications/networking/instant-messengers/ferdium/default.nix b/pkgs/applications/networking/instant-messengers/ferdium/default.nix index 15fbaa1a8526..0439a1d2eb91 100644 --- a/pkgs/applications/networking/instant-messengers/ferdium/default.nix +++ b/pkgs/applications/networking/instant-messengers/ferdium/default.nix @@ -21,9 +21,7 @@ in mkFranzDerivation rec { extraBuildInputs = [ xorg.libxshmfence ]; passthru = { - updateScript = nix-update-script { - extraArgs = [ "--override-filename" ./default.nix ]; - }; + updateScript = ./update.sh; }; meta = with lib; { diff --git a/pkgs/applications/networking/instant-messengers/ferdium/update.sh b/pkgs/applications/networking/instant-messengers/ferdium/update.sh new file mode 100755 index 000000000000..bb59b7efdffb --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/ferdium/update.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnused nix-prefetch jq + +set -e + +dirname="$(dirname "$0")" + +updateHash() +{ + version=$1 + arch=$2 + + hashKey="${arch}-linux_hash" + + url="https://github.com/ferdium/ferdium-app/releases/download/v$version/Ferdium-linux-$version-$arch.deb" + hash=$(nix-prefetch-url --type sha256 $url) + sriHash="$(nix hash to-sri --type sha256 $hash)" + + sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$sriHash\";|g" "$dirname/default.nix" +} + +updateVersion() +{ + sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix" +} + +currentVersion=$(cd $dirname && nix eval --raw -f ../../../../.. ferdium.version) + +latestTag=$(curl https://api.github.com/repos/ferdium/ferdium-app/releases/latest | jq -r ".tag_name") +latestVersion="$(expr $latestTag : 'v\(.*\)')" + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "Ferdium is up-to-date: ${currentVersion}" + exit 0 +fi + +updateVersion $latestVersion + +updateHash $latestVersion amd64 +updateHash $latestVersion arm64 |