Commit cea2daf7 authored by kyehn's avatar kyehn
Browse files

fvm: add updateScript

parent 9927f406
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -2,11 +2,13 @@
  lib,
  buildDartApplication,
  fetchFromGitHub,
  nix-update-script,
  runCommand,
  yq-go,
  _experimental-update-script-combinators,
  gitUpdater,
}:

buildDartApplication rec {
  pname = "fvm";
let
  version = "3.2.1";

  src = fetchFromGitHub {
@@ -15,10 +17,28 @@ buildDartApplication rec {
    tag = version;
    hash = "sha256-i7sJRBrS5qyW8uGlx+zg+wDxsxgmolTMcikHyOzv3Bs=";
  };
in
buildDartApplication {
  pname = "fvm";
  inherit version src;

  pubspecLock = lib.importJSON ./pubspec.lock.json;

  passthru.updateScript = nix-update-script { };
  passthru = {
    pubspecSource =
      runCommand "pubspec.lock.json"
        {
          inherit src;
          nativeBuildInputs = [ yq-go ];
        }
        ''
          yq eval --output-format=json --prettyPrint $src/pubspec.lock > "$out"
        '';
    updateScript = _experimental-update-script-combinators.sequence [
      (gitUpdater { })
      (_experimental-update-script-combinators.copyAttrOutputToFile "fvm.pubspecSource" ./pubspec.lock.json)
    ];
  };

  meta = {
    description = "Simple CLI to manage Flutter SDK versions";