2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, jdk, jre, coursier, makeWrapper }:
|
|
|
|
|
|
|
|
let
|
|
|
|
baseName = "scalafmt";
|
2020-05-29 06:06:01 +00:00
|
|
|
version = "2.5.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
deps = stdenv.mkDerivation {
|
|
|
|
name = "${baseName}-deps-${version}";
|
|
|
|
buildCommand = ''
|
|
|
|
export COURSIER_CACHE=$(pwd)
|
|
|
|
${coursier}/bin/coursier fetch org.scalameta:scalafmt-cli_2.12:${version} > deps
|
|
|
|
mkdir -p $out/share/java
|
|
|
|
cp $(< deps) $out/share/java/
|
|
|
|
'';
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
2020-05-29 06:06:01 +00:00
|
|
|
outputHash = "14sfpzhd7r8srl9qyrdfqwmgrircqsgrr5hwvg8h1vaiwakq7m00";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "${baseName}-${version}";
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ jdk deps ];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
phases = [ "installPhase" "checkPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
makeWrapper ${jre}/bin/java $out/bin/${baseName} \
|
|
|
|
--add-flags "-cp $CLASSPATH org.scalafmt.cli.Cli"
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
$out/bin/${baseName} --version | grep -q "${version}"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Opinionated code formatter for Scala";
|
|
|
|
homepage = "http://scalameta.org/scalafmt";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = [ maintainers.markus1189 ];
|
|
|
|
};
|
|
|
|
}
|