Code Monkey home page Code Monkey logo

crane's People

Contributors

9999years avatar adisbladis avatar aidalgol avatar cobaltcause avatar danjl1100 avatar dependabot[bot] avatar detegr avatar dpc avatar erratic-pattern avatar felschr avatar figsoda avatar firestack avatar grahamc avatar i1i1 avatar ipetkov avatar isibboi avatar j-baker avatar jemaw avatar jfly avatar ldicarlo avatar lovesegfault avatar luflosi avatar marijanp avatar mic92 avatar mitchty avatar pegasust avatar pingiun avatar rvolosatovs avatar scvalex avatar szlend avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

crane's Issues

Build error got ignored?

I'm still investigating, but I have noticed that a build error got ignored https://github.com/fedimint/fedimint/actions/runs/3148750617/jobs/5119612041

Code in question: https://github.com/fedimint/fedimint/blob/9fb4a608d7f3a5cd1d9775a3178fb0098c10d449/flake.nix#L280

 workspace-doc>  Documenting fedimint-sled v0.1.0 (/build/source/fedimint-sled)
workspace-doc>  Documenting fedimint-mint v0.1.0 (/build/source/modules/fedimint-mint)
workspace-doc>  Documenting fedimint-rocksdb v0.1.0 (/build/source/fedimint-rocksdb)
workspace-doc>     Checking fedimint-core v0.1.0 (/build/source/fedimint-core)
workspace-doc>  Documenting fedimint-core v0.1.0 (/build/source/fedimint-core)
workspace-doc> error: unresolved link to `Error::InvalidPublicKey`
workspace-doc>    --> modules/fedimint-ln/src/contracts/mod.rs:125:19
workspace-doc>     |
workspace-doc> 125 |     /// Returns [`Error::InvalidPublicKey`] if the Preimage does not represent a valid Secp256k1 point x coordinate.
workspace-doc>     |                   ^^^^^^^^^^^^^^^^^^^^^^^ the struct `Error` has no field or associated item named `InvalidPublicKey`
workspace-doc>     |
workspace-doc>     = note: requested on the command line with `-D rustdoc::broken-intra-doc-links`
workspace-doc> error: could not document `fedimint-ln`
workspace-doc> Caused by:
workspace-doc>   process didn't exit successfully: `rustdoc --edition=2021 --crate-type lib --crate-name fedimint_ln modules/fedimint-ln/src/lib.rs -o /build/source/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --document-private-items -C metadata=ac4db1cadd051a00 -L dependency=/build/source/target/debug/deps --extern async_trait=/build/source/target/debug/deps/libasync_trait-700f6c924ae669c6.so --extern bincode=/build/source/target/debug/deps/libbincode-724b514a4a963e87.rmeta --extern bitcoin_hashes=/build/source/target/debug/deps/libbitcoin_hashes-4d587aa5676c4821.rmeta --extern fedimint_api=/build/source/target/debug/deps/libfedimint_api-8582f0d8ccc7aabe.rmeta --extern futures=/build/source/target/debug/deps/libfutures-bae9b3e36cc92cb5.rmeta --extern itertools=/build/source/target/debug/deps/libitertools-cfabf4943f34eb4e.rmeta --extern lightning=/build/source/target/debug/deps/liblightning-542ab2b20a2e5f3b.rmeta --extern lightning_invoice=/build/source/target/debug/deps/liblightning_invoice-5febe7f6df92cb02.rmeta --extern secp256k1=/build/source/target/debug/deps/libsecp256k1-8d5efe93088ab0a5.rmeta --extern serde=/build/source/target/debug/deps/libserde-4973fd9fdd672beb.rmeta --extern serde_json=/build/source/target/debug/deps/libserde_json-bd614a6eb8ad83e6.rmeta --extern thiserror=/build/source/target/debug/deps/libthiserror-aeec39fa68b5ee3c.rmeta --extern threshold_crypto=/build/source/target/debug/deps/libthreshold_crypto-532ffdea4615044e.rmeta --extern tracing=/build/source/target/debug/deps/libtracing-b3e97c9560ce2996.rmeta --extern url=/build/source/target/debug/deps/liburl-fd7fea2e60d87da0.rmeta -D 'rustdoc::broken_intra_doc_links' --crate-version 0.1.0` (exit status: 1)
workspace-doc> warning: build failed, waiting for other jobs to finish...
workspace-doc> installing
workspace-doc> copying target to /nix/store/shaq1szx3i9xc0nf549m0dljhi4r811h-workspace-doc-0.0.1/target.tar.zst
workspace-doc> /*stdin*\            : 22.07%   (  4.23 GiB =>    956 MiB, /nix/store/shaq1szx3i9xc0nf549m0dljhi4r811h-workspace-doc-0.0.1/target.tar.zst)
workspace-doc> post-installation fixup
workspace-doc> shrinking RPATHs of ELF executables and libraries in /nix/store/shaq1szx3i9xc0nf549m0dljhi4r811h-workspace-doc-0.0.1
workspace-doc> strip is /nix/store/ag2bpk0lzjvj409znklrz5krkpc5imzs-gcc-wrapper-11.3.0/bin/strip
workspace-doc> patching script interpreter paths in /nix/store/shaq1szx3i9xc0nf549m0dljhi4r811h-workspace-doc-0.0.1
workspace-doc> checking for references to /build/ in /nix/store/shaq1szx3i9xc0nf549m0dljhi4r811h-workspace-doc-0.0.1...

I'm confused, because it says that build failed, but then moves on ...

Adding `cmake` as an input causes the stdenv to try to build the entire expression with cmake instead of cargo

Having cmake in Nix dependencies breaks the build with the following error message:-

CMake Error: The source directory "/build/dummy-src" does not appear to contain CMakeLists.txt.

I tried depsBuildBuild, nativeBuildInputs, buildInputs and even depsTargetTarget. Putting cmake in any of those for a project that doesn't contain CMakeLists.txt causes it to abort with that message. I'm not sure if this is the expected behavior or not but it's surprising.

I was able to get around this by using the environment variable CMAKE = "${pkgs.cmake}/bin/cmake". However, doing this seems to override gcc from stdenv and uses the latest gcc instead. I suspect that's why overrideScope' didn't work for me in this discussion #99. I even ran into this as well when I tried the PR for ergonomic stdenv here #99 (reply in thread). I had to initialize a new project with no Nix dependencies to verify that the new PR was in fact working.

Edit: I'm not so sure about this anymore. Commenting out the environment variable still brings in the newer gcc. This is strange because it was working fine with naersk before switching to crane.

Unknown libc native/impure

Setting crossSystem to x86_64-windows and running nix flake check fails with error: Unknown libc native/impure.

--- a/flake.nix
+++ b/flake.nix
@@ -16,7 +16,8 @@
     flake-utils.lib.eachDefaultSystem (system:
       let
         pkgs = import nixpkgs {
-          inherit system;
+          localSystem = system;
+          crossSystem = "x86_64-windows";
         };
 
         craneLib = crane.lib.${system};

Edit: It's very likely that this issue is not directly introduced by Crane.

Pass custom arguments to mkDerivation?

Is there a way to do this? I've tried with the following flake.nix:

{
  description = "Your crate description here";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";

    crane = {
      url = "github:ipetkov/crane";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    flake-utils.url = "github:numtide/flake-utils";

    advisory-db = {
      url = "github:rustsec/advisory-db";
      flake = false;
    };

    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
  };

  outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };

        inherit (pkgs) lib;

        craneLib = crane.lib.${system};
        src = ./.;
        desktop_item = pkgs.makeDesktopItem {
          name = "my_pkg";
          desktopName = "my_pkg";
          exec = "my_pkg %u";
          mimeTypes = [ ];
        };
        cargoArtifacts = craneLib.buildDepsOnly {
          inherit src;
        };

        package = craneLib.buildPackage {
          inherit cargoArtifacts src;
          preBuild = ''echo jhsdgfskhdjf sdkjf hjxhjvdxg yfhyhjdgfsdffgdskdgkjsdgjsdghsdf'';
          desktopItems = [ desktop_item ];
          nativeBuildInputs = [ pkgs.copyDesktopItems ];
        };
      in
      {
        checks =
          {
            inherit package;


            package-clippy = craneLib.cargoClippy {
              inherit cargoArtifacts src;
              cargoClippyExtraArgs = "--all-targets -- --deny warnings";
            };

            package-fmt = craneLib.cargoFmt {
              inherit src;
            };

            package-audit = craneLib.cargoAudit {
              inherit src advisory-db;
            };
          };

        packages.default = package;

        apps.default = flake-utils.lib.mkApp {
          drv = package;
        };

        devShells.default = pkgs.mkShell {
          inputsFrom = builtins.attrValues self.checks;

          nativeBuildInputs = with pkgs; [
            cargo
            rustc
          ];
        };
      });
}

one would imagine that this

  • writes a my_package.desktop file into result/share/applications
  • prints gibberish before building,

yet none of this happens.

Some way to have `buildDepsOnly` preserve extra files

We need to use some wrappers around linker/ar binaries in .cargo/config.toml:

[target.armv7-linux-androideabi]
linker = "./.cargo/ld.armv7-linux-androideabi"
ar = "./.cargo/ar.armv7-linux-androideabi"

[target.aarch64-linux-android]
linker = "./.cargo/ld.aarch64-linux-android"
ar = "./.cargo/ar.aarch64-linux-android"

[target.x86_64-linux-android]
linker = "./.cargo/ld.x86_64-linux-android"
ar = "./.cargo/ar.x86_64-linux-android"

[target.i686-linux-android]
linker = "./.cargo/ld.i686-linux-android"
ar = "./.cargo/ar.i686-linux-android"

These are some custom scripts that use env variables to fix some Android toolchain issues.

Unfortunately, I discovered that mkDummySrc is not friendly to these, and all of them are stripped from the building src, so building project dependencies fails.

Some escape hatch, and maybe by default preserving whole ./cargo/ directory would be nice.

Improve cross-compilation example

Currently, the cross-compilation example instantiates nixpkgs like so:

pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};

And proceeds as usual, only referencing the custom toolchain when instantiating craneLib:

rustWithWasiTarget = pkgs.rust-bin.stable.latest.default.override {
targets = [ "wasm32-wasi" ];
};
# NB: we don't need to overlay our custom toolchain for the *entire*
# pkgs (which would require rebuidling anything else which uses rust).
# Instead, we just want to update the scope that crane will use by appending
# our specific toolchain there.
craneLib = (crane.mkLib pkgs).overrideScope' (final: prev: {
rustc = rustWithWasiTarget;
cargo = rustWithWasiTarget;
rustfmt = rustWithWasiTarget;
});

This is AOK if you don't have any system dependencies, but it would be great if an example were added showing how to use crane together with crossSystem, akin to the example in rust-overlay: https://github.com/oxalica/rust-overlay/blob/master/examples/cross-aarch64/shell.nix.

I've attempted to get this to work with the following (truncated) snippet:

{
        localSystem = "x86_64-linux";
        crossSystem = "aarch64-linux";
        pkgs = import nixpkgs {
          inherit localSystem crossSystem;
          overlays = [ rust-overlay.overlay ];
        };

        rustToolchain = pkgs.pkgsBuildHost.rust-bin.stable.latest.default;

        craneLib = (crane.mkLib pkgs).overrideScope' (final: prev: {
          cargo = rustToolchain;
          rustc = rustToolchain;
          clippy = rustToolchain;
          rustfmt = rustToolchain;
        });

        src =  ./.;

        cargoArtifacts = craneLib.buildDepsOnly {
          inherit src;
        };

        crateFmt = craneLib.cargoFmt {
          inherit cargoArtifacts src;
        };

        crateClippy = craneLib.cargoClippy {
          inherit src;
          cargoArtifacts = crateFmt;
          cargoClippyExtraArgs = "-- --deny warnings";
        };

        crate = craneLib.buildPackage {
          inherit src;
          cargoArtifacts = crateClippy;
        };
}

But it fails with the following:

hyperpixel_init-clippy-aarch64-unknown-linux-gnu> unable to copy cargo artifacts, "/nix/store/ppzyixshipwzr7zqvq190mdfbcap6njg-hyperpixel_init-fmt-aarch64-unknown-linux-gnu-0.1.0/target.tar.zst" looks invalid

You should be able to reproduce this with nix build -L on https://github.com/lovesegfault/hyperpixel-init on the crane branch.

Help building `rusqlite` for `wasm32-unknown-unknown`

I've described my issues with building rusqlite/rusqlite#1010 using crane in detail at https://discourse.nixos.org/t/help-building-rusqlite-for-wasm32-unknown-unknown-with-crane/21724 and created a standalone project at https://github.com/paulyoung/rusqlite-wasm32-unknown-unknown-nix . I'd appreciate it if someone could take a look.

My main motivation for filing this issue is that I (perhaps incorrectly) suspect that crane might be doing something to the build that I don't understand (perhaps via automatic handling of git dependencies?) such as trying to set certain environment variables.

Apologies if this is not an appropriate use of issues for this project. I suspect it might be an interesting use case to discuss and helpful for other crane users in the future.

Thanks for crane; this is my first time using it and I like it a lot so far.

Cargo dep with missing locked revision fails with unclear error message

After using tokio-uring = { version = "0.3.0", git = "https://github.com/tokio-rs/tokio-uring" } I was getting:

> nix build .#loglogd                                                                                                                                                              
warning: Git tree '/home/dpc/lab/loglog' is dirty                                                                                                                                  
error: unknown hash algorithm 'https'                                                    
Try 'nix --help' for more information.     

I had to:

--- a/server/Cargo.toml
+++ b/server/Cargo.toml
@@ -25,7 +25,7 @@ tokio = { version = "1.19.2", features = ["macros", "rt", "rt-multi-thread", "si
 thiserror = "1.0.31"
 num_enum = "0.5.7"
 nix = { version = "0.24.2", features = [ "zerocopy" ]}
-tokio-uring = { version = "0.3.0", git = "https://github.com/tokio-rs/tokio-uring" }
+tokio-uring = { version = "0.3.0", git = "https://github.com/tokio-rs/tokio-uring", branch = "master" }
 binrw = "0.9.2"
 typed-builder = "0.10.0"
 derive_more = "0.99.17"

to get it to build again.

cargoTarpaulin broken- permission issue

#49 seems to have broken my use of cargoTarpaulin- reverting the cargoBuildCommand from

cargoBuildCommand = "cargoWithProfile tarpaulin";

to

cargoBuildCommand = "cargo tarpaulin";` 

in lib/cargoTarpaulin.nix avoided a number of permission denied panics:

nix flake check #.x86_64-linux.app-tarpaulin
error: builder for '/nix/store/92x8a0ba5lxbvq0zrgb57dxr7yjm9i7z-app-tarpaulin-0.1.0.drv' failed with exit code 1;
       last 10 log lines:
       >   running: "ar" "s" "/build/source/target/release/build/zstd-sys-49da8651afb28f6d/out/libzstd.a"
       >   exit status: 0
       >   cargo:rustc-link-lib=static=zstd
       >   cargo:rustc-link-search=native=/build/source/target/release/build/zstd-sys-49da8651afb28f6d/out
       >
       >   --- stderr
       >   thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', /nix/store/igrpi0wmjyxx07v5z2crnk21m6fsrpgk-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/zstd-sys-2.0.1+zstd.1.5.2/build.rs:184:58
       >   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       > Jul 26 13:30:53.889 ERROR cargo_tarpaulin: Cargo failed to run! Error: cargo run failed
       > Error: "Cargo failed to run! Error: cargo run failed"

Add some support for filtering `src` or at least highlight it in the docs and examples.

After I realized why my projects rebuilds completely any time I touch any file it became apparent that src = ./.; is never a thing that one should use in practice. "src = ./.; considered harmful".

I see that you've opened #78 as I'm typing in this text, but I don't think it is enough.

Now that I discovered this fundamental improvement, I'll have to go and update all the projects I already started using crane in, which means copying bunch of boilerplate to filter src.

It seems to me that crane should come with a built-in and advertised function(s) to filter the src - possibly something like this and maybe also some specialized versions ("all Cargo files", "all cargo files + rs files"). At very least it would save on the boilerplate in every project. Also - probably the examples should just use such filtering everywhere. I don't think hoping for people to read FAQ and connect the dots is an optimal strategy. 99% of Rust users do not know Nix, yet they might want to try it out, or will want to contribute to projects that do use crane. They might not even be fully aware of how cargo uses target - they just want to build stuff and get a nice, fast reproducible build.

I remember that you mentioned somewhere that you'd like to have better automated filter, but it will be complex, and I'm not even sure if it's possible in general case (stuff like build.rs can potentially do anything inside, and how is crane going to figure it out?). Eg. when running tests, I need to enable some extra files anyway. So it seems to me that crane will have to support manual filtering for a long while - might as well make it first class.

A way to output just a diff of `./target`

I was admiring the results of crane-based CI pipeline in Fedimint: https://github.com/fedimint/fedimint/actions/runs/2853966200 . After adding all the proper src filtering, when no source files were modified, nothing gets rebuild - not even tests are being re-run (since they've already passed successful, there's no point in re-running them).

Which is frankly super awesome, and thank you so much for working on crane! I can't overstate how well it works and how helpful you are. :)

However as you can see the build still takes ~2m, and it's all downloading stuff from cachix. There is something off there - as 2GB of stuff shouldn't take 2 minutes to download, IMO, but that's something I'm going to investigate on my own.

I started looking into why is it 2GB of data, and I realized that part of the reason is that build contains two target/ outputs:

Cachix: push
  /home/ubuntu/actions-runner/_work/_actions/cachix/cachix-action/v10/dist/main/push-paths.sh /home/ubuntu/.nix-profile/bin/cachix fedimint 
  compressing and pushing /nix/store/08mljabqrb8p11dl3y9ddqbakiss3mhl-source (108.28 KiB)
  compressing and pushing /nix/store/gw7pv5j6djw3rmkxvv9lj5az7l7xccfk-cargo-package-0.0.1 (489.87 MiB)
  compressing and pushing /nix/store/h1riypzjkqxc6qvw0m6f0kw7dvnrhai5-source (744.02 KiB)
  compressing and pushing /nix/store/acpnlx92cd7rgsm028l1g4mmf1575c4g-source (760.59 KiB)
  compressing and pushing /nix/store/9d3fwbq3bp0n03lrbs6msmacj2m9y7ml-cargo-package-0.0.1 (96.00 B)
  compressing and pushing /nix/store/glzdgkib6v3mf556vfhb7zy6ziqadk1l-cargo-package-0.0.1 (96.00 B)
  compressing and pushing /nix/store/9gmk58528m11yrra4miapcca0wv6ywnc-cargo-package-0.0.1 (420.72 MiB)
  compressing and pushing /nix/store/qdwmpys2zsr3klx1p92c730zw7jn0ali-cargo-package-0.0.1 (96.00 B)
  compressing and pushing /nix/store/qph9acr5h18gj51g1hv9d56ahngnxqym-cargo-package-0.0.1 (96.00 B)
  compressing and pushing /nix/store/sqaaj2ly4whg43iy05rikbcrc65j1azs-cargo-package-0.0.1 (96.00 B)
  compressing and pushing /nix/store/qf98j6391lrdmj9k0y0x2z94m99madl7-cargo-package-0.0.1 (96.00 B)

The 420MB one is the ./target after building the dependencies only, and 490M are the full workspace build.

And it made my realize - 80% of that 490M is redundant, isn't it? It is exactly same data that 420MB contains.

So I wonder - if crane allow somehow to store in $out only the files of ./target that are different from the input cargoArtifacts, then steps that need that output can just restore the first version, and then the diff, and get the same data, without storing anything twice.

The diffing itself might be slightly slower, but I think it will be more than made up for storage savings, in particular if network transfers are involved. And given that in the cloud CPU power is relatively cheap, yet storage is expensive it could be a big optimization.

This could possibly be all optional. The step producing ./target would have some doInstallCargoArtifactsDiffOnly = true;, and then downstream users would do cargoArtifacts = [ workspaceDeps workspaceFull ];. I wonder if it's possible to somehow write the reference to the base cargoArtifacts along the diff-only $out, so that the users don't even need to specify the [ base diff1 diff2 ... ] list, but I kind of doubt it (unless there's some Nix magic that I'm not aware of).

Crane / nix flake delaying the stdout from the cargo?

I've noticed both locally and in CI that the output is delayed. When a large package is being built what is being displayed is actually:

   Compiling proc-macro-error v1.0.4

where proc-maco-error is just an arbitrary crate that happens to be right before the the crate that actually takes a long time to build. It's mildly annoying, and also confusing.

Initially I thought it's because of the progress-bar, but I tried to disable it and it doesn't make a difference.

Extranous crates in vendored git repo can cause a build failure if they fail to parse

I had to switch to use git version of error-stack like this:

-error-stack = "0.1.1"
+error-stack = { version = "0.1.1", git = "https://github.com/hashintel/hash/", rev="5edddb5" }

cargo build works fine with it, but nix build .#foobar fails with:

> nix run .#res.starter
path '/home/dpc/lab/rustshop/services' does not contain a 'flake.nix', searching up
warning: Git tree '/home/dpc/lab/rustshop' is dirty
error: builder for '/nix/store/yj8a6ir4szhq4aa73xhnjwi5bwcxd2xf-services-workspace-deps-deps-0.0.1.drv' failed with exit code 101;
       last 10 log lines:
       >   Unable to update https://github.com/hashintel/hash/?rev=5edddb5#5edddb55
       >
       > Caused by:
       >   failed to update replaced source https://github.com/hashintel/hash/?rev=5edddb5#5edddb55
       >
       > Caused by:
       >   failed to parse manifest at `/nix/store/36f54ndv3y8yr2zhbxy1ss7mhs6jjj80-vendor-cargo-deps/8379b92581444212dd05e8733c6ac22ae88bba0f603ebf7660db6adbcf973197/orchestrator-0.0.0/Cargo.toml`
       >
       > Caused by:
       >   `artifact = …` requires `-Z bindeps` (hash_engine)
       For full logs, run 'nix log /nix/store/yj8a6ir4szhq4aa73xhnjwi5bwcxd2xf-services-workspace-deps-deps-0.0.1.drv'.
error: 1 dependencies of derivation '/nix/store/0bz9mki1h7fhk23i1qf1alpr4zc1bg2i-starter-res-gen-0.0.1.drv' failed to build

The problem might be that this crate lives in a subdirectory of larger project?

Making your own lib and not overriding clippy makes clippy fail with incompatible versions

In my flake I have:

         craneLib = (crane.mkLib pkgs).overrideScope' (final: prev: {
            rustc = rustTarget;
            cargo = rustTarget;
            rustfmt = rustTarget;
          });

and in my checks:

 my-app-clippy = craneLib.cargoClippy {
              inherit cargoArtifacts src;
              cargoClippyExtraArgs = "-- --deny warnings";
            };

This gives the following error:

error[E0514]: found crate `std` compiled by an incompatible version of rustc
  |
  = help: please recompile that crate using this compiler (rustc 1.60.0) (consider running `cargo clean` first)
  = note: the following crate versions were found:
          crate `std` compiled by rustc 1.61.0 (fe5b13d68 2022-05-18): /nix/store/7nbm9f6mf8jh8ndxm243zbdjkdwwh7lr-rust-std-1.61.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-05b39ac0cb4c5688.rlib
          crate `std` compiled by rustc 1.61.0 (fe5b13d68 2022-05-18): /nix/store/7nbm9f6mf8jh8ndxm243zbdjkdwwh7lr-rust-std-1.61.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-05b39ac0cb4c5688.so
          crate `std` compiled by rustc 1.61.0 (fe5b13d68 2022-05-18): /nix/store/7nbm9f6mf8jh8ndxm243zbdjkdwwh7lr-rust-std-1.61.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-df6036c77d75ce21.rlib

Adding clippy to the mkLib makes it work again.

While I understand that this error is of my making, it is also somewhat intransparent if I didn't know what went wrong. Maybe the lib can check that clippy is being called on the right version before and throw a better message, or mkLib makes sure that they are all the same version (with a helper function maybe?)

Source prefix mapping is broken if rustflags are set in .cargo/config.toml

Originally brought up in #75

Repro flake: https://github.com/shanesveller/axum-rest-example/blob/5e8831b91724f81970204fff877293e2f2ec65d2/flake.nix#L83-L169

Running nix path-info .#docker -r gives:
/nix/store/004217z94skkdd664v74aa1a43x1xq7b-cargo-package-aho-corasick-0.7.18
/nix/store/00d196bbncisks5amrximqmia6p6w204-cargo-package-mime-0.3.16
/nix/store/01a5gg965ki1zx34vzl9jk5wz4f4y01b-cargo-package-async-stream-impl-0.3.3
/nix/store/0ap1cxi1l8ax2as9znihmh8w99bdh8ai-cargo-package-which-4.2.5
/nix/store/0gnkg18w8fh6x87w7ywg3qmj05l87r0w-cargo-package-atoi-1.0.0
/nix/store/0kx0m1dyby3q7ngww9x7k1ikdl3h1x60-cargo-package-unicode-normalization-0.1.21
/nix/store/0rgm65ymq6hhkf4b3sy0qqadckkypndv-cargo-package-tokio-1.20.1
/nix/store/0vdzclflbbmlq0y509prp7fn8jv5pl8j-cargo-package-httparse-1.7.1
/nix/store/1269vy9nzw5p170p26i9hkisrbmn4hvd-cargo-package-parking_lot-0.11.2
/nix/store/185dqq2w54qm1qri00ixa7smb1cg5fx9-cargo-package-android_system_properties-0.1.4
/nix/store/1afbvyc3d2r9v8i81iwm8hbnb4lmv3qz-cargo-package-typenum-1.15.0
/nix/store/1gcgis47wk8qxc5ch9frdacwas8jx0n4-cargo-package-sqlformat-0.1.8
/nix/store/1mpj58d7lr0m2h3cz0w716hnl10dm28m-axum-rest-example-customisation-layer
/nix/store/1nlhzs2n4h71kmxzk0zimjhj14q0zwyn-cargo-package-paste-1.0.8
/nix/store/1pxc8zaydlbdcxyprlxvs0yd8m4gw36p-cargo-package-async-stream-0.3.3
/nix/store/1v5i6h1407qmhgy6yrjri8kjwpz6445x-cargo-package-tracing-attributes-0.1.22
/nix/store/1vw0adh7g5hm6ffq06msqyqha7qj52l9-cargo-package-webpki-0.21.4
/nix/store/1zjg5svjy32yz6m89baxnkq2i02ic714-cargo-package-smallvec-1.9.0
/nix/store/2caw02v8dgcdcrnff3ci0rsbqshr4knj-cargo-package-fastrand-1.8.0
/nix/store/2iq3n9asdaqs4871fsh8sxwb6qdf9xd0-cargo-package-tokio-util-0.6.10
/nix/store/3461zyyxqdjlkln6wbq2kv3bv818xkx9-cargo-package-wasm-bindgen-macro-0.2.82
/nix/store/3f2ia14y2xlvik4k996548jdib6ss0kd-cargo-package-winapi-i686-pc-windows-gnu-0.4.0
/nix/store/3nryb2j8i2xkj14x3xvpf9x9n2fzc9nh-cargo-package-thiserror-1.0.32
/nix/store/437vh6mhmvvvpd43ayn0i44i4qwslh9i-cargo-package-matchers-0.1.0
/nix/store/43hh5jnf1qzky420jw0xhsc59368sgif-cargo-package-spin-0.5.2
/nix/store/4p4gajw62mk83d5i5fgj2kbp32bndbj2-cargo-package-tracing-futures-0.2.5
/nix/store/4qj9vznf8dza5iral96024rm82vwv6x5-cargo-package-headers-0.3.7
/nix/store/4vpqn2vbz51vbprkzpgld2f2wmwqn4f6-cargo-package-itoa-1.0.3
/nix/store/4x2gwz8dinbkxryrriga1annhdh53fvh-cargo-package-dotenvy-0.15.1
/nix/store/51p3356hv1k0zyidbadrxf79azi0m8ry-cargo-package-ryu-1.0.11
/nix/store/54ikgwrwqsmhglyllm89byydxj63iidk-cargo-package-tinyvec-1.6.0
/nix/store/wj6j8lrdlind44n7vqn864ga7y802vc7-libunistring-1.0
/nix/store/rp4dwxbw4vk590lrbcf9r198cdjwjhmd-libidn2-2.3.2
/nix/store/scd5n7xsn0hh0lvhhnycr9gx0h8xfzsl-glibc-2.34-210
/nix/store/q7k32ydcqlram7f0l6b1y2c4cs07765y-zlib-1.2.12
/nix/store/55x9vyjbplnkrc0b2f060jqzdwqd13n4-sqlite-3.38.5
/nix/store/59y3yhsz7hh6bkd0r7z345fh9016pggr-cargo-package-pin-project-1.0.11
/nix/store/5lx2zyfn1ww907349n8a3nlqn9ng15hs-cargo-package-js-sys-0.3.59
/nix/store/5rimm8cqvp9y77zkp1zxncd6jv4fnh4p-cargo-package-sqlx-0.6.1
/nix/store/5s5cwhq5jxf15kv1cva9i54mhrv4mfif-cargo-package-syn-1.0.99
/nix/store/5v741l9rbidqx0dn307lklbz1djcgf81-cargo-package-futures-executor-0.3.21
/nix/store/61ffmipxrswk0x09rnwfdh0d8bkpg2cd-cargo-package-unicode_categories-0.1.1
/nix/store/633irk75644qhlkalvz9isb8izs227x0-cargo-package-rand_core-0.6.3
/nix/store/63g892cqzc5dkn60lv4yr09zwpvwwk59-cargo-package-tempfile-3.3.0
/nix/store/67iapzh2zzlcykn5hn70jki5xyps3k7c-cargo-package-lazy_static-1.4.0
/nix/store/67iymy0yxc5kaqar4y1gy1kwlwk5qmll-cargo-package-tonic-build-0.6.2
/nix/store/6li05ajqrqvqvg705cadfrdhvaf1nkji-cargo-package-http-body-0.4.5
/nix/store/6yzsbgj7vq0scl5jfkcp2zv0ksqpai64-cargo-package-tower-service-0.3.2
/nix/store/6zm46bgj056kb5rvklwjfikbsfkpr7m6-cargo-package-autocfg-1.1.0
/nix/store/74nilnyl1ycjm5lf7apl1q5sdf2x1cn7-cargo-package-cfg-if-1.0.0
/nix/store/79f1w796ljm8l8v137kngq326qm04x20-cargo-package-async-trait-0.1.57
/nix/store/7l35dn3rw3dlpxc6iyppcxc96kc1z6zy-cargo-package-zeroize-1.5.7
/nix/store/7qwzhp0qs4vx37sia21dcnfiscx5m87g-cargo-package-digest-0.10.3
/nix/store/7zj5yv17cnhyiaba38z3qdqnif3x58rz-cargo-package-indexmap-1.9.1
/nix/store/8636r3d8rsk7c3l5xcgb1mn37pkfc84k-ncurses-6.3-p20220507
/nix/store/89abgv341an3ywpwwhzv359kafmq10ig-cargo-package-winapi-0.3.9
/nix/store/8dwij0g1sbxhwzaabb3qp9sjw7gkavzh-cargo-package-headers-core-0.2.0
/nix/store/8i6b27rnzj1w02rma3rb30f7fq4k2hl6-cargo-package-prost-build-0.9.0
/nix/store/8j1vf2i92pdh7x7vx26l49980kbmvdi9-cargo-package-tower-0.4.13
/nix/store/8mg064bixgn15v4586caaqn3xblkb9ix-cargo-package-opentelemetry-0.17.0
/nix/store/8pd4xbrwj353k8k0wsl55c0x4ymkcnvq-cargo-package-hashlink-0.8.0
/nix/store/8rg8jz4nxl05mxfilxxr91m12fblxy0f-cargo-package-remove_dir_all-0.5.3
/nix/store/92n8p9kz64d926nsyxp2v5wqhsrqs8s2-cargo-package-lock_api-0.4.7
/nix/store/95p24qvbfrmf1ndc5c6ica23kmpziqzk-cargo-package-once_cell-1.13.0
/nix/store/972dq59321d1h1xzr6m766065xzfa98v-cargo-package-iana-time-zone-0.1.44
/nix/store/9jphwyj3pgn8nwg1xsbahx6p1adf0shz-cargo-package-version_check-0.9.4
/nix/store/9kbzfwxgq91x5cg7lfvjzchqbdy9gzln-cargo-package-axum-0.5.15
/nix/store/9pdicwb4a75r6x6i06g7pfd0npwsvdgr-cargo-package-dirs-sys-0.3.7
/nix/store/9q8i1yx9jgw923zp4vrd4v0pc08c3m6r-cargo-package-mio-0.8.4
/nix/store/9sw9rc0vl4jxysymi2ypc633zg8k51sb-cargo-package-percent-encoding-2.1.0
/nix/store/a25rbnln4l36jbcaiihyy42wrkpf044k-cargo-package-pin-project-internal-1.0.11
/nix/store/a29gzg1i5xwcmh7k7pym7zxaajkv2n4q-cargo-package-url-2.2.2
/nix/store/a6sp57hx5w0qpgqw6spnfcmskfcj1cvm-cargo-package-secrecy-0.8.0
/nix/store/a7p17wqxbyciiilwq7sdkpvs3a94jr9l-cargo-package-unicode-segmentation-1.9.0
/nix/store/a8y640s77z4s2b2zv6jvrsqknpj3n8ng-cargo-package-sqlx-rt-0.6.1
/nix/store/ak8afa90mw48jin8gvn654jzbbdczdif-cargo-package-web-sys-0.3.59
/nix/store/b65cqbics4ivq34lf5pqwsbdp4jhb1fp-cargo-package-block-buffer-0.10.2
/nix/store/b862q0qxgvjdvc3w16h7nb4xy665hrhv-cargo-package-getrandom-0.2.7
/nix/store/baj3qaw2f55vjdmsj2a46iyga1lbkw1z-cargo-package-ahash-0.7.6
/nix/store/bav2l95yl31dpz9z6n07ym242zmy57s1-cargo-package-bitflags-1.3.2
/nix/store/bk243s31zrlgzgg9ikb78dp9zg7pgqms-cargo-package-futures-intrusive-0.4.0
/nix/store/bmx7yd2bg9llbjv6s7bq2jd8hvbriccl-cargo-package-regex-1.6.0
/nix/store/brfyazqhaq8mr4b4mikwhp5np81439f1-cargo-package-ppv-lite86-0.2.16
/nix/store/c0gga2igwzg2iwpv15f7kdnb7l0m73iw-cargo-package-tinyvec_macros-0.1.0
/nix/store/c98n3ifn21wd5g44gsnayhbkk4wwvlwv-cargo-package-parking_lot-0.12.1
/nix/store/cba31l14xc1m8n76bxjlwbsc113sp1fy-cargo-package-futures-task-0.3.21
/nix/store/ccwc7k0bg1y42rdqh77p2pazyyvdb86l-cargo-package-hmac-0.12.1
/nix/store/cgnr2rhhqz98iw6cgyqr738cv4nwa0j0-cargo-package-windows_aarch64_msvc-0.36.1
/nix/store/cvw4ziyls1fkpb1r2flnjhgj23x29m01-cargo-package-webpki-0.22.0
/nix/store/cz4jn9pd4hz41ja6vsg5hlaym75piyhf-cargo-package-instant-0.1.12
/nix/store/d0qdby99xhhhj279slp9s4fdpax08s4h-cargo-package-dirs-4.0.0
/nix/store/d3zszpf41l7kwlnlsc0js3lzvnkpfanf-cargo-package-cc-1.0.73
/nix/store/d7wb87s6jmrf8d7bdlv6rjjy872q5hb7-cargo-package-idna-0.2.3
/nix/store/d9iw77mq6sddsjjl2gci3hl62bbrh6p0-cargo-package-nom-7.1.1
/nix/store/dba9y45v2i1186mf3v8jwcbva6xcx18b-cargo-package-matchit-0.5.0
/nix/store/dbixnf39diwj12grq6z3dziy4qcp3hqq-cargo-package-futures-io-0.3.21
/nix/store/djll0qnml986lws89f93cjzczzxl2z10-cargo-package-parking_lot_core-0.9.3
/nix/store/djzbyqlf06g4h6fyzhjvninyswd9xav3-cargo-package-wasm-bindgen-macro-support-0.2.82
/nix/store/dknd0mwlnavya38rfdnr9q1r20lscc7d-cargo-package-dashmap-4.0.2
/nix/store/dnjm9ca53rp45n6l3pig1akp5blsna60-cargo-package-crossbeam-channel-0.5.6
/nix/store/f9b66ih9i7w2pn65hhi1rzvdg43l4vxf-cargo-package-hex-0.4.3
/nix/store/fanwhgr320kx728kl5y2xk4anys3h7nh-cargo-package-hermit-abi-0.1.19
/nix/store/fb2wvzfn5l4kscqdz24121fpb1x8qqyz-cargo-package-tokio-util-0.7.3
/nix/store/fnifgymxswp35qm2jabhaf7qq2iy8nqf-cargo-package-base-x-0.2.11
/nix/store/fsrsx4r5hr0kscj68ljfw52k6anl2nzx-cargo-package-serde_derive-1.0.143
/nix/store/fyd4wzawcfg948kiwc5f0nakx04a92zn-cargo-package-axum-core-0.2.7
/nix/store/g3j4f81jhfr0wsj2r5z7db7svmil5dhr-cargo-package-bytes-1.2.1
/nix/store/gfmarjz9ia1wg5ddnwcw0ykx6nd0n15a-cargo-package-crossbeam-utils-0.8.11
/nix/store/gi37fl04rqdhs0akwfs27f9mia4a47ig-cargo-package-tower-http-0.3.4
/nix/store/giz0zjfkrnz2df2svkcgydkh81fyj7rv-cargo-package-prost-0.9.0
/nix/store/gj98cm9f01dvpi4f5kscgvzyaw3jh1s2-cargo-package-toml-0.5.9
/nix/store/gjy4ria5smwkllvh99wcaarmjwlaix5f-cargo-package-subtle-2.4.1
/nix/store/gmfb2aw4gfy6i2a595djfd78gwqpk2xg-cargo-package-sharded-slab-0.1.4
/nix/store/gqp0icmb7vz0lygq1bqpbqvzfb5ylxdq-cargo-package-sha2-0.10.2
/nix/store/gw11ixj525zb3pf59ybc0y6nfinjyklc-cargo-package-rand-0.8.5
/nix/store/h2rc98v40y1v24nyjv4yw4jppc7ahrpa-cargo-package-sqlx-core-0.6.1
/nix/store/h34srjafsvw870a6s68b4fcxwbsg7rnc-cargo-package-either-1.7.0
/nix/store/h4kq9mcf417qvhyam23735hzyapfik89-cargo-package-uuid-1.1.2
/nix/store/h8834d3rx088389npps7p76h6q57yhr6-cargo-package-windows_i686_msvc-0.36.1
/nix/store/h8h43cph3hl0f3dn5qrv153m9f4gylgm-cargo-package-redox_syscall-0.2.16
/nix/store/hrzn3xca6d4nnw9kx2qgj9s11yfk9r8q-cargo-package-parking_lot_core-0.8.5
/nix/store/hxm548klczvkj4n4r8jvsz35ray6z6pr-cargo-package-crc-catalog-2.1.0
/nix/store/hz62fklhcyqa3ga6sjd0kmwn7y5pdp78-cargo-package-rustls-0.20.6
/nix/store/i2l93111ysjc7mg70xl0l6krr2w02cxm-cargo-package-proc-macro2-1.0.43
/nix/store/i2n58pbp06yrpg59x0wkwk5lvclgmd14-cargo-package-socket2-0.4.4
/nix/store/i80chifd5x8ap9dj8xqda7kspc4pdmq4-cargo-package-want-0.3.0
/nix/store/i8aznvf6svp954ndyix3x4j9k3p7a6hz-cargo-package-pin-utils-0.1.0
/nix/store/ihmv8pll0z10k6hqjzzdi2dca7sy448r-cargo-package-windows_x86_64_msvc-0.36.1
/nix/store/ii6k2l28x2cvs88f93wfy325dqfadb5y-cargo-package-wasm-bindgen-shared-0.2.82
/nix/store/imxjpkpa2gwn1dfdcd4a7a2yf859yq6n-cargo-package-futures-channel-0.3.21
/nix/store/in6dcpgkh63wsp5m7bwz656sv6x5k9ri-cargo-package-fixedbitset-0.4.2
/nix/store/irrw3ch38darl4wyn63npcs6gwmcdhrh-cargo-package-memchr-2.5.0
/nix/store/j744r7a5zf09kb07dans8gqnavw8ql7p-cargo-package-futures-util-0.3.21
/nix/store/jay7qmnjqq9cqfyqj1qbpsy8h8nkv9ns-cargo-package-tracing-subscriber-0.3.15
/nix/store/jbclnj1liavhy1yb59kiibcz7wb1ybcz-cargo-package-thread_local-1.1.4
/nix/store/jd18qn8jx3aigh6yim172321mkcvqily-cargo-package-prost-derive-0.9.0
/nix/store/jg1z378q62ns7wxwh8iaq0zya3bcshk3-cargo-package-unicode-ident-1.0.3
/nix/store/jwprn09ra82bgcx3by84javg02bamzam-cargo-package-serde-1.0.143
/nix/store/jyqh3f1isfgrb0p017ywwrlqimzpxr2v-cargo-package-sync_wrapper-0.1.1
/nix/store/k2qssnmpx5fzdc8vjj9h4q2zds4gq9xf-cargo-package-rand_chacha-0.3.1
/nix/store/k3qzzj9f0baarfr89d9dv9xk40i4rn7b-cargo-package-tokio-macros-1.8.0
/nix/store/k3w5jq0v2aqyn0x9rdnpdfvrxi279fn4-cargo-package-generic-array-0.14.6
/nix/store/k75k57b502qijh6ahx4m4dxblf6kaz5q-cargo-package-core-foundation-sys-0.8.3
/nix/store/k7m54cxqw7zh3kb8va371j1blpdhr1w2-cargo-package-try-lock-0.2.3
/nix/store/kmwwa1gbn3d1agxrrlhm6bmk4vba0lw2-cargo-package-redox_users-0.4.3
/nix/store/kpf20vr3i31qc1dvwxxf7g5671gswz4c-cargo-package-winapi-x86_64-pc-windows-gnu-0.4.0
/nix/store/kqzzxyaqx6jy7s707lwp8f3rrshx0g0b-cargo-package-byteorder-1.4.3
/nix/store/ksgi1bqrr2pf9n5zqz6g275yz1l08hgv-cargo-package-sqlx-macros-0.6.1
/nix/store/kyj8jl5qw4ixbb9jwmvn0b8n3yrwfp9p-cargo-package-httpdate-1.0.2
/nix/store/kyqxrrj9579lmflcfidgzz8h7mriwq1c-cargo-package-sct-0.7.0
/nix/store/kzrjjjaasiz08xj1607kl74mj1l87d1j-cargo-package-libc-0.2.131
/nix/store/l23hc9mc6ymrq77dvfwg0j4d7nn54p36-cargo-package-tonic-0.6.2
/nix/store/l6sw8iv2syx8b5lhb7dqa88n8qk0z423-cargo-package-pin-project-lite-0.2.9
/nix/store/l9n8pgnpcmfi1vzc4rlm6aykjxglv1mj-cargo-package-rustls-0.19.1
/nix/store/l9xpibgx1ql852k6svwxi7171dj8pl50-cargo-package-http-range-header-0.3.0
/nix/store/la1qayscjr9wdvddxgl5asmxsqg4a22b-cargo-package-tokio-rustls-0.22.0
/nix/store/lbrryxk0frpi7vkxiz798h0w6cniszli-cargo-package-tracing-0.1.36
/nix/store/lc5vipn5lkwj43slpnh84jgkp97vipy6-cargo-package-heck-0.3.3
/nix/store/ldvnkv12as592m9jvw74pmi85i6wyd0z-cargo-package-thiserror-impl-1.0.32
/nix/store/lq0pqmhvc1f0d77cbgd034n5lgqpwzyc-cargo-package-serde_json-1.0.83
/nix/store/ls322d3bxy6drmhbp82r4wfq96k6kh4j-cargo-package-futures-0.3.21
/nix/store/lvlf1xn5xg0finap2swr1r9pqjp6z0sr-cargo-package-num-traits-0.2.15
/nix/store/lvvvalbhizsjx8fklfs82z6zxrbh03jz-cargo-package-untrusted-0.7.1
/nix/store/m0zcsjv1ckgnjz2s71d5c5nff096rliy-cargo-package-wasi-0.11.0+wasi-snapshot-preview1
/nix/store/m1l7mc65nank1kmiq4jdbznlmv1qgnkh-cargo-package-crossbeam-queue-0.3.6
/nix/store/m4af3ypfxllmq5636i8ykpjv154h1mpr-cargo-package-http-0.2.8
/nix/store/m9gqaz0ly00da4dkjhx6bga9bp8fnb89-cargo-package-tokio-rustls-0.23.4
/nix/store/md8pghg4hr3sczgkgzpxql6x63dhl2ab-cargo-package-hyper-timeout-0.4.1
/nix/store/mps2syk6rqn8mqlsxbzpf6myig3hh5fx-cargo-package-windows_i686_gnu-0.36.1
/nix/store/nbizgs21ffg2m1dsmvayhf57131619kl-cargo-package-config-0.13.2
/nix/store/nj2jmlwp3aijbvfk8aphkqnjnfw0303y-cargo-package-bumpalo-3.10.0
/nix/store/nyfskjcil4nrspri09mfma9wr3kfi4wg-cargo-package-regex-automata-0.1.10
/nix/store/p2fzm8mb52mwvhqj5xrip2lpz72qfh1i-cargo-package-cpufeatures-0.2.2
/nix/store/p3nm48rwh6n0cmzz1db49fjbwc64l9vq-cargo-package-sha-1-0.10.0
/nix/store/pbxa4pgc7if6qpkq6fqswcdwdpfvl3mz-cargo-package-tracing-opentelemetry-0.17.4
/nix/store/plrl7pahxvxk91pwirmifj9qblc08hxl-cargo-package-ring-0.16.20
/nix/store/pmdpxs37vkg8x1afypjay4d0zzgasy1g-cargo-package-tracing-log-0.1.3
/nix/store/ps9makph9k4qn8r2kq7fzfjrik9fkyy5-cargo-package-wasm-bindgen-backend-0.2.82
/nix/store/py6k2z2rka5ddss2gbh7i33zy8n1d2bc-cargo-package-unicode-bidi-0.3.8
/nix/store/qcg5pqlmcqfx3qc9l93rn6246c6zwwfr-cargo-package-windows_x86_64_gnu-0.36.1
/nix/store/qhj3fgxqfh0pxd0qx4znvlzjk9mhsw5n-cargo-package-multimap-0.8.3
/nix/store/ql84jyy7fanpwf5jzdpx00rgnjrhn7dk-cargo-package-scopeguard-1.1.0
/nix/store/qx0b4iyr9lpsdp1pc7nzmdz0862ka683-cargo-package-futures-sink-0.3.21
/nix/store/r0mwk59w6mf17nh3i3wxnaj46rmg62ah-cargo-package-prost-types-0.9.0
/nix/store/r36041g57qsm2yjbrh9127hvdjk3gj3l-cargo-package-tower-layer-0.3.1
/nix/store/r8j83qr1ach6xr0zdiyhg7nz9s0lnfdi-cargo-package-ansi_term-0.12.1
/nix/store/r9hnvr96h5azbvxpqfkj3ymd0sin8q0q-cargo-package-signal-hook-registry-1.4.0
/nix/store/rksf7mxzlsf00vyqhiaahb77drf727h2-cargo-package-hkdf-0.12.3
/nix/store/rlclyizazj193pyym3i52675qhhh21d8-cargo-package-hyper-0.14.20
/nix/store/rnrsjfb6r2zcvp90azxmhc0j6hbwj14l-cargo-package-time-0.1.44
/nix/store/rqa3d2zqc5jhx62ll327pm9l9phxgfkp-cargo-package-crypto-common-0.1.6
/nix/store/rrbirdbjxm3hivs1x66wdg6ffpqzfgx4-cargo-package-matches-0.1.9
/nix/store/sd0g4xa5y2ryp86i0ckmrpxcxhrhgypi-cargo-package-wasm-bindgen-0.2.82
/nix/store/vf92l1bbsa4hangmin35dznmhwrjs6lv-cargo-package-regex-syntax-0.6.27
/nix/store/vgkmpn5vvn6l99ghxgjkp5qz90alcl15-cargo-package-quote-1.0.21
/nix/store/w128k732blza1saglgqfa20d57f4p9j1-cargo-package-fnv-1.0.7
/nix/store/w7028a73i2sm2qvmgdr12x2qqh599fam-cargo-package-anyhow-1.0.61
/nix/store/wcz2c8n50crmnmgm8av3sx8gp8ai6r20-cargo-package-opentelemetry-otlp-0.10.0
/nix/store/wfbz1wp107wnkniiqv1vmq8qrx6pybzf-cargo-package-tracing-core-0.1.29
/nix/store/wjvn818ilnynx3xilgkdw79j26yapij4-cargo-package-minimal-lexical-0.2.1
/nix/store/wljkgmwin4cbsvgniwqwypkwji75vp5m-cargo-package-pathdiff-0.2.1
/nix/store/wlp1yh98l0kwpmnq1041l8asxjf1zwf0-cargo-package-base64-0.13.0
/nix/store/wnz2zv7qh50hadiz5xxg3pbpxjnlx62i-cargo-package-futures-core-0.3.21
/nix/store/wpy1bfbaj9zbbmrgsa9j7bh5cj7xaxcc-cargo-package-tracing-serde-0.1.3
/nix/store/ws7viiibzxvlv4k97v5p3bb8n33dnpiw-cargo-package-num_cpus-1.13.1
/nix/store/x0s280vs80h4bvdxs5ygfn9x58801f7d-cargo-package-rustls-pemfile-1.0.1
/nix/store/x0vcgs6ia2k8fxq97wnz152ag4rs8xsa-cargo-package-whoami-1.2.1
/nix/store/xbpb6pf98fpn7df3pyy7r78cxjdk41wa-cargo-package-petgraph-0.6.2
/nix/store/xfjgkhbzr2cszvl8pkywmd8yrsrg4d1p-cargo-package-tokio-io-timeout-1.2.0
/nix/store/xkww4ryksqbpa0zj08k7sp2wfqpk5crb-cargo-package-hashbrown-0.12.3
/nix/store/xnysj4rszdhpjip46rk2grd5kq8hv430-cargo-package-sct-0.6.1
/nix/store/xxv1cbz6ryxzwkyyfq8hakhm6fadbq0a-cargo-package-md-5-0.10.1
/nix/store/y523r7ww233y3bd3ha67gjqwi6ka3yy5-cargo-package-slab-0.4.7
/nix/store/y63vzdr13fyr1qxqi5zr29y6kcaqdsza-cargo-package-tokio-stream-0.1.9
/nix/store/yc32wdj7w7n8k0ipjy62f74v0r8yqql3-cargo-package-h2-0.3.13
/nix/store/yff36h95c136bqwmi6amsc2n5brzcc3m-cargo-package-heck-0.4.0
/nix/store/ykq47d0gdsc67ha0xvzk35b79d0qs0qx-cargo-package-event-listener-2.5.3
/nix/store/yn3pirkddz2lg8zdg7y3n6151a7czxm8-cargo-package-webpki-roots-0.22.4
/nix/store/yp3ad8g5pfslp7bxvfzvr09x668gmav3-cargo-package-log-0.4.17
/nix/store/ypj3sshn2fgx41mhpdlpm14lppi9iv5b-cargo-package-num-integer-0.1.45
/nix/store/yqyr5r0c3mkar1973x61qvc2swdjc9jw-cargo-package-form_urlencoded-1.0.1
/nix/store/yrazpg632l09dl3db4cknasl27ryxgzc-cargo-package-wasi-0.10.0+wasi-snapshot-preview1
/nix/store/yzkyzlkx7gwm61qf1krhqdlhqpljrqyd-cargo-package-serde_urlencoded-0.7.1
/nix/store/yzp4wn5kjry7qri1l2npkwr4jhaqdb26-cargo-package-itertools-0.10.3
/nix/store/z25a1634xiw0dd00rhwmnf5ywwynw3w6-cargo-package-stringprep-0.1.2
/nix/store/zdqw9cg4nj82crqdkwanni9vl5ky1cfj-cargo-package-crc-3.0.0
/nix/store/zfd46ycd7lhbb5ln611x0ircd9frr14a-cargo-package-valuable-0.1.0
/nix/store/zv1wjjgb9xgsy3ivqi1cfflmwb6cfqiw-cargo-package-chrono-0.4.22
/nix/store/zzkrs87x3a2n4d7x2jj3zrgij6p3w8vb-cargo-package-windows-sys-0.36.1
/nix/store/wnhmrwxwpy4ci6ndvkppm5z496hnx26i-vendor-registry
/nix/store/i4rbvnvy4s0k78hjbnfacsxf7xhbjsbm-vendor-cargo-deps
/nix/store/mii834bf617gfgzf2lrsilixc1q726ip-axum-rest-example-0.1.0
/nix/store/cah7gc1abrsagxyc5a1v00phf8znz990-axum-rest-example-conf.json
/nix/store/cki6zalbpin96q7k33a1s26ffmbqvr4r-xz-5.2.5
/nix/store/cvjizmvf7bml9a9ppcbl4gxc2y8smbai-bzip2-1.0.6.0.2
/nix/store/gidv7w43ilgj22g1mkd3b9if5h4k0xgv-readline-6.3p08
/nix/store/iffl6dlplhv22i2xy7n1w51a5r631kmi-bash-5.1-p16
/nix/store/n83qx7m848kg51lcjchwbkmlgdaxfckf-tzdata-2022a
/nix/store/nwf2y0nc48ybim56308cr5ccvwkabcqc-openssl-1.1.1q
/nix/store/q8gnp7r8475p52k9gmdzsrcddw5hirbn-gdbm-1.23
/nix/store/qvv10nni6ya53k9gvybyw10kh6c380f2-mailcap-2.1.53
/nix/store/v3j1blvixih1gd29l8j1mxaf3v26cn2w-libffi-3.4.2
/nix/store/v92pzd7ln3nyvqrz9dzzf8mcfh8xnisp-expat-2.4.8
/nix/store/xpwwghl72bb7f48m51amvqiv1l25pa01-python3-3.9.13
/nix/store/dv5wgy8129chfgwswjfz9nz6ivmkyblw-stream
/nix/store/93g9alqzh1gxfxzy6ahpqpwbky6jxizj-stream-axum-rest-example

Similarly, running nix build .#axum-rest-example && strings ./result/bin/axum-rest-example shows references to /nix/store/i4rbvnvy4s0k78hjbnfacsxf7xhbjsbm-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/... when it should instead contain strings to /sources/...

The current source prefix mapping sets the root of all directories which contains vendored sources, but apparently that isn't enough to make the remapping work, so we'll need to remap things multiple times

I keep getting my things recompiled (when using with lorri)

I'm trying crane out, to move from naersk. I've already created #24 , but I've noticed one issue that I'd like to report separately.

Whenever I switch between nix run .#, and getting devShell from lorri, I see that all the deps are getting recompiled. Can this be helped? Is it something about my flake.nix that invalidates the cache? Or is it just how crane works and it's meant to be used on in a CI, where no one will be getting dev shells?

Dummy source derivation relying on source when using flake's self argument as source

When using self over ./. for the source to buildPackage, the dummy source derivation relies on the source of the flake.

Good:

    "inputSrcs": [
      "/nix/store/xxx-default-builder.sh",
      "/nix/store/xxx-Cargo.lock"
    ],
    "inputDrvs": {
      "/nix/store/xxx-dummy.rs.drv": [
        "out"
      ],
      "/nix/store/xxx-Cargo.toml.drv": [
        "out"
      ],
      "/nix/store/xxx-stdenv-darwin.drv": [
        "out"
      ],
      "/nix/store/xxx-bash-5.1-p16.drv": [
        "out"
      ]
    },

Bad:

    "inputSrcs": [
      "/nix/store/xxx-default-builder.sh",
      "/nix/store/xxx-source"
    ],
    "inputDrvs": {
      "/nix/store/xxx-bash-5.1-p16.drv": [
        "out"
      ],
      "/nix/store/xxx-stdenv-linux.drv": [
        "out"
      ],
      "/nix/store/xxx-Cargo.toml.drv": [
        "out"
      ],
      "/nix/store/xxx-dummy.rs.drv": [
        "out"
      ]
    },

A reproduction is available at https://github.com/winterqt/crane-dummy-src-invalidation. This may be outside of Crane's control (as in, this may be an issue with how this attribute of flakes are implemented).

Update `cargoFmt` to copy cargo artifacts

Originally mentioned in #4

cargoFmt does not copy the cargo artifact directory to its output, which makes it impossible to sequentially chain derivations like shown in the README (e.g. enforce that rustfmt passes, then run clippy, etc.)

This line basically needs to be removed in favor of a default argument which defines doInstallCargoArtifacts ? true. This will ensure examples like this just work, but still allow the caller to turn off artifact copying if needed.

doInstallCargoArtifacts = false;

Way to build each workspace member as separate derivation

We have big cargo workspace with lot of crates depending on each other. Building whole workspace is ok while developing but in actual deploy we would like to build only crates which are used not the whole workspace.
Currently we are using crate2nix which can output each workspace member as separate derivation, can crane be used in this way ?

Thanks for working on this!

References to individual vendored crates aren't stripped out after installation

When running nix path-info -rsSh ./result on a Crane build artifact of a flake I'm working on, I'm getting this:-

/nix/store/gfqwbax0x58mjnh89ca6milx41bw49lr-libunistring-1.0                               1.7M    1.7M
/nix/store/9jqiw71lq60sdpiniywq3msknf3wmd9c-libidn2-2.3.2                                254.1K    2.0M
/nix/store/lxpdbaazqd2s79jx6lngr8nak2rjdaq1-glibc-2.34-210                                29.2M   31.2M
/nix/store/9js2mvj0xc7axi1nqs15941bdnm5pqmn-libressl-3.4.3                                 5.6M   36.8M
/nix/store/pnqyyr621w93zqb550q5889b1ri1qah5-gcc-11.3.0-lib                                 6.1M   37.3M
/nix/store/dirc4ldaniz9zmp324ksix5062i5aybk-foundationdb-6.1.13-lib                        6.5M   49.4M
/nix/store/yr2dlmvzdhzhcac0raiwy8wcmv4wg9s3-cargo-package-grpcio-sys-0.8.1                33.7M   33.7M
/nix/store/52vb94fbilh2mnkdfy6naw3q2k2i70gj-surreal-1.0.0-beta.7+20220923.42db149         28.8M  111.9M

The same command on an older Naersk branch with the same dependencies gives me:-

/nix/store/gfqwbax0x58mjnh89ca6milx41bw49lr-libunistring-1.0                               1.7M    1.7M
/nix/store/9jqiw71lq60sdpiniywq3msknf3wmd9c-libidn2-2.3.2                                254.1K    2.0M
/nix/store/lxpdbaazqd2s79jx6lngr8nak2rjdaq1-glibc-2.34-210                                29.2M   31.2M
/nix/store/9js2mvj0xc7axi1nqs15941bdnm5pqmn-libressl-3.4.3                                 5.6M   36.8M
/nix/store/pnqyyr621w93zqb550q5889b1ri1qah5-gcc-11.3.0-lib                                 6.1M   37.3M
/nix/store/dirc4ldaniz9zmp324ksix5062i5aybk-foundationdb-6.1.13-lib                        6.5M   49.4M
/nix/store/knl8qnm4z362hhl031fnk2wyb0dvr5jk-surreal-1.0.0-beta.7+20220922.aaf81d2         28.7M   78.2M

Notice the extra line in Crane output:-

/nix/store/yr2dlmvzdhzhcac0raiwy8wcmv4wg9s3-cargo-package-grpcio-sys-0.8.1                33.7M   33.7M

I tried both doInstallCargoArtifacts = false and RUSTFLAGS = "-Clink-arg=-fuse-ld=lld" to get rid of it but that didn't help.

nix why-depends shows that the binary is depending on it directly:-

$ nix why-depends ./result /nix/store/yr2dlmvzdhzhcac0raiwy8wcmv4wg9s3-cargo-package-grpcio-sys-0.8.1
/nix/store/52vb94fbilh2mnkdfy6naw3q2k2i70gj-surreal-1.0.0-beta.7+20220923.42db149
└───/nix/store/yr2dlmvzdhzhcac0raiwy8wcmv4wg9s3-cargo-package-grpcio-sys-0.8.1

I care about the closure size because one of the outputs of this flake is a Docker image.

error: attribute 'groupBy' missing

Hi,

I just git cloned the current top-of-tree, and when I try to build the example in examples/quick-start, I see this

[mcgibbon@pn50:~/projects/crane/examples/quick-start]$ nix build -L --show-trace
warning: Git tree '/home/mcgibbon/projects/crane' is dirty
error: attribute 'groupBy' missing

       at /nix/store/x3pcqh8n41lwzwk4r245l3fb60dgwc63-source/lib/vendorCargoRegistries.nix:10:4:

            9| }:
           10| let
             |    ^
           11|   inherit (builtins)

       … while evaluating 'mapAttrs''

       at /nix/store/jkdijyvqw24byf8k8l1slc4h7dj8hzas-source/lib/attrsets.nix:242:18:

          241|   */
          242|   mapAttrs' = f: set:
             |                  ^
          243|     listToAttrs (map (attr: f attr set.${attr}) (attrNames set));

       … from call site

       at /nix/store/x3pcqh8n41lwzwk4r245l3fb60dgwc63-source/lib/vendorCargoRegistries.nix:61:13:

           60|
           61|   sources = mapAttrs'
             |             ^
           62|     (url: packages: nameValuePair (hash url) (vendorSingleRegistry packages))

       … while evaluating 'concatMapStrings'

       at /nix/store/jkdijyvqw24byf8k8l1slc4h7dj8hzas-source/lib/strings.nix:53:25:

           52|   */
           53|   concatMapStrings = f: list: concatStrings (map f list);
             |                         ^
           54|

       … from call site

       at /nix/store/x3pcqh8n41lwzwk4r245l3fb60dgwc63-source/lib/vendorCargoRegistries.nix:65:24:

           64|
           65|   configLocalSources = concatMapStrings
             |                        ^
           66|     (hashedUrl: ''

       … while evaluating the attribute 'config'

       at /nix/store/x3pcqh8n41lwzwk4r245l3fb60dgwc63-source/lib/vendorCargoRegistries.nix:102:3:

          101|
          102|   config = configLocalSources + (concatStrings configReplaceRegistries);
             |   ^
          103| }

       … while evaluating the attribute 'buildCommand' of the derivation 'vendor-cargo-deps'

       at /nix/store/jkdijyvqw24byf8k8l1slc4h7dj8hzas-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let

       … while evaluating the attribute 'cargoVendorDir' of the derivation 'quick-start-deps-0.1.0'

       at /nix/store/jkdijyvqw24byf8k8l1slc4h7dj8hzas-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let

       … while evaluating the attribute 'cargoArtifacts' of the derivation 'quick-start-0.1.0'

       at /nix/store/jkdijyvqw24byf8k8l1slc4h7dj8hzas-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

          204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          205|       name =
             |       ^
          206|         let

redbpf / cargo bpf?

Absolutely love the project, this is one of the most ergonomic Rust nix flakes integrations I've seen so far.

I have a project where I'd like to use https://github.com/foniod/redbpf, which provides its own setup using a Cargo subcommand it provides called cargo bpf.

What would be the 'right' way to use this with crane?

Consider defining `cargoTest`

Rather than running cargo test inside of cargoBuild, consider moving the invocation to a dedicated command. That way other wrappers don't need to mess around with disabling doCheck and having cargo test be invoked.

Note that buildPackage should still implicitly run cargo test as most workspaces will want to build/test in one easy derivation.

Originally suggested here

Access to path error in `mkDummySrc`

Hello, thanks for this great library! I'm implementing crane as a builder for https://github.com/nix-community/dream2nix, and I ran into an issue. Essentially I call buildDepsOnly and then use it in cargoBuild, but this doesn't seem to work because Nix complains about error: access to absolute path '/Cargo.toml' is forbidden in pure eval mode (use '--impure' to override). I'm not sure why it's trying to access there, but this happens in the dummy source creation.

https://github.com/nix-community/dream2nix/blob/1c4b8aaa52e1e9572f590f2fdb099aeaf1734084/src/builders/rust/crane/default.nix#L32-L48 is where i use builldDepsOnly.

You can reproduce this with this flake:

{
  inputs.dream2nix.url = "github:yusdacra/dream2nix/rust/crane-builder";
  inputs.ripgrep = { flake = false; url = "github:BurntSushi/ripgrep/13.0.0"; };
  outputs = { self, nixpkgs, dream2nix, ripgrep }@inputs:
    let
      # change according to your system
      system = "x86_64-linux";
      dream2nix = inputs.dream2nix.lib.init {
        pkgs = nixpkgs.legacyPackages."${system}";
      };
    in
    {
      packages = (dream2nix.riseAndShine {
        source = ripgrep;
      }).packages;
    };
}

mkDummySrc doesn't behave well with manually filtered source

Using the following source filter as the argument to crane.buildPackage:

lib.cleanSourceWith {
  inherit src;
  filter = path: type: lib.hasPrefix "Cargo" (builtins.baseNameOf path) || type == "directory";
}

results in the generated dummy source only containing Cargo.toml.

I don't see anything in mkDummySrc that would be causing this behavior, and my filter is sane (I manually tested to make sure it contains both Cargo.toml and Cargo.lock). My Crane input is at 223aaed. I've also confirmed that the given source works when not filtering.

buildDepsOnly for #![no_std]

buildDepsOnly creates a blank src/lib.rs with mkDummySrc. This will fail to compile for #![no_std] targets such as thumbv7em-none-eabi because of the absence of a panic handler.

My workaround is to add sed -i '1s/^/#![no_std]/' src/lib.rs to the top of buildPhaseCargoCommand. A full example of this is avaliable here.

This works, but I wish it was more elegant:

  • Should #![no_std] targets be supported in crane? I am not sure if this is within the scope of crane.
  • If this is in scope, how should this be implemented? There are many possible solutions, I would be interested to hear your ideas!

Dry run evaluation fails with filtered source

Running nix flake check --no-build on a flake that hasn't been built before (which is usually the case in CI) results in an error message like:-

error: path '/nix/store/wkg1fvrldw8kg05vjwqz4vc5g5r878sl-source' is not valid

when using cleanCargoSource. You can see a full backtrace here.

Refactor `cargoBuild` to not run tests

cargoBuild should be made simpler by not running any tests by default (since callers can use cargoTest if they want to run tests).

buildPackage should be updated to directly run the tests in its own checkPhase; it should also probably delegate directly to mkCargoDerivation

Follow up of #131 and related to #132

'error: Cannot find Git revision' with a branch

Maybe related to ref 'master' not matching test-override.

[dependencies]
chrono = { git = "https://github.com/bryanburgers/chrono", branch = "test-override", features = ["test-override", "serde"] }
error: Cannot find Git revision 'ffe62991c757de0877a53ec0d5aa30d597b7f24a' in ref 'master' of repository 'https://github.com/bryanburgers/chrono'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.
(use '--show-trace' to show detailed location information)

[Help] Cannot build crate with PyO3 dependency

I am trying to use crane to build the minimum rust-from-python example that PyO3 provides. My flake.nix is as follows:

{
  description = "Build a cargo project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    crane = {
      url = "github:ipetkov/crane";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, crane, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };

        craneLib = crane.lib.${system};
        src = ./.;

        # Build *just* the cargo dependencies, so we can reuse
        # all of that work (e.g. via cachix) when running in CI
        cargoArtifacts = craneLib.buildDepsOnly {
          inherit src;
          buildInputs = with pkgs; [
            python3
          ];
        };

        # Build the actual crate itself, reusing the dependency
        # artifacts from above.
        py-test = craneLib.buildPackage {
          inherit cargoArtifacts src;
        };
      in
      {
        checks = {
          # Build the crate as part of `nix flake check` for convenience
          inherit py-test;

          # Run clippy (and deny all warnings) on the crate source,
          # again, resuing the dependency artifacts from above.
          #
          # Note that this is done as a separate derivation so that
          # we can block the CI if there are issues here, but not
          # prevent downstream consumers from building our crate by itself.
          py-test-clippy = craneLib.cargoClippy {
            inherit cargoArtifacts src;
            cargoClippyExtraArgs = "-- --deny warnings";
          };

          # Check formatting
          py-test-fmt = craneLib.cargoFmt {
            inherit src;
          };

          # Check code coverage (note: this will not upload coverage anywhere)
          py-test-coverage = craneLib.cargoTarpaulin {
            inherit cargoArtifacts src;
          };
        };

        packages.default = py-test;

        apps.default = flake-utils.lib.mkApp {
          drv = py-test;
        };

        devShell = pkgs.mkShell {
          inputsFrom = builtins.attrValues self.checks;

          # Extra inputs can be added here
          nativeBuildInputs = with pkgs; [
            cargo
            rustc
          ];
        };
      });
}

I'm seeing the following error from nix flake check:

nix log /nix/store/zwsin4kixagiagfbbhn6mzm8cv1amfbz-py_test-0.1.0.drv
warning: executing SQLite statement '

         create table if not exists BinaryCaches (
             id        integer primary key autoincrement not null,
             url       text unique not null,
             timestamp integer not null,
             storeDir  text not null,
             wantMassQuery integer not null,
             priority  integer not null
         );

         create table if not exists NARs (
             cache            integer not null,
             hashPart         text not null,
             namePart         text,
             url              text,
             compression      text,
             fileHash         text,
             fileSize         integer,
             narHash          text,
             narSize          integer,
             refs             text,
             deriver          text,
             sigs             text,
             ca               text,
             timestamp        integer not null,
             present          integer not null,
             primary key (cache, hashPart),
             foreign key (cache) references BinaryCaches(id) on delete cascade
         );

         create table if not exists Realisations (
             cache integer not null,
             outputId text not null,
             content blob, -- Json serialisation of the realisation, or null if the realisation is absent
             timestamp        integer not null,
             primary key (cache, outputId),
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/drqs8ifw3kkxbai97ffnddnci3fg9cls-wpzzlw9mr6dy3q1zbv25rq8ybhn3byai-source
source root is wpzzlw9mr6dy3q1zbv25rq8ybhn3byai-source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
Executing configureCargoCommonVars
copying cargo artifacts from /nix/store/sfv5k81mca8l6acyqqsqimalrk177561-py_test-deps-0.1.0/target.tar.zst to target
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
will append /build/wpzzlw9mr6dy3q1zbv25rq8ybhn3byai-source/.cargo-home/config.toml with contents of /nix/store/dp4xq7rviwv7ih8nlv8lhy3grr1fhlyb-vend>
no configure script, doing nothing
setting CARGO_BUILD_RUSTFLAGS to "--remap-path-prefix /nix/store/dp4xq7rviwv7ih8nlv8lhy3grr1fhlyb-vendor-cargo-deps=/sources"
@nix { "action": "setPhase", "phase": "buildPhase" }
building
cargo 1.60.0
running: cargoBuildLog=$(mktemp cargoBuildLogXXXX.json)
cargo build --workspace --release --message-format json-render-diagnostics  >"$cargoBuildLog"

   Compiling pyo3-build-config v0.16.4
error: failed to run custom build command for `pyo3-build-config v0.16.4`

Caused by:
  process didn't exit successfully: `/build/wpzzlw9mr6dy3q1zbv25rq8ybhn3byai-source/target/release/build/pyo3-build-config-d9d1048ee5e4183e/build-sc>
  --- stdout
  cargo:rerun-if-env-changed=PYO3_CONFIG_FILE
  cargo:rerun-if-env-changed=PYO3_NO_PYTHON
  cargo:rerun-if-env-changed=PYO3_PYTHON
  cargo:rerun-if-env-changed=VIRTUAL_ENV
  cargo:rerun-if-env-changed=CONDA_PREFIX
  cargo:rerun-if-env-changed=PATH

  --- stderr
  error: no Python 3.x interpreter found

What I expect is happening is that PyO3 is not detecting the Python version. I have considered potentially using the PyO3 pyo3-build-config.txt, but wanted to ask here for your thoughts first.

Can't build workspace dependency from git repo with relative path references in Cargo.toml

I'm trying to use crane to build a package dependent on on polkadot-runtime which is included in https://github.com/paritytech/polkadot/ repo and depends on several packages available in the same workspace.

From runtime/polkadot/Cargo.toml:

xcm = { package = "xcm", path = "../../xcm", default-features = false }
xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false }
xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false }

This presents a problem when, while building package dependencies, crane calls downloadCargoPackageFromGit to create a flat directory source containing all crates found in the git repo:

runCommandLocal "cargo-git" deps ''
  mkdir -p $out
  while read -r cargoToml; do
    local crate=$(toml2json <"$cargoToml" | \
      jq -r 'select(.package != null) | .package | "\(.name)-\(.version)"'
    )
    if [ -n "$crate" ]; then
      local dest="$out/$crate"
      cp -r "$(dirname "$cargoToml")" "$dest"
      chmod +w "$dest"
      echo '{"files":{}, "package":null}' > "$dest/.cargo-checksum.json"
    fi
  done < <(find ${repo} -name Cargo.toml)
''

Because the directory source does not reflect the structure of the original repository, create will not be able to resolve dependencies specified as relative paths, which in the following error when trying to build crate that depends on one of the workspace packages fetched from git:

error: failed to get `pallet-xcm` as a dependency of package `polkadot-runtime v0.9.24 (/nix/store/96wd59czjxqc7h7hka0mzl8a6qi7ld45-vendor-cargo-deps/fee86dd00aa0134a06a01f9b456af966945d77ffcf28dceb39cbd32320835532/polkadot-runtime-0.9.24)`
  ... which satisfies path dependency `wasm-project` of package `polkadot-runtime-wasm v1.0.0 (/build/dummy-src/target/release/wbuild/polkadot-runtime)`

Caused by:
failed to load source for dependency `pallet-xcm`

Caused by:
Unable to update /nix/store/96wd59czjxqc7h7hka0mzl8a6qi7ld45-vendor-cargo-deps/xcm/pallet-xcm

Caused by:
failed to read `/nix/store/96wd59czjxqc7h7hka0mzl8a6qi7ld45-vendor-cargo-deps/xcm/pallet-xcm/Cargo.toml`

Caused by:
No such file or directory (os error 2)

I hope this information is enough to identify the problem, but I can also draft a minimal reproducible example if it helps.

I have only brief familiarity with rust toolchain and development, but I'd happy to follow up on my diagnosis with a solution if you would point me in the right direction.

Thanks.

Build scripts may not play nicely with dummy sources

Discussed in #115

Seems like cargo may be looking at the timestamp of the build script (or at the timestamp of the artifacts) to determine when it is being run. Since nix strips out the timestamps, cargo may not be (re)running the actual build script with the real files.

One potential solution is to make the dummy build script have a unique name (i.e. not build.rs and not whatever build script the Cargo.toml file may set), though I'm not sure what implications this may have on build artifact caching, if any

Build failed myseriously

https://github.com/fedimint/fedimint/runs/7846262690?check_suite_focus=true

fedimint/fedimint@ba9c4d9

cargo-package> ++ command cargo --version
cargo-package> cargo 1.64.0-nightly (85b500cca 2022-07-24)
cargo-package> error: failed to get `bls12_381` as a dependency of package `tbs v0.1.0 (/build/source/crypto/tbs)`
cargo-package> Caused by:
cargo-package>   failed to load source for dependency `bls12_381`
cargo-package> Caused by:
cargo-package>   Unable to update registry `crates-io`
cargo-package> Caused by:
cargo-package>   failed to update replaced source registry `crates-io`
cargo-package> Caused by:
cargo-package>   failed to parse manifest at `/nix/store/j72f39qsvkndpyiy69xlbn23gk0ay11n-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/librocksdb-sys-0.8.0+7.4.4/Cargo.toml`
cargo-package> Caused by:
cargo-package>   optional dependency features with `?` syntax are only allowed on the nightly channel and requires the `-Z weak-dep-features` flag on the command line
cargo-package>   Feature `static` had feature value `libz-sys?/static`.
error: builder for '/nix/store/16lid7j0ljyl2y804i2alr9zy0n4n3jz-cargo-package-0.0.1.drv' failed with exit code 101;
       last 10 log lines:
       >
       > Caused by:
       >   failed to update replaced source registry `crates-io`
       >
       > Caused by:
       >   failed to parse manifest at `/nix/store/j72f39qsvkndpyiy69xlbn23gk0ay11n-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/librocksdb-sys-0.8.0+7.4.4/Cargo.toml`
       >
       > Caused by:
       >   optional dependency features with `?` syntax are only allowed on the nightly channel and requires the `-Z weak-dep-features` flag on the command line
       >   Feature `static` had feature value `libz-sys?/static`.
       For full logs, run 'nix log /nix/store/16lid7j0ljyl2y804i2alr9zy0n4n3jz-cargo-package-0.0.1.drv'.

Handling source-adjacent packages?

Do you have any advice on how to handle the situation of "a source control repo that contains a library package at the repo root + multiple binary packages in subdirectories", where the binary packages depend on crates defined in the library package, often referenced via relative paths in Cargo.toml?

(Here, I am specifically interested in using crane to write a flake that exposes outputs for the binary packages -- e.g., a web server, a wasm frontend, and some platform-specific GUI clients.)

Thanks! (and thanks also for writing and publishing crane; it looks like a lovely addition to the nix + rust ecosystem!)

Something is printing wget output

While introducing flake.nix using crane to another project (and thus updating flake which updates crane) I noticed wget output when doing nix build -L ...

Screenshot from 2022-08-27 23-01-30

cargoAudit ignores audit.toml

I'd like to use cargo-audit, however without being able to specify an audit.toml I am not able to use crane to do the auditing.

I could not find a way to specify an audit.toml. Is this already possible?

Undocumented(?) edge cases updating Cargo.toml / Cargo.lock

Hi. I'm using https://github.com/rust-lang/mdBook and https://github.com/daviddrysdale/mdbook-indexing on a project, and wanted to build newer versions because of both 1) bugfixes and 2) nixpkgs seemed to have mismatching versions.

So mdbook has this slightly cumbersome design where preprocessors are supposed to be built against the version of mdbook that actually calls them (as subprocesses).

So, I'm looking at mdbook-indexing and trying to bump its dependencies to mdbook = 0.4.21. This is a "user confusion report", where I think crane is at least missing documentation, and might actually want to do things differently with regard to Cargo.lock.

mdbook-indexing commit e8e8cde3aabc1db3a83fd20d29dc827f0bdfbcd7 has

Cargo.toml: mdbook = "0.4.*"

https://github.com/daviddrysdale/mdbook-indexing/blob/e8e8cde3aabc1db3a83fd20d29dc827f0bdfbcd7/Cargo.toml#L17

Cargo.lock: name = "mdbook"; version = "0.4.18"

https://github.com/daviddrysdale/mdbook-indexing/blob/e8e8cde3aabc1db3a83fd20d29dc827f0bdfbcd7/Cargo.lock#L801-L803

What I wanted to make happen is essentially cargo update -p mdbook --precise 0.4.21 in mdbook-indexing source tree, and then build that.

Attempt 1: clone mdbook-indexing, cargo update -p mdbook --precise 0.4.21, update mdbook dependency, make a patch containing Cargo.lock change, add to crane.lib.${system}.buildPackage { ...; patches = [ ... ] }. Building that made cargo complain:

++ command cargo check --profile release --all-targets
error: failed to select a version for the requirement `mdbook = "0.4.*"`
candidate versions found which didn't match: 0.4.18

The error message is slightly misleading, since both 0.4.18 and 0.4.21 would match that wildcard.
What I think is happening here is that crane is only offering mdbook v0.4.18 to cargo, and cargo is saying that lock file told it to use 0.4.21, which wasn't available -- and failing to include the relevant detail.

Attempt 2: same as above, but also patch Cargo.toml to have mdbook = 0.4.21. Didn't help, same error except for error: failed to select a version for the requirement mdbook = "^0.4.21"``

Attempt 3: pass updated Cargo.lock file via cargoLock. This might be broken due to the wildcard dependency use in mdbook-indexing, and not be crane's fault at all. Wildcards are pretty rare, I've never seen them in any project. Anyway:

crane.lib.${system}.buildPackage {
            src = inputs.mdbook-indexing;
            cargoLock = ./mdbook-indexing-cargo-lock-with-mdbook-0_4_21.toml;
};
++ command cargo build --profile release --message-format json-render-diagnostics
error: failed to select a version for the requirement `mdbook = "0.4.*"`
candidate versions found which didn't match: 0.4.21

Attempt 4: Patch Cargo.toml to remove wildcard, pass Cargo.lock via cargoLock -- WORKS

crane.lib.${system}.buildPackage {
            src = inputs.mdbook-indexing;
            patches = [
              # changes Cargo.toml to say `mdbook = "0.4.21"`
              ./mdbook-indexing-e8e8cd-depend-mdbook-0_4_21.patch
            ];
            cargoLock = ./mdbook-indexing-cargo-lock-with-mdbook-0_4_21.toml;
};

I felt like this was quite unintuitive.

I would have expected crane to pick up Cargo.lock after patches.

Different toolchain in buildPhase and in installPhase?

A picture says more than a thousand words, I guess:

photo_2022-10-06_19-21-30

Why is a different cargo version used in the installPhase?

The relevant parts from my flake look like this:

{
        pkgs = import nixpkgs {                                                                                                                                                                                                                                                                                                
          inherit system;                                                                                                                                                                                                                                                                                                      
          overlays = [ (import rust-overlay) ];                                                                                                                                                                                                                                                                                
        };                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                               
        rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;                                                                                                                                                                                                                                              
        craneLib = (crane.mkLib pkgs).overrideToolchain rustTarget;                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                               
        tomlInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; };                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                               
        cargoArtifacts = craneLib.buildDepsOnly {                                                                                                                                                                                                                                                                              
          src = craneLib.cleanCargoSource ./.;                                                                                                                                                                                                                                                                                 
          buildInputs = [                                                                                                                                                                                                                                                                                                      
            pkgs.pkg-config                                                                                                                                                                                                                                                                                                    
            pkgs.openssl                                                                                                                                                                                                                                                                                                       
            pkgs.cmake                                                                                                                                                                                                                                                                                                         
          ];                                                                                                                                                                                                                                                                                                                   
        };                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                               
        commonArgs = {                                                                                                                                                                                                                                                                                                         
          inherit (tomlInfo) pname version;                                                                                                                                                                                                                                                                                    
          inherit cargoArtifacts;                                                                                                                                                                                                                                                                                              
          src = ./.;                                                                                                                                                                                                                                                                                                           
        };                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                               
        package = craneLib.buildPackage (commonArgs // {                                                                                                                                                                                                                                                             
          doCheck = false;                                                                                                                                                                                                                                                                                                     
        }); 
}

Hope you can help me here with the relatively little info I can give you 💭

How to handle dependencies?

If I have a crate which depends on some system library (i.e. I have a buildInput), how should I tell crane to include that dependency in the closure?

Likewise, if I depend on some tool at build time (i.e. I have a nativeBuildInput) to run a build.rs script, where do I specify that?

The 'quick-start' example fails to flake check due to cargo-tarpaulin not being supported on 'aarch64-linux'

I've followed the example of nix flake init -t github:ipetkov/crane#quick-start and then do a nix flake check to test it out. However it fails with this error:

error: Package ‘cargo-tarpaulin-0.20.0’ in /nix/store/k2ifqlyrcv3sa4py1fk4cifdgba5ch86-source/pkgs/development/tools/analysis/cargo-tarpaulin/default.nix:25 is not supported on ‘aarch64-linux’, refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

        Note: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
        (Flake) command, `--impure` must be passed in order to read this
        environment variable.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information)

Target saved into `$out` even when

I have a test that I run with buildPackage like: https://github.com/fedimint/fedimint/blob/41ace18a67e1131f146b8aa9ed117f245b9fe275/flake.nix#L170

Documentation for buildPackage says that doInstallCargoArtifacts is disabled for it by default https://github.com/ipetkov/crane/blob/master/docs/API.md#optional-attributes-1

Yet the output contains heavy target.tar.zst. Am I confused or something is not working like it should?

[I] dpc@futex:~/l/minimint
> nix build .#cli-test.rust-tests --print-out-paths
/nix/store/9mhviiwwc3a73ifvbszwjxn0mawpy2bq-cargo-package-0.0.1
[I] dpc@futex:~/l/minimint
> ls -alh /nix/store/9mhviiwwc3a73ifvbszwjxn0mawpy2bq-cargo-package-0.0.1
total 443M
dr-xr-xr-x 1 root root     28 Dec 31  1969 .
drwxrwxr-t 1 root nixbld  27M Aug 12 19:57 ..
-r--r--r-- 1 root root   443M Dec 31  1969 target.tar.zst

Add ability to customize compression level.

As transfers times are often the bottleneck, would be nice if it was possible to pass custom arguments to zstd compression (like -19 or even -U -30) and trade compute for storage space.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.