plantuml-c4: init at unstable-2022-08-21

This commit is contained in:
Jacek Galowicz
2022-10-01 13:15:47 +02:00
committed by Bjørn Forsman
parent 1c23b486f2
commit cec24ab1c8
2 changed files with 67 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
{ lib, stdenv, makeWrapper, fetchzip, runCommand, plantuml, plantuml-c4, jre }:
# The C4-PlantUML docs say that it suffices to run plantuml with the
# -DRELATIVE_INCLUDE="..." arg to make plantuml find the C4 templates
# when included like "!include C4_Container.puml".
# Unfortunately, this is not sufficient in practise, when the path is not ".".
# What helps is setting -Dplantuml.include.path="..." *before* the jar
# parameter.
# The -DRELATIVE_INCLUDE param then *still* needs to be set (*after* the jar
# argument), because the C4 template vars check for existence of this variable
# and if it is not set, reference paths in the internet.
let
c4-lib = fetchzip {
url = "https://github.com/plantuml-stdlib/C4-PlantUML/archive/88a3f99150c6ff7953c4a99b184d03412ffdedb1.zip";
sha256 = "sha256-vk4YWdGb47OsI9mApGTQ7OfELRZdBouzKfUZq3kchcM=";
};
# In order to pre-fix the plantuml.jar parameter with the argument
# -Dplantuml.include.path=..., we post-fix the java command using a wrapper.
# This way the plantuml derivation can remain unchanged.
plantumlWithExtraPath =
let
plantumlIncludePath = lib.concatStringsSep ":" [ c4-lib ];
includeFlag = "-Dplantuml.include.path=${lib.escapeShellArg plantumlIncludePath}";
postFixedJre =
runCommand "jre-postfixed" { nativeBuildInputs = [ makeWrapper ]; } ''
mkdir -p $out/bin
makeWrapper ${jre}/bin/java $out/bin/java \
--add-flags ${lib.escapeShellArg includeFlag}
'';
in
plantuml.override { jre = postFixedJre; };
in
stdenv.mkDerivation rec {
pname = "plantuml-c4";
version = "unstable-2022-08-21";
nativeBuildInputs = [ makeWrapper ];
buildCommand = ''
mkdir -p $out/bin
makeWrapper ${plantumlWithExtraPath}/bin/plantuml $out/bin/plantuml \
--add-flags "-DRELATIVE_INCLUDE=\"${c4-lib}\""
$out/bin/plantuml -help
'';
passthru.tests.example-c4-diagram =
runCommand "c4-plantuml-sample.png" { nativeBuildInputs = [ plantuml-c4 ]; } ''
sed 's/https:.*\///' "${c4-lib}/samples/C4_Context Diagram Sample - enterprise.puml" > sample.puml
plantuml sample.puml -o $out
'';
meta = with lib; {
description = "PlantUML bundled with C4-Plantuml library";
homepage = "https://github.com/plantuml-stdlib/C4-PlantUML";
license = licenses.mit;
maintainers = with maintainers; [ tfc ];
platforms = platforms.unix;
};
}
+2
View File
@@ -10122,6 +10122,8 @@ with pkgs;
plantuml = callPackage ../tools/misc/plantuml { };
plantuml-c4 = callPackage ../tools/misc/plantuml/plantuml-c4.nix { };
plantuml-server = callPackage ../tools/misc/plantuml-server { };
plan9port = callPackage ../tools/system/plan9port {