yusdacra / nix-cargo-integration

Library to easily and effortlessly integrate Cargo projects with Nix.
https://flake.parts/options/nix-cargo-integration.html
MIT License
174 stars 19 forks source link

`[patch.crates-io]` with local crate fails #154

Open pJunger opened 2 weeks ago

pJunger commented 2 weeks ago

Patching the simple-workspace example to replace a crates dependency with an local crate leads to problems when building the dependencies.

Content of the build directory:

nix-build-my-crate-deps-0.1.0.drv-0
├── env-vars
├── nix-vendor
│   ├── hermit-abi-0.3.9
│   │   ├── ...
│   └── num_cpus-1.16.0    # has dependency to libc
│       ├── ...
└── simple-workspace
    ├── Cargo.lock
    ├── Cargo.toml
    ├── libc    # is found by nix but is empty
    │   ├── Cargo.toml
    │   └── src
    │       ├── bin    # dummy main.rs
    │       └── lib.rs    # dummy
    ├── my-crate
    │   ├── ...
    ├── my-other-crate
    │   ├── ...
    └── target
        ├── ...

Is there any way to fix the dependency chain? Excluding the crate from the workspace does not change anything, it still seems to show up as empty in the simple-workspace directory instead of the nix-vendor directory.

yusdacra commented 2 weeks ago

Can you verify if this happens with the latest version of https://github.com/ipetkov/crane ? I'm guessing it works fine there, and it's that dream2nix currently just uses an old version of crane (v0.15.0 to be exact) and that's why this doesn't work.

pJunger commented 2 weeks ago

Had to adapt the interface (for mkDummySrc & writeTOML starting with v0.16.1), but the same error occurs with newer versions.

yusdacra commented 1 week ago

We just discard any path crates here https://github.com/nix-community/dream2nix/blob/main/modules/dream2nix/rust-crane/vendor.nix#L116 while vendoring so that maybe the reason. Probably have to cross check with patch.crates-io and allow vendoring for it if it does exist there?