2022-09-09 14:08:57 +00:00
|
|
|
{ lib, stdenv, jre, coursier, makeWrapper, setJavaClassPath }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
baseName = "scalafmt";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "3.5.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
deps = stdenv.mkDerivation {
|
|
|
|
name = "${baseName}-deps-${version}";
|
|
|
|
buildCommand = ''
|
|
|
|
export COURSIER_CACHE=$(pwd)
|
2021-12-06 16:07:01 +00:00
|
|
|
${coursier}/bin/cs fetch org.scalameta:scalafmt-cli_2.13:${version} > deps
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p $out/share/java
|
|
|
|
cp $(< deps) $out/share/java/
|
|
|
|
'';
|
|
|
|
outputHashMode = "recursive";
|
2022-09-09 14:08:57 +00:00
|
|
|
outputHash = "sha256-1QP5a0QjYUDU3JzrIX2rM/DclRfU/ACSXVLd6C7uFCo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
2021-08-05 21:33:18 +00:00
|
|
|
pname = baseName;
|
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper setJavaClassPath ];
|
|
|
|
buildInputs = [ deps ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
dontUnpack = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2021-08-05 21:33:18 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
makeWrapper ${jre}/bin/java $out/bin/${baseName} \
|
|
|
|
--add-flags "-cp $CLASSPATH org.scalafmt.cli.Cli"
|
2021-08-05 21:33:18 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
installCheckPhase = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
$out/bin/${baseName} --version | grep -q "${version}"
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Opinionated code formatter for Scala";
|
|
|
|
homepage = "http://scalameta.org/scalafmt";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = [ maintainers.markus1189 ];
|
|
|
|
};
|
|
|
|
}
|