1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-30 01:20:40 +00:00
nixpkgs/pkgs/development/tools/scalafmt/default.nix
2019-11-01 10:21:54 +01:00

45 lines
1.1 KiB
Nix

{ stdenv, jdk, jre, coursier, makeWrapper }:
let
baseName = "scalafmt";
version = "2.2.2";
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 = "08qzcmps2biaf267nv945a924ca7rw8w7gzmjfv32r7aayz6pk1l";
};
in
stdenv.mkDerivation {
name = "${baseName}-${version}";
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ jdk 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 ];
};
}