2022-06-16 17:23:12 +00:00
|
|
|
{ stdenv
|
|
|
|
, coreutils
|
|
|
|
, lib
|
|
|
|
, installShellFiles
|
|
|
|
, zlib
|
|
|
|
, autoPatchelfHook
|
|
|
|
, fetchurl
|
|
|
|
, makeWrapper
|
|
|
|
, callPackage
|
|
|
|
, jre
|
|
|
|
}:
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
assert lib.versionAtLeast jre.version "17.0.0";
|
2021-12-06 16:07:01 +00:00
|
|
|
let
|
2022-06-16 17:23:12 +00:00
|
|
|
pname = "scala-cli";
|
|
|
|
sources = builtins.fromJSON (builtins.readFile ./sources.json);
|
|
|
|
inherit (sources) version assets;
|
|
|
|
|
|
|
|
platforms = builtins.attrNames assets;
|
2021-12-06 16:07:01 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
2022-06-16 17:23:12 +00:00
|
|
|
inherit pname version;
|
|
|
|
nativeBuildInputs = [ installShellFiles makeWrapper ]
|
2022-04-15 01:41:22 +00:00
|
|
|
++ lib.optional stdenv.isLinux autoPatchelfHook;
|
2021-12-06 16:07:01 +00:00
|
|
|
buildInputs = [ coreutils zlib stdenv.cc.cc ];
|
|
|
|
src =
|
|
|
|
let
|
|
|
|
asset = assets."${stdenv.hostPlatform.system}" or (throw "Unsupported platform ${stdenv.hostPlatform.system}");
|
|
|
|
in
|
|
|
|
fetchurl {
|
|
|
|
url = "https://github.com/Virtuslab/scala-cli/releases/download/v${version}/${asset.asset}";
|
|
|
|
sha256 = asset.sha256;
|
|
|
|
};
|
|
|
|
unpackPhase = ''
|
|
|
|
runHook preUnpack
|
|
|
|
gzip -d < $src > scala-cli
|
|
|
|
runHook postUnpack
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2022-06-16 17:23:12 +00:00
|
|
|
install -Dm755 scala-cli $out/bin/.scala-cli-wrapped
|
|
|
|
makeWrapper $out/bin/.scala-cli-wrapped $out/bin/scala-cli \
|
|
|
|
--set JAVA_HOME ${jre.home}
|
2021-12-06 16:07:01 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
# We need to call autopatchelf before generating completions
|
|
|
|
dontAutoPatchelf = true;
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
2021-12-06 16:07:01 +00:00
|
|
|
autoPatchelf $out
|
2022-04-15 01:41:22 +00:00
|
|
|
'' + ''
|
2021-12-06 16:07:01 +00:00
|
|
|
# hack to ensure the completion function looks right
|
|
|
|
# as $0 is used to generate the compdef directive
|
|
|
|
PATH="$out/bin:$PATH"
|
|
|
|
|
|
|
|
installShellCompletion --cmd scala-cli \
|
|
|
|
--bash <(scala-cli completions bash) \
|
|
|
|
--zsh <(scala-cli completions zsh)
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://scala-cli.virtuslab.org";
|
|
|
|
downloadPage = "https://github.com/VirtusLab/scala-cli/releases/v${version}";
|
|
|
|
license = licenses.asl20;
|
|
|
|
description = "Command-line tool to interact with the Scala language";
|
|
|
|
maintainers = [ maintainers.kubukoz ];
|
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
passthru.updateScript = callPackage ./update.nix { } { inherit platforms pname version; };
|
2021-12-06 16:07:01 +00:00
|
|
|
}
|