butterfly: refactor

This commit is contained in:
nayeko
2025-02-15 18:06:12 +00:00
committed by GitHub
parent c81c080102
commit 44086cd8e4
2 changed files with 20 additions and 21 deletions
+20 -1
View File
@@ -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";
-20
View File
@@ -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