Possible to create a stdenv where cc comes from what's native on macOS?

I’m trying to compile OpenWrt on macOS, with build dependencies installed by nix. It’s pretty straightforward with Homebrew, where you install build dependencies and then just build it, but OpenWrt can only be built successfully with native cc like /usr/bin/clang, this makes it challenging to build with nix.

I’ve tried all the following methods, and all failed:

1. Use nix develop to create the build environment.

This doesn’t work because I use pkg.mkShell and it provides its own cc. I also tried pkg.mkShellNoCC, but it still comes with its own cc. I also tried adding this as a build dependency:

cc = pkgs.runCommand "cc-wrapper" { } ''
  mkdir -p $out/bin
  ln -s /usr/bin/cc $out/bin/cc
  ln -s /usr/bin/gcc $out/bin/gcc
  ln -s /usr/bin/llvm-gcc $out/bin/llvm-gcc
  ln -s /usr/bin/clang $out/bin/clang
  ln -s /usr/bin/clang++ $out/bin/clang++
  ln -s /usr/bin/ld $out/bin/ld

but the compiling would then fail with ld: library not found for -lSystem, I guess the stdenv probably changed how ld finds library, I couldn’t figure out how to restore it. It should be controlled by $LIBRARY_PATH, but in my nix develop shell, it was empty, which is what it’s supposed to be.

2. Install all build dependencies in configuration.nix

This almost worked, since stdenv was no longer in play, but because $PKG_CONFIG_PATH wouldn’t be set up, some dependencies wouldn’t be found.

I’d prefer using nix develop if possible. I wonder if it’s possible to set up an stdenv that uses the native CC on the macOS? I also tried a minimal stdenv like this, but it still comes with its own cc:

pkgs.mkShell.override {
  stdenv = pkgs.stdenvNoCC.override {
    cc = null;
    preHook = "";
    allowedRequisites = null;
    extraNativeBuildInputs = [];