babashka: add passthru.updateScript

This commit is contained in:
Thiago Kenji Okada 2021-10-19 18:30:11 -03:00
parent 5fa9b22eef
commit 38001b1454

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl, graalvm11-ce, glibcLocales }:
{ lib, stdenv, fetchurl, graalvm11-ce, glibcLocales, writeScript }:
stdenv.mkDerivation rec {
pname = "babashka";
@ -58,6 +58,21 @@ stdenv.mkDerivation rec {
$out/bin/bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' | grep '[1 2]'
'';
passthru.updateScript = writeScript "update-babashka" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts jq
set -euo pipefail
readonly latest_version="$(curl \
''${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \
-s "https://api.github.com/repos/babashka/babashka/releases/latest" \
| jq -r '.tag_name')"
# v0.6.2 -> 0.6.2
update-source-version babashka "''${latest_version/v/}"
'';
meta = with lib; {
description = "A Clojure babushka for the grey areas of Bash";
longDescription = ''