Unverified Commit 44086cd8 authored by nayeko's avatar nayeko Committed by GitHub
Browse files

butterfly: refactor

parent c81c0801
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -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";
+0 −20
Original line number Diff line number Diff line
#!/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