diff --git a/pkgs/by-name/bu/butterfly/package.nix b/pkgs/by-name/bu/butterfly/package.nix index b8a87e17654c..7407c72586a8 100644 --- a/pkgs/by-name/bu/butterfly/package.nix +++ b/pkgs/by-name/bu/butterfly/package.nix @@ -2,6 +2,11 @@ lib, fetchFromGitHub, flutter327, + runCommand, + butterfly, + yq, + _experimental-update-script-combinators, + gitUpdater, }: flutter327.buildFlutterApplication rec { pname = "butterfly"; @@ -37,7 +42,21 @@ flutter327.buildFlutterApplication rec { cp -r linux/debian/usr/share $out/share ''; - passthru.updateScript = ./update.sh; + passthru = { + pubspecSource = + runCommand "pubspec.lock.json" + { + buildInputs = [ yq ]; + inherit (butterfly) src; + } + '' + cat $src/app/pubspec.lock | yq > $out + ''; + updateScript = _experimental-update-script-combinators.sequence [ + (gitUpdater { rev-prefix = "v"; }) + (_experimental-update-script-combinators.copyAttrOutputToFile "butterfly.pubspecSource" ./pubspec.lock.json) + ]; + }; meta = { description = "Powerful, minimalistic, cross-platform, opensource note-taking app"; diff --git a/pkgs/by-name/bu/butterfly/update.sh b/pkgs/by-name/bu/butterfly/update.sh deleted file mode 100755 index 19732e0a7406..000000000000 --- a/pkgs/by-name/bu/butterfly/update.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -I nixpkgs=./. -i bash -p curl jq yq nix bash coreutils nix-update - -set -eou pipefail - -ROOT="$(dirname "$(readlink -f "$0")")" - -latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/LinwoodDev/Butterfly/releases/latest | jq --raw-output .tag_name) -latestVersion=$(echo "$latestTag" | sed 's/^v//') - -currentVersion=$(nix-instantiate --eval -E "with import ./. {}; butterfly.version or (lib.getVersion butterfly)" | tr -d '"') - -if [[ "$currentVersion" == "$latestVersion" ]]; then - echo "package is up-to-date: $currentVersion" - exit 0 -fi - -nix-update butterfly - -curl https://raw.githubusercontent.com/LinwoodDev/Butterfly/${latestTag}/app/pubspec.lock | yq . >$ROOT/pubspec.lock.json