mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-30 17:43:42 +00:00
47 lines
1.1 KiB
Nix
47 lines
1.1 KiB
Nix
{ lib, stdenv, jre, coursier, makeWrapper, setJavaClassPath }:
|
|
|
|
let
|
|
baseName = "scalafmt";
|
|
version = "3.5.2";
|
|
deps = stdenv.mkDerivation {
|
|
name = "${baseName}-deps-${version}";
|
|
buildCommand = ''
|
|
export COURSIER_CACHE=$(pwd)
|
|
${coursier}/bin/cs fetch org.scalameta:scalafmt-cli_2.13:${version} > deps
|
|
mkdir -p $out/share/java
|
|
cp $(< deps) $out/share/java/
|
|
'';
|
|
outputHashMode = "recursive";
|
|
outputHash = "sha256-1QP5a0QjYUDU3JzrIX2rM/DclRfU/ACSXVLd6C7uFCo=";
|
|
};
|
|
in
|
|
stdenv.mkDerivation {
|
|
pname = baseName;
|
|
inherit version;
|
|
|
|
nativeBuildInputs = [ makeWrapper setJavaClassPath ];
|
|
buildInputs = [ deps ];
|
|
|
|
dontUnpack = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
makeWrapper ${jre}/bin/java $out/bin/${baseName} \
|
|
--add-flags "-cp $CLASSPATH org.scalafmt.cli.Cli"
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
installCheckPhase = ''
|
|
$out/bin/${baseName} --version | grep -q "${version}"
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Opinionated code formatter for Scala";
|
|
homepage = "http://scalameta.org/scalafmt";
|
|
license = licenses.asl20;
|
|
maintainers = [ maintainers.markus1189 ];
|
|
};
|
|
}
|