Open Ten0 opened 5 months ago
I think rust version that gets passed to "${crate2nix}/tools.nix"
is different from rust version you get when you nix run
, try checking that.
That seems to not be the source of the issue.
When I nix run
it uses cargo 1.76.0 as pinned in your nixpkgs
, since nix derivation show github:nix-community/crate2nix
shows /nix/store/8s7fd4c5r06d4x94vqbmgwsv05v2jmlb-cargo-1.76.0.drv
, UNLESS there is also another cargo version in path, in which case it uses that one.
Either way (1.76.0 or my 1.77.0) I don't get any error when running crate2nix generate
, and build then runs - although the generated files look different in that they don't use the same ID format.
I was doing (pkgs.callPackage "${crate2nix}/tools.nix" { }).generatedCargoNix
, which had me override the pkgs
, but I happened to also have 1.76 there (/nix/store/7ld12b9gmdziwrvjyb1lhf5y49b7l0nw-cargo-1.76.0.drv
).
I also tried using crate2nix.tools.${system}.generatedCargoNix
, which prevents me from overriding and instead uses the version that you're exporting, but that does result in the same error, despite it picking the exact same derivation as non-ifd: /nix/store/8s7fd4c5r06d4x94vqbmgwsv05v2jmlb-cargo-1.76.0.drv
.
So it would look like that's not the source of the issue.
I also made sure to be generating the Cargo.lock
on 1.76 if that matters.
{
buildRustCrateForPkgs = pkgs: pkgs.buildRustCrate.override (
let rustToolchain = pkgs.rust-bin.stable.latest; in {
# Use the latest stable rust version from oxalica overlay instead of the one in nixpkgs to build workspace packages
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/rust/build-rust-crate/default.nix#L12-L13
rustc = rustToolchain.default;
cargo = rustToolchain.cargo;
# We need to override some dependencies/env variables... for some crates - that is specified in crate_overrides.nix
defaultCrateOverrides = pkgs.callPackage ./crate_overrides.nix { inherit flake-inputs packages cargoNix; };
}
);
};
That's currently pinned at 1.77.0 in the flake.
If it matters that this is the same version that we generate the Cargo.nix
for (that Cargo.lock is generated with...), then I wonder how I could override tools.nix
to have it use that version from my pkgs.rust-bin
- there doesn't seem to be a corresponding argument.
With the following nix derivation:
Building leads to the following error (truncated with hopefully only relevant information):
Contents of
/nix/store/zg0br63gy3b9r67kkfzsjqzxwz79vqwk-deps
:If I do generate Cargo.nix manually via
nix run github:nix-community/crate2nix -- generate -f .cargo/workspace/Cargo.toml
and import that instead, it works.Thanks for your help.