diff options
author | Peder Bergebakken Sundt <pbsds@hotmail.com> | 2024-06-24 13:54:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-24 13:54:17 +0200 |
commit | 5c33cba26b67a378d1bbb57491bb82a9b7b65cf2 (patch) | |
tree | e761996674ccc66fd83b4b284278c43be7ee3e31 /pkgs | |
parent | 86e1552f46d63bc9a1537a3e453f3919f3eec2c0 (diff) | |
parent | 7284a2000ace95772ed11f72d046e3763080235d (diff) |
Merge pull request #282445 from lelgenio/protoc-gen-dart-update
protoc-gen-dart: add passthru.updateScript
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/development/tools/protoc-gen-dart/default.nix | 2 | ||||
-rwxr-xr-x | pkgs/development/tools/protoc-gen-dart/update.sh | 33 |
2 files changed, 35 insertions, 0 deletions
diff --git a/pkgs/development/tools/protoc-gen-dart/default.nix b/pkgs/development/tools/protoc-gen-dart/default.nix index b09322e297014..06a96e70cf3e7 100644 --- a/pkgs/development/tools/protoc-gen-dart/default.nix +++ b/pkgs/development/tools/protoc-gen-dart/default.nix @@ -17,6 +17,8 @@ buildDartApplication rec { pubspecLock = lib.importJSON ./pubspec.lock.json; + passthru.updateScript = ./update.sh; + meta = with lib; { description = "Protobuf plugin for generating Dart code"; mainProgram = "protoc-gen-dart"; diff --git a/pkgs/development/tools/protoc-gen-dart/update.sh b/pkgs/development/tools/protoc-gen-dart/update.sh new file mode 100755 index 0000000000000..5bea5f3bea84c --- /dev/null +++ b/pkgs/development/tools/protoc-gen-dart/update.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p yq ripgrep common-updater-scripts dart + +set -xeu -o pipefail + +PACKAGE_DIR="$(realpath "$(dirname "$0")")" +cd "$PACKAGE_DIR/.." +while ! test -f flake.nix; do cd .. ; done +NIXPKGS_DIR="$PWD" + +version="$( + list-git-tags --url=https://github.com/google/protobuf.dart \ + | rg '^protobuf-v(.*)' -r '$1' \ + | sort --version-sort \ + | tail -n1 +)" + +cd "$NIXPKGS_DIR" +update-source-version protoc-gen-dart "$version" + +TMPDIR="$(mktemp -d)" +cd "$TMPDIR" + +src="$(nix-build --no-link "$NIXPKGS_DIR" -A protoc-gen-dart.src)/protoc_plugin" +cp $src/pubspec.* . + +if ! test -f pubspec.lock; then + dart pub update +fi + +yq . pubspec.lock > "$PACKAGE_DIR/pubspec.lock.json" + +rm -rf "$TMPDIR" |