Ld: framework not found System

After prematurely posting my last question I’m now facing an issue I really can’t solve. I’m trying to package the Solana CLI and you can find my current efforts here GitHub - cideM/solana-nix: The Solana CLI tools packaged up with Nix

I’m on a MacBook.

If I run nix build I get

   Compiling serde_derive v1.0.130
   Compiling serde v1.0.130
   Compiling memchr v2.4.0
   Compiling spin v0.5.2
error: linking with `/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc` fai
  |
  = note: "/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc" "-arch" "arm6
  = note: ld: framework not found System
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)


error: linking with `/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc` fai
  |
  = note: "/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc" "-arch" "arm6
  = note: ld: framework not found System
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)


error: linking with `/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc` fai
  |
  = note: "/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc" "-arch" "arm6
  = note: ld: framework not found System
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)


error: aborting due to previous error

error: aborting due to previous error

error: aborting due to previous error

error: could not compile `proc-macro2`

I’ve already read most issues and PRs on that topic and so far I have this in the flake:

            nativeBuildInputs = [
              pkgs.hidapi
              pkgs.llvmPackages.clang
              pkgs.llvm
              pkgs.rustfmt
              pkgs.darwin.apple_sdk.frameworks.System
              pkgs.llvmPackages.libclang
              pkgs.pkg-config
            ];

            buildInputs = [
              pkgs.hidapi
              pkgs.llvm
              pkgs.llvmPackages.libclang
              pkgs.rustfmt
              pkgs.darwin.apple_sdk.frameworks.System
              pkgs.openssl
              # pkgs.udev
              pkgs.zlib
            ];

            preBuild = ''
              export LLVM_CONFIG_PATH="${pkgs.llvm}/bin/llvm-config";
              export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
            '';

            preConfigure = ''
              export NIX_LDFLAGS="-F${pkgs.darwin.apple_sdk.frameworks.System}/Library/Frameworks -framework System $NIX_LDFLAGS";
            '';

so as you can see I already have the frameworks.System and I’m passing it via NIX_LDFLAGS but it doesn’t change the error in any way.

The solution to this issue is to make sure that whatever application you are linking/compiling is not linking to System.

The System framework should never be used according to Apple: OS X Frameworks

So the best thing to do is to patch the software.