2017-12-08 08:31:04 +00:00
|
|
|
{ stdenv, jdk, jre, coursier, makeWrapper }:
|
2016-05-09 17:41:21 +00:00
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
let
|
2016-05-09 17:41:21 +00:00
|
|
|
baseName = "scalafmt";
|
2019-08-23 07:28:31 +00:00
|
|
|
version = "2.0.1";
|
2017-12-08 08:31:04 +00:00
|
|
|
deps = stdenv.mkDerivation {
|
2017-12-15 19:34:14 +00:00
|
|
|
name = "${baseName}-deps-${version}";
|
2017-12-08 08:31:04 +00:00
|
|
|
buildCommand = ''
|
|
|
|
export COURSIER_CACHE=$(pwd)
|
2019-04-05 04:46:45 +00:00
|
|
|
${coursier}/bin/coursier fetch org.scalameta:scalafmt-cli_2.12:${version} > deps
|
2017-12-08 08:31:04 +00:00
|
|
|
mkdir -p $out/share/java
|
2017-12-15 19:34:14 +00:00
|
|
|
cp $(< deps) $out/share/java/
|
2017-12-08 08:31:04 +00:00
|
|
|
'';
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
2019-08-23 07:28:31 +00:00
|
|
|
outputHash = "1k5qn0w6hqql8yqhlma67ilp8hf0xwxwkzvwg8bkky1jvsapjsl5";
|
2016-05-09 17:41:21 +00:00
|
|
|
};
|
2017-12-08 08:31:04 +00:00
|
|
|
in
|
2019-08-13 21:52:01 +00:00
|
|
|
stdenv.mkDerivation {
|
2017-12-08 08:31:04 +00:00
|
|
|
name = "${baseName}-${version}";
|
2016-05-09 17:41:21 +00:00
|
|
|
|
2019-05-08 16:13:15 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ jdk deps ];
|
2016-05-09 17:41:21 +00:00
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
doCheck = true;
|
2016-05-09 17:41:21 +00:00
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
phases = [ "installPhase" "checkPhase" ];
|
2016-05-09 17:41:21 +00:00
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
installPhase = ''
|
|
|
|
makeWrapper ${jre}/bin/java $out/bin/${baseName} \
|
|
|
|
--add-flags "-cp $CLASSPATH org.scalafmt.cli.Cli"
|
|
|
|
'';
|
2016-05-09 17:41:21 +00:00
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
checkPhase = ''
|
|
|
|
$out/bin/${baseName} --version | grep -q "${version}"
|
2016-05-09 17:41:21 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Opinionated code formatter for Scala";
|
2019-04-05 04:46:45 +00:00
|
|
|
homepage = http://scalameta.org/scalafmt;
|
2016-05-09 17:41:21 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = [ maintainers.markus1189 ];
|
|
|
|
};
|
|
|
|
}
|