chromium,chromedriver: 129.0.6668.91 -> 129.0.6668.100
[NixPkgs.git] / pkgs / by-name / pl / plantuml-c4 / package.nix
bloba17aedefee26212d4cff1021db12ad616a9e9d90
2   lib,
3   stdenv,
4   fetchzip,
5   jre,
6   makeWrapper,
7   plantuml-c4,
8   plantuml,
9   runCommand,
12 # The C4-PlantUML docs say that it suffices to run plantuml with the
13 # -DRELATIVE_INCLUDE="..." arg to make plantuml find the C4 templates
14 # when included like "!include C4_Container.puml".
15 # Unfortunately, this is not sufficient in practise, when the path is not ".".
16 # What helps is setting -Dplantuml.include.path="..." *before* the jar
17 # parameter.
18 # The -DRELATIVE_INCLUDE param then *still* needs to be set (*after* the jar
19 # argument), because the C4 template vars check for existence of this variable
20 # and if it is not set, reference paths in the internet.
22 let
23   c4-lib = fetchzip {
24     url = "https://github.com/plantuml-stdlib/C4-PlantUML/archive/refs/tags/v2.10.0.zip";
25     hash = "sha256-p9Njb7VauXVf6yOBDQrO9mS+za9NntFUCK5tig0mH3U=";
26   };
28   sprites = fetchzip {
29     url = "https://github.com/tupadr3/plantuml-icon-font-sprites/archive/refs/tags/v3.0.0.zip";
30     hash = "sha256-I/cR1VPR7aKyTZF9X/4GkgcxV9+sLgNpTZugvCy0Dvs=";
31   };
33   # In order to pre-fix the plantuml.jar parameter with the argument
34   # -Dplantuml.include.path=..., we post-fix the java command using a wrapper.
35   # This way the plantuml derivation can remain unchanged.
36   plantumlWithExtraPath =
37     let
38       plantumlIncludePath = lib.concatStringsSep ":" [
39         c4-lib
40         sprites
41       ];
42       includeFlag = "-Dplantuml.include.path=${lib.escapeShellArg plantumlIncludePath}";
43       postFixedJre = runCommand "jre-postfixed" { nativeBuildInputs = [ makeWrapper ]; } ''
44         mkdir -p $out/bin
46         makeWrapper ${jre}/bin/java $out/bin/java \
47           --add-flags ${lib.escapeShellArg includeFlag}
48       '';
49     in
50     plantuml.override { jre = postFixedJre; };
53 stdenv.mkDerivation {
54   pname = "plantuml-c4";
55   version = "2.10.0";
57   nativeBuildInputs = [ makeWrapper ];
59   buildCommand = ''
60     mkdir -p $out/bin
62     makeWrapper ${plantumlWithExtraPath}/bin/plantuml $out/bin/plantuml \
63       --add-flags "-DRELATIVE_INCLUDE=\"${c4-lib}\""
65     $out/bin/plantuml -help
66   '';
68   passthru.tests.example-c4-diagram =
69     runCommand "c4-plantuml-sample.png" { nativeBuildInputs = [ plantuml-c4 ]; }
70       ''
71         sed 's/https:.*\///' "${c4-lib}/samples/C4_Context Diagram Sample - enterprise.puml" > sample.puml
72         plantuml sample.puml -o $out
74         sed 's/!include ..\//!include /' ${sprites}/examples/complex-example.puml > sprites.puml
75         plantuml sprites.puml -o $out
76       '';
78   meta = with lib; {
79     description = "PlantUML bundled with C4-Plantuml and plantuml sprites library";
80     mainProgram = "plantuml";
81     homepage = "https://github.com/plantuml-stdlib/C4-PlantUML";
82     license = licenses.mit;
83     maintainers = with maintainers; [
84       tfc
85       anthonyroussel
86     ];
87     platforms = platforms.unix;
88   };