Skip to content

Impossible to override arguments of rustPlatform.fetchCargoVendor #415397

@axelkar

Description

@axelkar

It's practically impossible to override the src and hash arguments of rustPlatform.fetchCargoVendor. You can copy code from Nixpkgs and try to reuse vendorStaging, but there's a clear issue here.

The switch from fetchCargoTarball to fetchCargoVendor broke the previous way of using overrideAttrsand setting src and outputHash.

I'm unsure how to amend this myself as the FOD in fetchCargoVendor is wrapped. Maybe something like lib.extendMkDerivation could be used here?


The issue with buildRustPackage not yet fully utilizing finalAttrs is adjacent but not directly in the scope of this issue, but I'll document it here regardless:

let
  pkgs = import <nixpkgs> {};
  myPkg = pkgs.rustPlatform.buildRustPackage {
    name = "example";
    src = pkgs.hello;
    cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
  };
in
(myPkg.overrideAttrs { cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABB="; }).cargoDeps
== myPkg.cargoDeps

# These should be inequal but they aren't

Related:

@9999years @amesgen @ShamrockLee

#194475 (comment) #107070 #382550

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken0.kind: regressionSomething that worked before working no longer2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: rustGeneral-purpose programming language emphasizing performance, type safety, and concurrency.
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions