Can't build grafbase (rust package)

Hello,

I’m trying to package the grafbase.com tools (a GraphQL federation gateway) to be able to try it.

I encounter a compilation error on the vendor dependency. I don’t know how to fix:

   --> /nix/var/nix/builds/nix-2155-4037846201/grafbase-gateway-0.53.3-vendor/source-registry-0/rsasl-2.2.0/src/context.rs:121:16
    |
120 | pub fn build_context<'a, 'b>(provider: &'a (dyn Provider<'b> + 'a)) -> &'a Context<'b> {
    |                      -- lifetime `'a` defined here
121 |     unsafe { &*(provider as *const dyn Provider as *const Context) }
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'a` must outlive `'static`
    |
note: raw pointer casts of trait objects cannot extend lifetimes
   --> /nix/var/nix/builds/nix-2155-4037846201/grafbase-gateway-0.53.3-vendor/source-registry-0/rsasl-2.2.0/src/context.rs:121:16
    |
121 |     unsafe { &*(provider as *const dyn Provider as *const Context) }
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this was previously accepted by the compiler but was changed recently
    = help: see <https://github.com/rust-lang/rust/issues/141402> for more information

error: could not compile `rsasl` (lib) due to 1 previous error

Here is the nix expression I use (I follow the nixpkgs-unstable branch) :

{
  fetchFromGitHub,
  rustPlatform,
}:

rustPlatform.buildRustPackage rec {
  pname = "grafbase-gateway";
  version = "0.53.3";

  src = fetchFromGitHub {
    owner = "grafbase";
    repo = "grafbase";
    rev = "gateway-${version}";
    sha256 = "sha256-ajqkyE7VM2utRARTw2P6jjqRG1sTMvCN8Mv40iWGMyY=";
  };

  preBuild = ''
    pwd
    ls -la
    cargo --version
    rustc --version
  '';

  cargoArgs = [
    "--package"
    "gateway"
  ];

  cargoHash = "sha256-ZIR1N7Rg51aijLQDW3BX6d2NtowqssysJJAAFRwKQv4=";
}

If someone has a hint, I’d be happy

The project seems to use an older version of rsasl that does not compile with a current rust compiler. It seems fixed in a newer version of that dependency: Release v2.2.1 · dequbed/rsasl · GitHub

Ok thanks so I should patch the Cargo.toml/Cargo.lock ?

Never done that for a nix rust package

The easiest way would be to update the dependency in the source and just use that when building. However it is possible to supply a patch file and patch cargo.lock - nixpkgs/doc/languages-frameworks/rust.section.md at 0ab68845cffe1767035633bc94fa45703aacc27e · NixOS/nixpkgs · GitHub