nixpkgs-suyu/pkgs/development/tools/scalafmt/default.nix

45 lines
1.1 KiB
Nix
Raw Normal View History

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