From 614a6d43a7c81bdd58f5fe5e0fda682f87c1fb4d Mon Sep 17 00:00:00 2001 From: Markus Hauck Date: Fri, 8 Dec 2017 09:31:04 +0100 Subject: [PATCH] scalafmt: 0.6.8 -> 1.3.0 --- pkgs/development/tools/scalafmt/default.nix | 43 ++++++++++++--------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/pkgs/development/tools/scalafmt/default.nix b/pkgs/development/tools/scalafmt/default.nix index 391c653b98ab..ae2bbd08e4c9 100644 --- a/pkgs/development/tools/scalafmt/default.nix +++ b/pkgs/development/tools/scalafmt/default.nix @@ -1,29 +1,36 @@ -{ stdenv, fetchurl, unzip, jre }: +{ stdenv, jdk, jre, coursier, makeWrapper }: -stdenv.mkDerivation rec { - version = "0.6.8"; +let baseName = "scalafmt"; + version = "1.3.0"; + deps = stdenv.mkDerivation { + name = "${baseName}-${version}-deps"; + buildCommand = '' + export COURSIER_CACHE=$(pwd) + mkdir -p $out/share/java + cp $(${coursier}/bin/coursier fetch com.geirsson:scalafmt-cli_2.12:${version}) $out/share/java/ + ''; + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + outputHash = "0q1vw6drpdrfifbm3266igpml0phdk6pl0gd3b5amysigx83m251"; + }; +in +stdenv.mkDerivation rec { name = "${baseName}-${version}"; - src = fetchurl { - url = "https://github.com/scalameta/scalafmt/releases/download/v${version}/${baseName}.tar.gz"; - sha256 = "1iaanrxk5lhxx1zj9gbxzgqbnyy1azfrab984mga7di5z1hs02s2"; - }; + buildInputs = [ jdk makeWrapper deps ]; - unpackPhase = "tar xvzf $src"; + doCheck = true; + + phases = [ "installPhase" "checkPhase" ]; installPhase = '' - mkdir -p "$out/bin" - mkdir -p "$out/lib" + makeWrapper ${jre}/bin/java $out/bin/${baseName} \ + --add-flags "-cp $CLASSPATH org.scalafmt.cli.Cli" + ''; - cp cli/target/scala-2.11/scalafmt.jar "$out/lib/${name}.jar" - - cat > "$out/bin/${baseName}" << EOF - #!${stdenv.shell} - exec ${jre}/bin/java -jar "$out/lib/${name}.jar" "\$@" - EOF - - chmod a+x "$out/bin/${baseName}" + checkPhase = '' + $out/bin/${baseName} --version | grep -q "${version}" ''; meta = with stdenv.lib; {