Change:
outputs = [ "out" "lib" ]; <del> installPhase = let copyClibrariesToOut = basepath: '' # provide libraries needed for static compilation for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do ln -s $f ${basepath}/${platform}/$(basename $f) done ''; copyClibrariesToLib = '' # add those libraries to $lib output too, so we can use them with # `native-image -H:CLibraryPath=''${graalvm11-ce.lib}/lib ...` and reduce # closure size by not depending on GraalVM $out (that is much bigger) </del> <ins> installPhase = let copyClibrariesToOut = basepath: '' # provide libraries needed for static compilation ${ if useMusl then "for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do" else "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do" } ln -s $f ${basepath}/${platform}/$(basename $f) done ''; copyClibrariesToLib = '' # add those libraries to $lib output too, so we can use them with # `native-image -H:CLibraryPath=''${lib.getLib graalvm11-ce}/lib ...` and reduce # closure size by not depending on GraalVM $out (that is much bigger) mkdir -p $lib/lib for f in ${glibc}/lib/*; do ln -s $f $lib/lib/$(basename $f) done ''; in { "11-linux-amd64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} ''; "17-linux-amd64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} ''; "11-linux-aarch64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} ''; "17-linux-aarch64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} ''; "11-darwin-amd64" = ""; "17-darwin-amd64" = ""; }.${javaVersionPlatform} + '' # ensure that $lib/lib exists to avoid breaking builds </ins> mkdir -p $lib/lib <del> for f in ${glibc}/lib/*; do ln -s $f $lib/lib/$(basename $f) done ''; in { "11-linux-amd64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} ''; "17-linux-amd64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} ''; "11-linux-aarch64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} </del> <ins> # jni.h expects jni_md.h to be in the header search path. ln -s $out/include/linux/*_md.h $out/include/ # copy-paste openjdk's preFixup # Set JAVA_HOME automatically. mkdir -p $out/nix-support cat <<EOF > $out/nix-support/setup-hook if [ -z "''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF </ins> ''; <del> "17-linux-aarch64" = '' ${copyClibrariesToOut "$out/lib/svm/clibraries"} ${copyClibrariesToLib} ''; "11-darwin-amd64" = ""; "17-darwin-amd64" = ""; }.${javaVersionPlatform} + '' # ensure that $lib/lib exists to avoid breaking builds mkdir -p $lib/lib # jni.h expects jni_md.h to be in the header search path. ln -s $out/include/linux/*_md.h $out/include/ ''; </del> dontStrip = true; <del> preFixup = '' </del> <ins> # Workaround for libssl.so.10 wanted by TruffleRuby # Resulting TruffleRuby cannot use `openssl` library. autoPatchelfIgnoreMissingDeps = stdenv.isDarwin; preFixup = lib.optionalString (stdenv.isLinux) '' </ins> # We cannot use -exec since wrapProgram is a function but not a # command. #

Discussion:
Usage of flag without , and it is known in the Clojure community that its usage causes issues. This is because without the binaries are statically linked with , and I tried to create a GraalVM derivation compatible with . The result is here: However, this can't be upstreamed since it brokes all compilations with (including dynamically linked programs as used in nixpkgs). The major issue is that, to make compilation work, . This approach works fine for when we have only one lib C, however if we have two separate lib C we will have name conflicts and either we will have a compilation with glibc symbols on musl libraries or vice-versa. So, what are the options? One approach I can think is extend the wrapper from binary to conditionally include either or depending on the context (e.g.: if the flag is passed or not). We can do this using the flag, as below: For this to work we also need to remove the symbolic links to glibc library, otherwise this can conflict with musl libraries. This should also fix this . However, this looks like a very ugly solution, and I am open for better ones. Steps to reproduce the behavior: . Keep in mind after , it expects binary as . You can create a symbolic link and add it to your a file with contents: (segfaults) It should compile and run successfully. N/A Add any other context about the problem here. <!-- Please @ people who are in the list of the offending package or module. If in doubt, check for whoever last touched something. -- Please run and paste the result. Maintainer information: