From e4d8eb1c300a80deb057590a85a1ea15117321ee Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Wed, 11 Nov 2020 09:19:51 -0500 Subject: [PATCH] sbt-extras: Add update script --- .../build-managers/sbt-extras/default.nix | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/pkgs/development/tools/build-managers/sbt-extras/default.nix b/pkgs/development/tools/build-managers/sbt-extras/default.nix index 49d18d9e8575..038c88dff7e9 100644 --- a/pkgs/development/tools/build-managers/sbt-extras/default.nix +++ b/pkgs/development/tools/build-managers/sbt-extras/default.nix @@ -1,12 +1,10 @@ -{ stdenv, fetchFromGitHub, which, curl, makeWrapper, jdk }: +{ stdenv, fetchFromGitHub, which, curl, makeWrapper, jdk, writeScript +, common-updater-scripts, cacert, git, nixfmt, nix, jq, coreutils, gnused }: -let +stdenv.mkDerivation rec { + pname = "sbt-extras"; rev = "1e9230f35879ce23cbd8d16add07d2134fd479c9"; version = "2020-09-24"; -in -stdenv.mkDerivation { - name = "sbt-extras-${version}"; - inherit version; src = fetchFromGitHub { owner = "paulp"; @@ -26,14 +24,51 @@ stdenv.mkDerivation { install bin/sbt $out/bin - wrapProgram $out/bin/sbt --prefix PATH : ${stdenv.lib.makeBinPath [ which curl ]} + wrapProgram $out/bin/sbt --prefix PATH : ${ + stdenv.lib.makeBinPath [ which curl ] + } ''; + passthru = { + updateScript = writeScript "update.sh" '' + #!${stdenv.shell} + set -xo errexit + PATH=${ + stdenv.lib.makeBinPath [ + common-updater-scripts + curl + cacert + git + nixfmt + nix + jq + coreutils + gnused + ] + } + + oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')" + latestSha="$(curl -L -s https://api.github.com/repos/paulp/sbt-extras/commits\?sha\=master\&since\=$oldVersion | jq -r '.[0].sha')" + + if [ ! "null" = "$latestSha" ]; then + nixpkgs="$(git rev-parse --show-toplevel)" + default_nix="$nixpkgs/pkgs/development/tools/build-managers/sbt-extras/default.nix" + latestDate="$(curl -L -s https://api.github.com/repos/paulp/sbt-extras/commits/$latestSha | jq '.commit.committer.date' | sed 's|"\(.*\)T.*|\1|g')" + update-source-version ${pname} "$latestSha" --version-key=rev + update-source-version ${pname} "$latestDate" --ignore-same-hash + nixfmt "$default_nix" + else + echo "${pname} is already up-to-date" + fi + ''; + }; + meta = { - description = "A more featureful runner for sbt, the simple/scala/standard build tool"; + description = + "A more featureful runner for sbt, the simple/scala/standard build tool"; homepage = "https://github.com/paulp/sbt-extras"; license = stdenv.lib.licenses.bsd3; - maintainers = with stdenv.lib.maintainers; [ puffnfresh ]; + maintainers = with stdenv.lib.maintainers; [ nequissimus puffnfresh ]; platforms = stdenv.lib.platforms.unix; }; }