nixpkgs/pkgs/development/tools/scalafmt/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.1 KiB
Nix
Raw Normal View History

{ lib, stdenv, jre, coursier, makeWrapper, setJavaClassPath }:
2016-05-09 17:41:21 +00:00
2017-12-08 08:31:04 +00:00
let
2016-05-09 17:41:21 +00:00
baseName = "scalafmt";
version = "3.5.2";
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/cs fetch org.scalameta:scalafmt-cli_2.13:${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";
outputHash = "sha256-1QP5a0QjYUDU3JzrIX2rM/DclRfU/ACSXVLd6C7uFCo=";
2016-05-09 17:41:21 +00:00
};
2017-12-08 08:31:04 +00:00
in
2019-08-13 21:52:01 +00:00
stdenv.mkDerivation {
pname = baseName;
inherit version;
2016-05-09 17:41:21 +00:00
nativeBuildInputs = [ makeWrapper setJavaClassPath ];
buildInputs = [ deps ];
2016-05-09 17:41:21 +00:00
dontUnpack = true;
2016-05-09 17:41:21 +00:00
2017-12-08 08:31:04 +00:00
installPhase = ''
runHook preInstall
2017-12-08 08:31:04 +00:00
makeWrapper ${jre}/bin/java $out/bin/${baseName} \
--add-flags "-cp $CLASSPATH org.scalafmt.cli.Cli"
runHook postInstall
2017-12-08 08:31:04 +00:00
'';
2016-05-09 17:41:21 +00:00
installCheckPhase = ''
2017-12-08 08:31:04 +00:00
$out/bin/${baseName} --version | grep -q "${version}"
2016-05-09 17:41:21 +00:00
'';
meta = with lib; {
2016-05-09 17:41:21 +00:00
description = "Opinionated code formatter for Scala";
homepage = "http://scalameta.org/scalafmt";
2016-05-09 17:41:21 +00:00
license = licenses.asl20;
maintainers = [ maintainers.markus1189 ];
};
}