When I put gcc and clang in my pkg list the gcc/clang “binaries” are actually shell scripts that inject a ton of stuff. I’m building a fully statically linked binary (even libc) where all dependencies are vendored inside my source tree, so I actually don’t want to use anything from the nix store, and I don’t want any extra options I didn’t specify injected into the build.
You can use gcc.cc or clang.cc to get the unwrapped compiler, however if you just want statically compiled programs, using pkgsStatic.callPackage is typically what you need and if you need access to the programs for static compilation they’re under pkgsStatic.buildPackages.
So I seem to be between a rock and a hard place, use the wrapper and get conflicts because the wrapper tries to include and link things from the store that I don’t want, or don’t use the wrapper and lose access to the headers that musl assumes the compiler provides
pkgsStatic.buildPackages.clang and pkgsStatic.buildPackages.gcc should include all the necessary stuff to do static compilation or if you’re using callPackage, swapping it with pkgsStatic.callPackage should make your program statically compiled.
I’m not sure what you mean. I only use nix packages to get access to a compiler, then I control the entire process myself (all vendored libraries, no nix store use). So there’s no callPackage anywhere, I just put llvmPackages_19.clang.cc in my flake’s package list so that an instance of clang is in my path so make can find it.
Oops sorry I glossed over that part of your response. That worked! I can see it pull in /nix/store/54jpfpf7v9b8rkv49vib83zfgdzw34ap-x86_64-unknown-linux-musl-clang-wrapper-19.1.7/resource-root/include/stdatomic.h.
Summary:
Use the pkgsStatic.buildPackages.llvmPackages_19.clang package
Use the x86_64-unknown-linux-musl-clang binary in PATH instead of clang