biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / ammonite / default.nix
blob4a33b713d7d7f051fc7afff1aeb179468fd84c4c
1 { lib, stdenv, fetchurl, jre, writeScript, common-updater-scripts, git, nixfmt-classic
2 , nix, coreutils, gnused, disableRemoteLogging ? true }:
4 let
5   repo = "git@github.com:lihaoyi/Ammonite.git";
7   common = { scalaVersion, sha256 }:
8     stdenv.mkDerivation rec {
9       pname = "ammonite";
10       version = "3.0.0-M1";
12       src = fetchurl {
13         url =
14           "https://github.com/lihaoyi/Ammonite/releases/download/${version}/${scalaVersion}-${version}";
15         inherit sha256;
16       };
18       dontUnpack = true;
20       installPhase = ''
21         install -Dm755 $src $out/bin/amm
22         sed -i '0,/java/{s|java|${jre}/bin/java|}' $out/bin/amm
23       '' + lib.optionalString (disableRemoteLogging) ''
24         sed -i "0,/ammonite.Main/{s|ammonite.Main'|ammonite.Main' --no-remote-logging|}" $out/bin/amm
25         sed -i '1i #!/bin/sh' $out/bin/amm
26       '';
28       passthru = {
30         updateScript = writeScript "update.sh" ''
31           #!${stdenv.shell}
32           set -o errexit
33           PATH=${
34             lib.makeBinPath [
35               common-updater-scripts
36               coreutils
37               git
38               gnused
39               nix
40               nixfmt-classic
41             ]
42           }
43           oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
44           latestTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags ${repo} '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3)"
45           if [ "$oldVersion" != "$latestTag" ]; then
46             nixpkgs="$(git rev-parse --show-toplevel)"
47             default_nix="$nixpkgs/pkgs/development/tools/ammonite/default.nix"
48             update-source-version ${pname}_2_12 "$latestTag" --version-key=version --print-changes
49             sed -i "s|$latestTag|$oldVersion|g" "$default_nix"
50             update-source-version ${pname}_2_13 "$latestTag" --version-key=version --print-changes
51             nixfmt "$default_nix"
52           else
53             echo "${pname} is already up-to-date"
54           fi
55         '';
56       };
58       doInstallCheck = true;
59       installCheckPhase = ''
60         runHook preInstallCheck
62         $out/bin/amm -h "$PWD" -c 'val foo = 21; println(foo * 2)' | grep 42
64         runHook postInstallCheck
65       '';
67       meta = with lib; {
68         description = "Improved Scala REPL";
69         longDescription = ''
70           The Ammonite-REPL is an improved Scala REPL, re-implemented from first principles.
71           It is much more featureful than the default REPL and comes
72           with a lot of ergonomic improvements and configurability
73           that may be familiar to people coming from IDEs or other REPLs such as IPython or Zsh.
74         '';
75         homepage = "https://github.com/com-lihaoyi/Ammonite";
76         license = licenses.mit;
77         maintainers = [ maintainers.nequissimus ];
78         mainProgram = "amm";
79         platforms = platforms.all;
80       };
81     };
82 in {
83   ammonite_2_12 = common {
84     scalaVersion = "2.12";
85     sha256 = "sha256-SlweOVHudknbInM4rfEPJ9bLd3Z/EImLhVLzeKfjfMQ=";
86   };
87   ammonite_2_13 = common {
88     scalaVersion = "2.13";
89     sha256 = "sha256-2BydXmF6AkWDdG5rbRLD2I/6z3w3UD0dCd5Tp+3lU7c=";
90   };