2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, jdk, jre, coursier, makeWrapper }:
|
2016-05-09 18:41:21 +01:00
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
let
|
2016-05-09 18:41:21 +01:00
|
|
|
baseName = "scalafmt";
|
2022-02-02 07:21:35 +00:00
|
|
|
version = "3.4.0";
|
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)
|
2021-10-29 01:48:26 +01:00
|
|
|
${coursier}/bin/cs fetch org.scalameta:scalafmt-cli_2.13:${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";
|
2022-02-02 07:21:35 +00:00
|
|
|
outputHash = "l5F09bjRev2eBHKTMzojC7+USkW7qf3YtA2KSoN7MxM=";
|
2016-05-09 18:41:21 +01:00
|
|
|
};
|
2017-12-08 08:31:04 +00:00
|
|
|
in
|
2019-08-13 22:52:01 +01:00
|
|
|
stdenv.mkDerivation {
|
2021-07-25 00:21:45 +01:00
|
|
|
pname = baseName;
|
|
|
|
inherit version;
|
2016-05-09 18:41:21 +01:00
|
|
|
|
2019-05-08 17:13:15 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ jdk deps ];
|
2016-05-09 18:41:21 +01:00
|
|
|
|
2021-07-25 00:21:45 +01:00
|
|
|
dontUnpack = true;
|
2016-05-09 18:41:21 +01:00
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
installPhase = ''
|
2021-07-25 00:21:45 +01:00
|
|
|
runHook preInstall
|
|
|
|
|
2017-12-08 08:31:04 +00:00
|
|
|
makeWrapper ${jre}/bin/java $out/bin/${baseName} \
|
|
|
|
--add-flags "-cp $CLASSPATH org.scalafmt.cli.Cli"
|
2021-07-25 00:21:45 +01:00
|
|
|
|
|
|
|
runHook postInstall
|
2017-12-08 08:31:04 +00:00
|
|
|
'';
|
2016-05-09 18:41:21 +01:00
|
|
|
|
2021-07-25 00:21:45 +01:00
|
|
|
installCheckPhase = ''
|
2017-12-08 08:31:04 +00:00
|
|
|
$out/bin/${baseName} --version | grep -q "${version}"
|
2016-05-09 18:41:21 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2016-05-09 18:41:21 +01:00
|
|
|
description = "Opinionated code formatter for Scala";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://scalameta.org/scalafmt";
|
2016-05-09 18:41:21 +01:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = [ maintainers.markus1189 ];
|
|
|
|
};
|
|
|
|
}
|