nix: Fix LDFLAGS rpath (#26912)

Julia Ryan created

By default stdenv strips all unused rpaths, but we use a few libraries
that are `dlopen`'d so we need to stop it from removing those. The
[`dontPatchELF`
flag](https://ryantm.github.io/nixpkgs/stdenv/stdenv/#var-stdenv-dontPatchELF)
disables that and makes the nix build work on wayland again.

Fix #26905
Close #26864

Release Notes:

- N/A

Change summary

nix/build.nix | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Detailed changes

nix/build.nix 🔗

@@ -145,7 +145,7 @@ let
         ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled.";
         RELEASE_VERSION = version;
         RUSTFLAGS = if withGLES then "--cfg gles" else "";
-        # TODO: why are these not handled by the linker given that they're in buildInputs?
+        # these libraries are used with dlopen so putting them in buildInputs isn't enough
         NIX_LDFLAGS = "-rpath ${
           lib.makeLibraryPath [
             gpu-lib
@@ -155,6 +155,9 @@ let
         LK_CUSTOM_WEBRTC = livekit-libwebrtc;
       };
 
+      # prevent nix from removing the "unused" wayland/gpu-lib rpaths
+      dontPatchELF = true;
+
       cargoVendorDir = craneLib.vendorCargoDeps {
         inherit src cargoLock;
         overrideVendorGitCheckout =