3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/scalafmt/default.nix

44 lines
1.1 KiB
Nix
Raw Normal View History

2017-12-08 08:31:04 +00:00
{ 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";
2018-09-20 15:18:38 +01:00
version = "1.5.1";
2017-12-08 08:31:04 +00:00
deps = stdenv.mkDerivation {
name = "${baseName}-deps-${version}";
2017-12-08 08:31:04 +00:00
buildCommand = ''
export COURSIER_CACHE=$(pwd)
${coursier}/bin/coursier fetch com.geirsson:scalafmt-cli_2.12:${version} > deps
2017-12-08 08:31:04 +00:00
mkdir -p $out/share/java
cp $(< deps) $out/share/java/
2017-12-08 08:31:04 +00:00
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
2018-09-20 15:18:38 +01:00
outputHash = "15xfys9wdlx3rrqb2ab6qcfngkf6sa8v8q8shh10kk8jrc30g6dk";
2016-05-09 18:41:21 +01:00
};
2017-12-08 08:31:04 +00:00
in
stdenv.mkDerivation rec {
name = "${baseName}-${version}";
2016-05-09 18:41:21 +01:00
2017-12-08 08:31:04 +00:00
buildInputs = [ jdk makeWrapper deps ];
2016-05-09 18:41:21 +01:00
2017-12-08 08:31:04 +00:00
doCheck = true;
2016-05-09 18:41:21 +01:00
2017-12-08 08:31:04 +00:00
phases = [ "installPhase" "checkPhase" ];
2016-05-09 18:41:21 +01: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 18:41:21 +01:00
2017-12-08 08:31:04 +00:00
checkPhase = ''
$out/bin/${baseName} --version | grep -q "${version}"
2016-05-09 18:41:21 +01:00
'';
meta = with stdenv.lib; {
description = "Opinionated code formatter for Scala";
homepage = http://scalafmt.org;
license = licenses.asl20;
maintainers = [ maintainers.markus1189 ];
};
}