Don't link to /nix/* libs, use original lib paths instead

I am using nix on CI to build desktop app for macOS.
I’m facing an issue that the resulting app is running correctly on any macOS machine with nix installed but fails on machines without nix.
The problem is that otool -l shows that the resulting app is linked to:

        /nix/store/nrsa1l0kh3vxindfkfa1d5fw62yvac4d-libc++-7.1.0/lib/libc++.1.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /nix/store/h144jawqa92rqjhaahrsikq5j2dwkh5n-Libsystem-osx-10.12.6/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
        /nix/store/h144jawqa92rqjhaahrsikq5j2dwkh5n-Libsystem-osx-10.12.6/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)

I am building the app using cargo tauri-bundler subcommand. Is there any option to tell linker not to link/patch binaries to libraries located in nix store and link to native macOS path instead?

Not the prettiest approach, but I opted for fixing the binaries after the Nix build: https://github.com/leanprover/lean4/blob/53510ff392ded17094194f040f2b08311d4de3cb/.github/workflows/ci.yml#L91-L96

(edit: In this case it’s not even a Nix build, just a nix-shell)

1 Like

I’ve managed to resolve the problem by setting RUSTFLAGS='-L /usr/lib'.