Wrong interpreter linked using 'zig cc' compiler

I’m trying to compile a binary on linux with ‘zig c++’ but the wrong interpreter gets linked so i have to use patchelf every time (after the switch of interpreters everything works). I’m inside a devshell from a flake (nixpkgs unstable) inside nixos (nixpkgs 22.11) I use the following command to compile:

zig cc -Dtarget=native main.c -o main -I$lm/include -L$lm/build/lib -lzmq -lc++ -lsodium -lc++abi -static -nodefaultlibs -lc

the ‘$lm’ env variable points to another c++ project compiled elsewhere and zmq gets linked statically.
when i try to execute the resulting binary i get:

./main: /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /nix/store/0z5kcds7b6qmm373s3b5w9ykvqbgw87i-glibc-2.37-8/lib/libpthread.so.0)

inspecting the libs needed by the executable i get:

ldd ./main                                                                                                                                                                                  15:20:26
        linux-vdso.so.1 (0x00007ffee68a5000)
        libsodium.so.23 => /nix/store/xrpk6klrlmvz36l5zqzwxy3vwvsslral-libsodium-1.0.18/lib/libsodium.so.23 (0x00007f4bf470f000)
        libc.so.6 => /nix/store/0z5kcds7b6qmm373s3b5w9ykvqbgw87i-glibc-2.37-8/lib/libc.so.6 (0x00007f4bf4529000)
        libpthread.so.0 => /nix/store/0z5kcds7b6qmm373s3b5w9ykvqbgw87i-glibc-2.37-8/lib/libpthread.so.0 (0x00007f4bf4524000)
        /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/ld-linux-x86-64.so.2 => /nix/store/0z5kcds7b6qmm373s3b5w9ykvqbgw87i-glibc-2.37-8/lib64/ld-linux-x86-64.so.2 (0x00007f4bf476c000)

the last line does not make sense, if I compile with the verbose flag i get this flag added to the link command:

-dynamic-linker /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/ld-linux-x86-64.so.2

when i compile with clang (installed from nixpkgs.llvmPackages_16) everything compiles fine. what is the clang wrapper doing ? what should i do so the zig compiler knows which interpreter to use? also where i can find resources (apart from the stdenv(s) nix sources) to create something like “stdenvZig”?