Jvm panic when building a kotling multiplarform app

I am building a kotlin multiplarform app See it is a build a little bit complicated because there is a dependencies that required a recent curl build with an older glibc version.

So I did it in my nix flake and the result looks like this

{
  description = "Server equivalent of the popular Phoenix wallet";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ ];
        };

        # Importing glibc 2.19 for compiling the recent version of curl
        pkgs-glibc = import
          (builtins.fetchTarball {
            url = "https://github.com/NixOS/nixpkgs/archive/b6f505c60a2417d4fad4dc5245754e4e33eb4d40.tar.gz";
            sha256 = "sha256:0hhb8sar8qxi179d6c5h6n8f7nm71xxqqbynjv8pldvpsmsxxzh9";
          })
          { inherit system; };
      in
      {
        packages = {
          default = pkgs.gnumake;
        };
        formatter = pkgs.nixpkgs-fmt;

        devShell = pkgs.mkShellNoCC {
          buildInputs = with pkgs; [
            # build dependencies
            git
            pkg-config
            zlib
            wget

            sqlite
            jdk17
            gradle
            kotlin

            # Ok this should help you lean a few things
            # See https://github.com/ACINQ/phoenixd/issues/1#issuecomment-2018205685
            (pkgs.stdenv.mkDerivation {
              name = "curl-7.87.0";
              src = pkgs.fetchurl {
                url = "https://curl.se/download/curl-7.87.0.tar.bz2";
                sha256 = "sha256-XW4Sh2G3EQlG0Sdq/28PJm8rcm9eYZ9+CgV6R0FV8wc=";
              };
              buildInputs = [ pkgs.zlib pkgs.openssl.dev ];
              configureFlags = [ "--with-zlib=${pkgs.zlib}" "--with-openssl=${pkgs.openssl.dev}" ];
            })

            ncurses
          ] ++ [
            pkgs-glibc.glibc
          ];

          shellHook = ''
            # FIXME: this need to go in a build task
            gradle linuxX64DistZip
          '';
        };
      }
    );
}

However, when run the nix develop I get the following JVM panic

> Task :xcodeVersion SKIPPED
The message received from the daemon indicates that the daemon has disappeared.
Build request sent: Build{id=2bd6cf76-d00e-4281-9415-2fd21b57c566, currentDir=/home/vincent/github/work/phoenixd}
Attempting to read last messages from the daemon log...
Daemon pid: 4089712
  log file: /home/vincent/.gradle/daemon/8.7/daemon-4089712.out.log
----- Last  20 lines from daemon log file - daemon-4089712.out.log -----
2024-11-07T22:04:58.897+0100 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 46: received class org.gradle.launcher.daemon.protocol.Build
2024-11-07T22:04:58.897+0100 [DEBUG] [org.gradle.launcher.daemon.server.DefaultDaemonConnection] thread 46: Received non-IO message from client: Build{id=2bd6cf76-d00e-4281-9415-2fd21b57c566, currentDir=/home/vincent/github/work/phoenixd}
2024-11-07T22:04:58.897+0100 [INFO] [org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler] Received command: Build{id=2bd6cf76-d00e-4281-9415-2fd21b57c566, currentDir=/home/vincent/github/work/phoenixd}.
2024-11-07T22:04:58.898+0100 [DEBUG] [org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler] Starting executing command: Build{id=2bd6cf76-d00e-4281-9415-2fd21b57c566, currentDir=/home/vincent/github/work/phoenixd} with connection: socket connection from /127.0.0.1:43283 to /127.0.0.1:34024.
2024-11-07T22:04:58.900+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] Command execution: started DaemonCommandExecution[command = Build{id=2bd6cf76-d00e-4281-9415-2fd21b57c566, currentDir=/home/vincent/github/work/phoenixd}, connection = DefaultDaemonConnection: socket connection from /127.0.0.1:43283 to /127.0.0.1:34024] after 0.0 minutes of idle
2024-11-07T22:04:58.901+0100 [INFO] [org.gradle.launcher.daemon.server.DaemonRegistryUpdater] Marking the daemon as busy, address: [dcb927f4-c2f7-4ff0-a54d-82c4a77ca26f port:43283, addresses:[localhost/127.0.0.1]]
2024-11-07T22:04:58.901+0100 [DEBUG] [org.gradle.launcher.daemon.registry.PersistentDaemonRegistry] Marking busy by address: [dcb927f4-c2f7-4ff0-a54d-82c4a77ca26f port:43283, addresses:[localhost/127.0.0.1]]
2024-11-07T22:04:58.901+0100 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on daemon addresses registry.
2024-11-07T22:04:58.902+0100 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
2024-11-07T22:04:58.904+0100 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
2024-11-07T22:04:58.904+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] resetting idle timer
2024-11-07T22:04:58.904+0100 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] daemon is running. Sleeping until state changes.
2024-11-07T22:04:58.905+0100 [INFO] [org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy] Daemon is about to start building Build{id=2bd6cf76-d00e-4281-9415-2fd21b57c566, currentDir=/home/vincent/github/work/phoenixd}. Dispatching build started information...
2024-11-07T22:04:58.905+0100 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 48: dispatching org.gradle.launcher.daemon.protocol.BuildStarted@17a0b518
2024-11-07T22:04:58.906+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment] Configuring env variables: [PATH, GDMSESSION, depsBuildTarget, buildInputs, doCheck, NIX_PROFILES, MOTD_SHOWN, DBUS_SESSION_BUS_ADDRESS, ANDROID_HOME, XDG_CACHE_HOME, COLORTERM, depsHostHostPropagated, SESSION_MANAGER, nativeBuildInputs, PWD, shellHook, NIX_BUILD_TOP, WINDOWID, stdenv, PAGER, patches, dontAddDisableDepTrack, ZSH, IN_NIX_SHELL, GNOME_DESKTOP_SESSION_ID, GTK_MODULES, system, NIX_SSL_CERT_FILE, SHLVL, NIX_ENFORCE_NO_NATIVE, HOST_PATH, JAVA_HOME, cmakeFlags, TERM, XDG_CONFIG_DIRS, propagatedBuildInputs, XDG_SEAT_PATH, depsTargetTarget, XDG_SESSION_ID, GRADLE_HOME, out, PKG_CONFIG_PATH_FOR_TARGET, builder, ALACRITTY_SOCKET, NIX_PKG_CONFIG_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu, phases, XDG_SESSION_CLASS, ZSH_2000_DISABLE_RIGHT_PROMPT, XDG_GREETER_DATA_DIR, DESKTOP_SESSION, propagatedNativeBuildInputs, ALACRITTY_WINDOW_ID, outputs, XAUTHORITY, XDG_DATA_DIRS, strictDeps, XDG_CURRENT_DESKTOP, MAIL, XDG_STATE_HOME, DESKTOP_AUTOSTART_ID, GUIX_LOCPATH, LOGNAME, INFOPATH, depsTargetTargetPropagated, SHELL, doInstallCheck, GIO_LAUNCHED_DESKTOP_FILE, GOPATH, mesonFlags, TMPDIR, buildPhase, XDG_SESSION_PATH, TEMPDIR, shell, DEBUGINFOD_URLS, ZSH_2000_DEFAULT_USER, name, LESS, NIX_LDFLAGS, XDG_SESSION_DESKTOP, LS_COLORS, __structuredAttrs, depsBuildTargetPropagated, depsHostHost, configureFlags, LANG, GNOME_KEYRING_CONTROL, XDG_SESSION_TYPE, DISPLAY, PKG_CONFIG_FOR_TARGET, ALACRITTY_LOG, SOURCE_DATE_EPOCH, CONFIG_SHELL, XDG_DATA_HOME, LSCOLORS, GTK3_MODULES, NIX_CFLAGS_COMPILE, GPG_TTY, preferLocalBuild, depsBuildBuildPropagated, USER, CLASSPATH, XDG_CONFIG_HOME, GIO_LAUNCHED_DESKTOP_FILE_PID, XDG_SEAT, TEMP, NIX_STORE, TMP, NIX_GCROOT, XDG_RUNTIME_DIR, depsBuildBuild, XDG_VTNR, HOME, NIX_BUILD_CORES]
2024-11-07T22:04:58.912+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.LogToClient] About to start relaying all logs to the client via the connection.
2024-11-07T22:04:58.912+0100 [INFO] [org.gradle.launcher.daemon.server.exec.LogToClient] The client will now receive all logging from the daemon (pid: 4089712). The daemon log file: /home/vincent/.gradle/daemon/8.7/daemon-4089712.out.log
2024-11-07T22:04:58.914+0100 [INFO] [org.gradle.launcher.daemon.server.exec.LogAndCheckHealth] Starting build in new daemon [memory: 1.5 GiB]
2024-11-07T22:04:58.916+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has started executing the build.
2024-11-07T22:04:58.916+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] Executing build with daemon context: DefaultDaemonContext[uid=a2b9f5fd-ad2b-4137-9af5-48a5e5a42b44,javaHome=/nix/store/h8f0psz00bwjqqvbing2436h3g5rkk4d-openjdk-21.0.3+9/lib/openjdk,daemonRegistryDir=/home/vincent/.gradle/daemon,pid=4089712,idleTimeout=10800000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
----- End of the daemon log -----

JVM crash log found: file:///home/vincent/github/work/phoenixd/hs_err_pid4089712.log

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
> Run with --stacktrace option to get the stack trace.

I think there is something wrong with the build but I do not know what