3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/scalafmt/default.nix
2019-04-05 00:46:45 -04:00

44 lines
1.1 KiB
Nix

{ stdenv, jdk, jre, coursier, makeWrapper }:
let
baseName = "scalafmt";
version = "2.0.0-RC5";
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";
outputHash = "0y2nja4dj3l7f7m9dxr8xwda8vv27dwj090gfsa78a20vq1d3xxw";
};
in
stdenv.mkDerivation rec {
name = "${baseName}-${version}";
buildInputs = [ jdk makeWrapper 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 ];
};
}