lol
at 23.11-beta 91 lines 3.2 kB view raw
1{ lib, stdenv, fetchurl, jre, writeScript, common-updater-scripts, git, nixfmt 2, nix, coreutils, gnused, disableRemoteLogging ? true }: 3 4let 5 repo = "git@github.com:lihaoyi/Ammonite.git"; 6 7 common = { scalaVersion, sha256 }: 8 stdenv.mkDerivation rec { 9 pname = "ammonite"; 10 version = "2.5.3"; 11 12 src = fetchurl { 13 url = 14 "https://github.com/lihaoyi/Ammonite/releases/download/${version}/${scalaVersion}-${version}"; 15 inherit sha256; 16 }; 17 18 dontUnpack = true; 19 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 ''; 27 28 passthru = { 29 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 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 }; 57 58 doInstallCheck = true; 59 installCheckPhase = '' 60 runHook preInstallCheck 61 62 $out/bin/amm -h "$PWD" -c 'val foo = 21; println(foo * 2)' | grep 42 63 64 runHook postInstallCheck 65 ''; 66 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 }; 82in { 83 ammonite_2_12 = common { 84 scalaVersion = "2.12"; 85 sha256 = "sha256-Iov55ohFjcGhur5UEng7aAZJPVua1H/JaKKW6OKS6Zg="; 86 }; 87 ammonite_2_13 = common { 88 scalaVersion = "2.13"; 89 sha256 = "sha256-dzUhKUQDHrYZ4WyCk4z4CTxb6vK05qfApR/WPOwhA5s="; 90 }; 91}