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