Skip to content

fix: build crane-utils using a different toolchain #422

@realeinherjar

Description

@realeinherjar

We are trying to move our CI to Nix using crane as the main tool, see bitcoindevkit/bdk#1165
We have a MSRV of 1.57.0 and we need to test it on CI.
I am trying to build it using crane.cargoBuild:

let
  ...
  rustMSRVTarget = pkgs.rust-bin.stable."1.57.0".default;
  craneMSRVLib = (crane.mkLib pkgs).overrideToolchain rustMSRVTarget;
  MSRVArgs = {
    cargoLock = ./CargoMSRV.lock;
  };
  cargoArtifactsMSRV = craneMSRVLib.buildDepsOnly (MSRVArgs);
  ...
in
  ...
  packages = {
    MSRV = craneMSRVLib.cargoBuild (MSRVArgs // {
      cargoArtifacts = cargoArtifactsMSRV;
    });
  };

However I have errors:

> nix build -L .#MSRV
warning: Git tree '/Users/einherjar/git/btc/bdk' is dirty
crane-utils-deps> cargoArtifacts not set, will not reuse any cargo artifacts
crane-utils-deps> unpacking sources
crane-utils-deps> unpacking source archive /nix/store/sr1g0p7p580sz6w4f02g67c7amzkbxvn-source
crane-utils-deps> source root is source
crane-utils-deps> patching sources
crane-utils-deps> Executing configureCargoCommonVars
crane-utils-deps> updateAutotoolsGnuConfigScriptsPhase
crane-utils-deps> configuring
crane-utils-deps> will append /private/tmp/nix-build-crane-utils-deps-0.1.0.drv-0/source/.cargo-home/config.toml with contents of /nix/store/snibvbwhnwg7iqgvqlc46wx6fl6kpka2-vendor-cargo-deps/config.toml
crane-utils-deps> default configurePhase, nothing to do
crane-utils-deps> building
crane-utils-deps> ++ command cargo --version
crane-utils-deps> cargo 1.57.0 (b2e52d7ca 2021-10-21)
crane-utils-deps> ++ command cargo check --release --locked --all-targets
crane-utils-deps> error: failed to get `anyhow` as a dependency of package `crane-utils v0.1.0 (/private/tmp/nix-build-crane-utils-deps-0.1.0.drv-0/source)`
crane-utils-deps> Caused by:
crane-utils-deps>   failed to load source for dependency `anyhow`
crane-utils-deps> Caused by:
crane-utils-deps>   Unable to update registry `crates-io`
crane-utils-deps> Caused by:
crane-utils-deps>   failed to update replaced source registry `crates-io`
crane-utils-deps> Caused by:
crane-utils-deps>   failed to parse manifest at `/nix/store/snibvbwhnwg7iqgvqlc46wx6fl6kpka2-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/toml_edit-0.20.2/Cargo.toml`
crane-utils-deps> Caused by:
crane-utils-deps>   namespaced features with the `dep:` prefix are only allowed on the nightly channel and requires the `-Z namespaced-features` flag on the command-line
error: builder for '/nix/store/f3bfaxij1ja6rljsicisykl2mklqvqx2-crane-utils-deps-0.1.0.drv' failed with exit code 101;
       last 10 log lines:
       >   Unable to update registry `crates-io`
       >
       > Caused by:
       >   failed to update replaced source registry `crates-io`
       >
       > Caused by:
       >   failed to parse manifest at `/nix/store/snibvbwhnwg7iqgvqlc46wx6fl6kpka2-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/toml_edit-0.20.2/Cargo.toml`
       >
       > Caused by:
       >   namespaced features with the `dep:` prefix are only allowed on the nightly channel and requires the `-Z namespaced-features` flag on the command-line
       For full logs, run 'nix log /nix/store/f3bfaxij1ja6rljsicisykl2mklqvqx2-crane-utils-deps-0.1.0.drv'.
error: 1 dependencies of derivation '/nix/store/p3dwbi4fx6h6w3x80hhjk45b5izsjdd8-crane-utils-0.1.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xdp693ycn3m0ygqljy7sk88m34jn8yj9-cargo-git.drv' failed to build
error: 1 dependencies of derivation '/nix/store/vhimyf39bq4a1ck90ah0lzs6ir5p8gch-linkLockedDeps.drv' failed to build
error: 1 dependencies of derivation '/nix/store/db13frhkv8rf9zcnwqpsza87512rnwzr-vendor-cargo-deps.drv' failed to build
error: 1 dependencies of derivation '/nix/store/hnhasq7zfagd1xs3nz6iai51985ilckd-crates-build-0.1.0.drv' failed to build

Rust 1.57.0 cannot build crane-utils.

How do I override this, by making crane-utils be compiled by Rust latest?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions