Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at litex 80 lines 2.3 kB view raw
1{ stdenv 2, coreutils 3, lib 4, installShellFiles 5, zlib 6, autoPatchelfHook 7, fetchurl 8, makeWrapper 9, callPackage 10, jre 11}: 12 13let 14 pname = "scala-cli"; 15 sources = lib.importJSON ./sources.json; 16 inherit (sources) version assets; 17 18 platforms = builtins.attrNames assets; 19in 20stdenv.mkDerivation { 21 inherit pname version; 22 nativeBuildInputs = [ installShellFiles makeWrapper ] 23 ++ lib.optional stdenv.isLinux autoPatchelfHook; 24 buildInputs = 25 assert lib.assertMsg (lib.versionAtLeast jre.version "17.0.0") '' 26 scala-cli requires Java 17 or newer, but ${jre.name} is ${jre.version} 27 ''; 28 [ coreutils zlib stdenv.cc.cc ]; 29 src = 30 let 31 asset = assets."${stdenv.hostPlatform.system}" or (throw "Unsupported platform ${stdenv.hostPlatform.system}"); 32 in 33 fetchurl { 34 url = "https://github.com/Virtuslab/scala-cli/releases/download/v${version}/${asset.asset}"; 35 sha256 = asset.sha256; 36 }; 37 unpackPhase = '' 38 runHook preUnpack 39 gzip -d < $src > scala-cli 40 runHook postUnpack 41 ''; 42 43 installPhase = '' 44 runHook preInstall 45 install -Dm755 scala-cli $out/bin/.scala-cli-wrapped 46 makeWrapper $out/bin/.scala-cli-wrapped $out/bin/scala-cli \ 47 --set JAVA_HOME ${jre.home} \ 48 --argv0 "$out/bin/scala-cli" 49 runHook postInstall 50 ''; 51 52 # We need to call autopatchelf before generating completions 53 dontAutoPatchelf = true; 54 55 postFixup = lib.optionalString stdenv.isLinux '' 56 autoPatchelf $out 57 '' + '' 58 # hack to ensure the completion function looks right 59 # as $0 is used to generate the compdef directive 60 mkdir temp 61 cp $out/bin/.scala-cli-wrapped temp/scala-cli 62 PATH="./temp:$PATH" 63 64 installShellCompletion --cmd scala-cli \ 65 --bash <(scala-cli completions bash) \ 66 --zsh <(scala-cli completions zsh) 67 ''; 68 69 meta = with lib; { 70 homepage = "https://scala-cli.virtuslab.org"; 71 downloadPage = "https://github.com/VirtusLab/scala-cli/releases/v${version}"; 72 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 73 license = licenses.asl20; 74 description = "Command-line tool to interact with the Scala language"; 75 maintainers = [ maintainers.kubukoz ]; 76 inherit platforms; 77 }; 78 79 passthru.updateScript = callPackage ./update.nix { } { inherit platforms pname version; }; 80}