From 7e062659e97ba0c354a329dbf6ae2f9460cfc69b Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Wed, 4 Nov 2020 12:45:20 -0500 Subject: [PATCH] ammonite: Add test reference, update script --- nixos/tests/all-tests.nix | 1 + nixos/tests/ammonite.nix | 2 +- pkgs/development/tools/ammonite/default.nix | 40 +++++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 553f4f8fc4cc..e277f5922ccf 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -24,6 +24,7 @@ in _3proxy = handleTest ./3proxy.nix {}; acme = handleTest ./acme.nix {}; agda = handleTest ./agda.nix {}; + ammonite = handleTest ./ammonite.nix {}; atd = handleTest ./atd.nix {}; avahi = handleTest ./avahi.nix {}; avahi-with-resolved = handleTest ./avahi.nix { networkd = true; }; diff --git a/nixos/tests/ammonite.nix b/nixos/tests/ammonite.nix index 1955e42be5f0..e9f06358e13f 100644 --- a/nixos/tests/ammonite.nix +++ b/nixos/tests/ammonite.nix @@ -8,7 +8,7 @@ import ./make-test-python.nix ({ pkgs, ...} : { amm = { pkgs, ... }: { - environment.systemPackages = [ pkgs.ammonite ]; + environment.systemPackages = [ (pkgs.ammonite.override { jre = pkgs.jre8; }) ]; }; }; diff --git a/pkgs/development/tools/ammonite/default.nix b/pkgs/development/tools/ammonite/default.nix index 82e38e2a25f8..fc8ec00bb8b7 100644 --- a/pkgs/development/tools/ammonite/default.nix +++ b/pkgs/development/tools/ammonite/default.nix @@ -1,8 +1,11 @@ -{ stdenv, fetchurl, jre, disableRemoteLogging ? true }: +{ stdenv, fetchurl, jre, nixosTests, writeScript, common-updater-scripts, git +, nixfmt, nix, coreutils, gnused, disableRemoteLogging ? true }: with stdenv.lib; let + repo = "git@github.com:lihaoyi/Ammonite.git"; + common = { scalaVersion, sha256 }: stdenv.mkDerivation rec { pname = "ammonite"; @@ -24,6 +27,37 @@ let sed -i '1i #!/bin/sh' $out/bin/amm ''; + passthru = { + tests = { inherit (nixosTests) ammonite; }; + + updateScript = writeScript "update.sh" '' + #!${stdenv.shell} + set -o errexit + PATH=${ + stdenv.lib.makeBinPath [ + common-updater-scripts + coreutils + git + gnused + nix + nixfmt + ] + } + oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')" + latestTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags ${repo} '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3)" + if [ ! "$oldVersion" = "$latestTag" ]; then + nixpkgs="$(git rev-parse --show-toplevel)" + default_nix="$nixpkgs/pkgs/development/tools/ammonite/default.nix" + update-source-version ${pname}_2_12 "$latestTag" --version-key=version --print-changes + sed -i "s|$latestTag|$oldVersion|g" "$default_nix" + update-source-version ${pname}_2_13 "$latestTag" --version-key=version --print-changes + nixfmt "$default_nix" + else + echo "${pname} is already up-to-date" + fi + ''; + }; + meta = { description = "Improved Scala REPL"; longDescription = '' @@ -41,10 +75,10 @@ let in { ammonite_2_12 = common { scalaVersion = "2.12"; - sha256 = "0nclfqwy3jfn1680z1hd0zzmc0b79wpvx6gn1jnm19aq7qcvh5zp"; + sha256 = "9xe4GT5YpVCtDPaZvi9PZwFW/wcNhg+QCdbJ4Tl2lFk="; }; ammonite_2_13 = common { scalaVersion = "2.13"; - sha256 = "104bnahn382sb6vwjvchsg0jrnkkwjn08rfh0g5ra7lwhgcj2719"; + sha256 = "KRwh2YOcHpXLA9BlBKzkc9oswdOQbcm3WVqgYaGyi4A="; }; }