nixpkgs/pkgs/tools/misc/plantuml-server/default.nix

71 lines
1.9 KiB
Nix
Raw Normal View History

2021-05-15 11:56:22 +02:00
{ lib, stdenv, fetchFromGitHub, maven, jdk8_headless }:
2020-07-08 17:55:37 +02:00
let
2021-10-23 17:21:56 +02:00
version = "1.2021.12";
2020-07-08 17:55:37 +02:00
src = fetchFromGitHub {
owner = "plantuml";
repo = "plantuml-server";
rev = "v${version}";
2021-10-23 17:21:56 +02:00
sha256 = "sha256:016mrs4djbaid1ma5922dvq372pphbzzmjzsjalj2dqp60538xll";
2020-07-08 17:55:37 +02:00
};
# perform fake build to make a fixed-output derivation out of the files downloaded from maven central
deps = stdenv.mkDerivation {
name = "plantuml-server-${version}-deps";
inherit src;
2021-05-15 11:56:22 +02:00
nativeBuildInputs = [ jdk8_headless maven ];
2020-07-08 17:55:37 +02:00
buildPhase = ''
2021-05-15 11:56:22 +02:00
runHook preBuild
2020-07-08 17:55:37 +02:00
while mvn package -Dmaven.repo.local=$out/.m2; [ $? = 1 ]; do
echo "timeout, restart maven to continue downloading"
done
2021-05-15 11:56:22 +02:00
runHook postBuild
2020-07-08 17:55:37 +02:00
'';
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
installPhase = ''find $out/.m2 -type f -regex '.+\(\.lastUpdated\|resolver-status\.properties\|_remote\.repositories\)' -delete'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
2021-10-23 17:21:56 +02:00
outputHash = "sha256:12w1iw9c5j7y9hhaip07j3aszjiiakkww1v3zszlj15fj8jgqyf2";
2020-07-08 17:55:37 +02:00
};
in
stdenv.mkDerivation rec {
pname = "plantuml-server";
inherit version;
inherit src;
2021-05-15 11:56:22 +02:00
nativeBuildInputs = [ jdk8_headless maven ];
2020-07-08 17:55:37 +02:00
buildPhase = ''
2021-05-15 11:56:22 +02:00
runHook preBuild
2020-07-08 17:55:37 +02:00
# 'maven.repo.local' must be writable so copy it out of nix store
cp -R $src repo
chmod +w -R repo
cd repo
mvn package --offline -Dmaven.repo.local=$(cp -dpR ${deps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2
2021-05-15 11:56:22 +02:00
runHook postBuild
2020-07-08 17:55:37 +02:00
'';
installPhase = ''
2021-05-15 11:56:22 +02:00
runHook preInstall
2020-07-08 17:55:37 +02:00
mkdir -p "$out/webapps"
cp "target/plantuml.war" "$out/webapps/plantuml.war"
2021-05-15 11:56:22 +02:00
runHook postInstall
2020-07-08 17:55:37 +02:00
'';
meta = with lib; {
2020-07-08 17:55:37 +02:00
description = "A web application to generate UML diagrams on-the-fly.";
homepage = "https://plantuml.com/";
2021-05-15 11:56:22 +02:00
license = licenses.gpl3Plus;
2020-07-08 17:55:37 +02:00
platforms = platforms.all;
maintainers = with maintainers; [ truh ];
};
}