ammonite: Add test reference, update script

This commit is contained in:
Tim Steinbach 2020-11-04 12:45:20 -05:00
parent 0aaf9d6143
commit 7e062659e9
No known key found for this signature in database
GPG key ID: FD36A5EAAC49035A
3 changed files with 39 additions and 4 deletions

View file

@ -24,6 +24,7 @@ in
_3proxy = handleTest ./3proxy.nix {}; _3proxy = handleTest ./3proxy.nix {};
acme = handleTest ./acme.nix {}; acme = handleTest ./acme.nix {};
agda = handleTest ./agda.nix {}; agda = handleTest ./agda.nix {};
ammonite = handleTest ./ammonite.nix {};
atd = handleTest ./atd.nix {}; atd = handleTest ./atd.nix {};
avahi = handleTest ./avahi.nix {}; avahi = handleTest ./avahi.nix {};
avahi-with-resolved = handleTest ./avahi.nix { networkd = true; }; avahi-with-resolved = handleTest ./avahi.nix { networkd = true; };

View file

@ -8,7 +8,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
amm = amm =
{ pkgs, ... }: { pkgs, ... }:
{ {
environment.systemPackages = [ pkgs.ammonite ]; environment.systemPackages = [ (pkgs.ammonite.override { jre = pkgs.jre8; }) ];
}; };
}; };

View file

@ -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; with stdenv.lib;
let let
repo = "git@github.com:lihaoyi/Ammonite.git";
common = { scalaVersion, sha256 }: common = { scalaVersion, sha256 }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "ammonite"; pname = "ammonite";
@ -24,6 +27,37 @@ let
sed -i '1i #!/bin/sh' $out/bin/amm 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 = { meta = {
description = "Improved Scala REPL"; description = "Improved Scala REPL";
longDescription = '' longDescription = ''
@ -41,10 +75,10 @@ let
in { in {
ammonite_2_12 = common { ammonite_2_12 = common {
scalaVersion = "2.12"; scalaVersion = "2.12";
sha256 = "0nclfqwy3jfn1680z1hd0zzmc0b79wpvx6gn1jnm19aq7qcvh5zp"; sha256 = "9xe4GT5YpVCtDPaZvi9PZwFW/wcNhg+QCdbJ4Tl2lFk=";
}; };
ammonite_2_13 = common { ammonite_2_13 = common {
scalaVersion = "2.13"; scalaVersion = "2.13";
sha256 = "104bnahn382sb6vwjvchsg0jrnkkwjn08rfh0g5ra7lwhgcj2719"; sha256 = "KRwh2YOcHpXLA9BlBKzkc9oswdOQbcm3WVqgYaGyi4A=";
}; };
} }