crate2nix
crate2nix copied to clipboard
IFD does not work with git deps
With the following nix derivation:
((pkgs.callPackage "${crate2nix}/tools.nix" { }).generatedCargoNix {
name = "proj";
# Filter src to avoid it being too large - keep Cargo.toml/Cargo.lock and lib.rs/main.rs
src = lib.fileset.toSource {
root = ../..;
fileset = lib.fileset.fromSource (lib.cleanSourceWith {
src = ../..;
filter = path: type: (
let baseName = baseNameOf (toString path);
in
(
(type == "directory" && baseName != "target" && baseName != "node_modules")
|| (baseName == "Cargo.toml" || baseName == "Cargo.lock" || baseName == "lib.rs" || baseName == "main.rs")
) && (lib.cleanSourceFilter path type) # + other basic filters
);
});
};
cargoToml = ".cargo/workspace/Cargo.toml";
})
Building leads to the following error (truncated with hopefully only relevant information):
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/dgd0qsj7p8s8aid2mkm09ynlxl4f9x6d-source
source root is source
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
++ crate2nix generate -f ./.cargo/workspace/Cargo.toml -o Cargo-generated.nix -h /nix/store/80m9cr7lmpsrxh79ql70iz763r6xs90j-proj-crate2nix/crate-hashes.json
Error: while retrieving metadata about ./.cargo/workspace/Cargo.toml: `cargo metadata` exited with an error: error: no matching package named `lightgbm-sys` found
location searched: https://github.com/Ten0/lightgbm-rs.git?branch=for_proj_main#ebc52622
required by package `lightgbm v0.2.3 (https://github.com/Ten0/lightgbm-rs.git?branch=for_proj_main#ebc52622)`
... which satisfies git dependency `lightgbm` (locked to 0.2.3) of package `p1 v1.0.0 (/build/source/p2/lib/p1)`
... which satisfies path dependency `p1` (locked to 1.0.0) of package `p2 v1.0.0 (/build/source/p2/Service)`
crate2nix failed.
== cargo/config (BEGIN)
[source.crates-io]
replace-with = "vendored-sources"
[source."https://github.com/Ten0/lightgbm-rs.git?branch=for_proj_main#ebc5262299d75cc770e21416f9e3ef8204427fba"]
git = "https://github.com/Ten0/lightgbm-rs.git"
branch = "for_proj_main"
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "/nix/store/zg0br63gy3b9r67kkfzsjqzxwz79vqwk-deps"
== cargo/config (END)
== crate-hashes.json (BEGIN)
{
"lightgbm 0.2.3 (git+https://github.com/Ten0/lightgbm-rs.git?branch=for_proj_main#ebc5262299d75cc770e21416f9e3ef8204427fba)": "0nr42asw4sg7q7xrkg565ivl1s9b6g75kflzy9hvl3srqrnxf10z",
"lightgbm-sys 0.3.0 (git+https://github.com/Ten0/lightgbm-rs.git?branch=for_proj_main#ebc5262299d75cc770e21416f9e3ef8204427fba)": "0nr42asw4sg7q7xrkg565ivl1s9b6g75kflzy9hvl3srqrnxf10z"
}
== crate-hashes.json (END)
== ls -la (BEGIN)
total 24
drwxr-xr-x 24 nixbld nixbld 4096 Jan 1 1970 .
drwx------ 3 nixbld nixbld 36 May 1 22:54 ..
drwxr-xr-x 3 nixbld nixbld 23 Jan 1 1970 .cargo
drwxr-xr-x 12 nixbld nixbld 173 Jan 1 1970 p2
== ls -la (END)
Contents of /nix/store/zg0br63gy3b9r67kkfzsjqzxwz79vqwk-deps
:
> cd /nix/store/zg0br63gy3b9r67kkfzsjqzxwz79vqwk-deps
> find . -maxdepth 1 -name "*lightgbm*"
./hway6s5x02wwvd7jqcqikvb8gw4zmsls-lightgbm-sys-0.3.0
./j7yyjdxmv1vfk77b7a7s30rqliq8rm0k-lightgbm-0.2.3
If I do generate Cargo.nix manually via nix run github:nix-community/crate2nix -- generate -f .cargo/workspace/Cargo.toml
and import that instead, it works.
Thanks for your help.