[SOLVED] Diagon Interactive ASCII art diagram generators build

Hello,

I’m in the process of providing a build for GitHub - ArthurSonzogni/Diagon: Interactive ASCII art diagram generators. 🌟

What I currently have is a default.nix

# default.nix
{ pkgs ? import <nixpkgs> {}, ... }:
pkgs.stdenv.mkDerivation {
  name = "Diagon";
  src = builtins.fetchTarball https://github.com/ArthurSonzogni/Diagon/tarball/master;
  nativeBuildInputs = with pkgs; [ cmake pkgconfig git cacert (jre_minimal.override { jdk = jdk11_headless; }) ant ];
  buildInputs = with pkgs; [ boost libuuid icu ];
  propagatedBuildInputs = with pkgs; [ antlr ];

  meta = with pkgs.lib; {
      description = "Interactive ASCII art diagram generators. 🌟";
      longDescription = ''
          Diagon is an interactive interpreter. It transforms markdown-style expression into an ascii-art
          representation.        
      '';
      homepage = "https://github.com/ArthurSonzogni/Diagon";
    };
}

where I can

nix-shell --pure
eval cmake $cmakeFlags $src
make -j

The build (make) currently breaks:

[ 92%] Generating FlowchartLexer.cpp, FlowchartParser.cpp, FlowchartLexer.h, FlowchartParser.h
Error: Unable to access jarfile /nix/store/7g8306l1a9qxw7xswcdlbrm61v16wzi5-source/tools/antlr.jarGraphPlanarParser.h
Error: Unable to access jarfile /nix/store/7g8306l1a9qxw7xswcdlbrm61v16wzi5-source/tools/antlr.jarError: Unable to access jarfile /nix/store/7g8306l1a9qxw7xswcdlbrm61v16wzi5-source/tools/antlr.jarError: Unable to access jarfile /nix/store/7g8306l1a9qxw7xswcdlbrm61v16wzi5-source/tools/antlr.jar

EDIT:
Removed unnecessary zeromq and static-boost.
Added antlr as a buildInput. Still to no avail.

There is a warning related to antlr as well when I run the cmake command:

eval cmake $cmakeFlags -Wno-dev $src | grep -i warning

fatal: not a git repository (or any of the parent directories): .git
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 162 100 162 0 0 2484 0 --:–:-- --:–:-- --:–:-- 2492
Warning: Failed to create the file antlr.jar: Permission denied
0 2040k 0 1005 0 0 5143 0 0:06:46 --:–:-- 0:06:46 5143
curl: (23) Failure writing output to destination

It is very roughly this, I can build using nix-build now:

# file default.nix
{ pkgs ? import <nixpkgs> {}, ... }:
pkgs.stdenv.mkDerivation {
  name = "env";
  src = pkgs.lib.cleanSource (builtins.fetchTarball https://github.com/ArthurSonzogni/Diagon/tarball/master);
  nativeBuildInputs = with pkgs; [ cmake pkgconfig git cacert (jre_minimal.override { jdk = jdk11_headless; }) ant extra-cmake-modules ];
  buildInputs = with pkgs; [ boost libuuid.dev icu ];

  # the https://github.com/ArthurSonzogni/Diagon/blob/23d95bb09f9ab0095946cc3f9c55fb8a17648e84/tools/download_and_patch.sh should not be needed
  # bc we have antlr already in the inputs
  # Also https://github.com/ArthurSonzogni/Diagon/blob/34b68f63e45f6912e18682e797b31b43c5ac05c8/tools/CMakeLists.txt#L6
  # ..
  # https://github.com/ArthurSonzogni/Diagon/blob/34b68f63e45f6912e18682e797b31b43c5ac05c8/tools/CMakeLists.txt#L9
  # can be patched off
  # Also https://github.com/ArthurSonzogni/Diagon/blob/34b68f63e45f6912e18682e797b31b43c5ac05c8/tools/CMakeLists.txt#L36
  # can be patched replacing by
  # -jar ${pkgs.antlr.jarLocation}
  prePatch = "ls -lart tools";
  patches = [
    ./patch_cmakelists
  ];

  postPatch = ''
    substituteInPlace tools/CMakeLists.txt \
        --replace '-jar ''${DIAGON_TOOLS_DIR}/antlr.jar' '-jar ${pkgs.antlr.jarLocation}'
  '';

  propagatedBuildInputs = with pkgs; [ antlr ];
}

file ./patch_cmakelists being:

--- a/tools/CMakeLists.txt      2022-05-05 12:24:44.073703300 +0200
+++ b/tools/CMakeLists2.txt     2022-05-05 12:28:45.463703300 +0200
@@ -3,10 +3,6 @@
 # ┌─────────────────────────────────────────────────┐
 # │ ANTLR                                           │
 # └─────────────────────────────────────────────────┘
-execute_process(
-  COMMAND bash download_and_patch.sh
-  WORKING_DIRECTORY ${DIAGON_TOOLS_DIR}
-)

 # Function
 #   ANTLR(<file.g4>)