Compiling Godot in a nix shell?

So it looks like I just needed to run autoPatchelf on the compiled binary with the correct runtimeDependencies (I assume because Godot uses dlopen)=. Using this flake.nix:

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
      in
      {
        devShells.default = pkgs.mkShell {
          nativeBuildInputs = with pkgs; [ pkg-config autoPatchelfHook ];
          runtimeDependencies = with pkgs; [
            libGL
            vulkan-loader
            xorg.libX11
            xorg.libXcursor
            xorg.libXext
            xorg.libXi
            xorg.libXrandr
          ];
          buildInputs = with pkgs; [ scons ];
        };
      });
}

I can run nix develop --command scons platform=linuxbsd dev_mode=yes dev_build=yes to build Godot and then nix develop --command bash -c '. $stdenv/setup; autoPatchelf bin' to patch it.

It’s worth noting that the above list of runtime dependencies is the minimal list to get Godot to start - it won’t have audio and will still complain about a bunch of other dependencies (which need adding to runtimeDependencies).