You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Impossible to override arguments of rustPlatform.fetchCargoVendor #415397
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.
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:
letpkgs=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
changed the title [-]Impossible to override rustPlatform.fetchCargoVendor[/-][+]Impossible to override arguments of rustPlatform.fetchCargoVendor[/+]on Jun 9, 2025
Aside from making cargoHash and other vendor-related arguments overridable, we could also override cargoDeps.
Yes. That's what this issue focuses on, and that would make it at least possible to update the Cargo vendor hash.
Overridability list
Here's how I picture everything currently: (below layers can't affect above layers)
Arguments to original package definition updated by override if defined using pkgs.callPackage
Arguments to rustPlatform.buildRustPackage set in the original package definition.
Arguments to stdenv.mkDerivation by rustPlatform.buildRustPackage. Includes the creation of cargoDeps from cargoHash etc.
Arguments to stdenv.mkDerivation updated by overrideAttrs
Arguments to builtins.derivation set by stdenv.mkDerivation logic
Arguments to builtins.derivation updated by overrideDerivation
builtins.derivation
Integrating 2 and 4 can be done in the package definition easily by using finalAttrs, and the integration of layers 3 and 4 is what buildRustPackage needs to implement itself.
Perhaps a visualization like the above could be paraphrased into the Nixpkgs manual? Oh and this all reminds me about infuse.nix :)
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.
Activity
axelkar commentedon Jun 9, 2025
@TomaSajt mentionted for creating
rustPlatform.fetchCargoVendorShamrockLee commentedon Jun 9, 2025
Aside from making
cargoHashand other vendor-related arguments overridable, we could also overridecargoDeps.[-]Impossible to override rustPlatform.fetchCargoVendor[/-][+]Impossible to override arguments of rustPlatform.fetchCargoVendor[/+]axelkar commentedon Jun 9, 2025
Yes. That's what this issue focuses on, and that would make it at least possible to update the Cargo vendor hash.
Overridability list
Here's how I picture everything currently: (below layers can't affect above layers)
overrideif defined usingpkgs.callPackagerustPlatform.buildRustPackageset in the original package definition.stdenv.mkDerivationbyrustPlatform.buildRustPackage. Includes the creation ofcargoDepsfromcargoHashetc.stdenv.mkDerivationupdated byoverrideAttrsbuiltins.derivationset bystdenv.mkDerivationlogicbuiltins.derivationupdated byoverrideDerivationbuiltins.derivationIntegrating 2 and 4 can be done in the package definition easily by using
finalAttrs, and the integration of layers 3 and 4 is whatbuildRustPackageneeds to implement itself.Perhaps a visualization like the above could be paraphrased into the Nixpkgs manual? Oh and this all reminds me about infuse.nix :)