Rust Binaries not Compatible with other Linux

I compiled my rust program (super simple one too as a test, just hello world). I ran it on my NixOS computer, but when I tried moving it to a server running a different distro of linux bash does not recognize it. Here is the output from file:
main: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2, for GNU/Linux 3.10.0, with debug_info, not stripped

and here is my shell.nix:

{ pkgs ? import <nixpkgs> {} }:
let
  gems = pkgs.bundlerEnv {
    name = "ultrahook-env";
    inherit (pkgs.ruby) bundler;
    gemdir = ./.; # path to Gemfile
  };
in pkgs.mkShell rec {
  buildInputs = with pkgs; [
    clang
    llvmPackages_17.bintools
    rustup
    openssl.dev
    binaryen
    dart-sass
    tailwindcss
    ruby.devEnv
    gems
    gems.wrappedRuby
  ];
  RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain;
  LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib];
  shellHook = ''
    export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
    export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
  '';
  RUSTFLAGS = builtins.map (a: ''-L ${a}/lib'') [
    # add libraries here (e.g. pkgs.libvmi)
  ];
  BINDGEN_EXTRA_CLANG_ARGS =
    (builtins.map (a: ''-I"${a}/include"'') [
      pkgs.glibc.dev
      # add dev libraries here (e.g. pkgs.libvmi.dev)
    ])
    ++ [
      ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
      ''-I"${pkgs.glib.dev}/include/glib-2.0"''
      ''-I${pkgs.glib.out}/lib/glib-2.0/include/''
    ];
}

It can’t work. Nix does not respect FHS.

Nix builds its binaries in complete isolation of outside world, and therefore they can’t recognize libraries installed by other distros.

A binary built by Nix will not seek its ld-linux.so in the /usr/lib/ of the distro, but in the /nix/store.

============================

Have you ever tried to do the same with, say, a binary built in Archlinux and trying to run it on Ubuntu? It will fail by the same reason. The binaries built in Archlinux expected their .so files installed with certain properties (kernel version, gcc version, libc version…), and it will likely be different from Ubuntu.

In Nix/NixOS it is more evident.

Thanks. Found a solution with patchelf though. How do I compile a Rust binary on NixOS that works on other Linux distros? - #2 by NobbZ