daml/nix/overrides/scalafmt.nix

44 lines
1.1 KiB
Nix
Raw Normal View History

{ stdenv, jdk, jre, coursier, makeWrapper, lib }:
let
baseName = "scalafmt";
version = "3.0.6";
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 = "0wsly5fhpywwrcz3pkcpyrzk43w887dfnyv70l4rkicd599arwy5";
};
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 lib; {
description = "Opinionated code formatter for Scala";
homepage = http://scalafmt.org;
license = licenses.asl20;
maintainers = [ maintainers.markus1189 ];
};
}