nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
352 stars 83 forks source link

Bump deps, use cargo_platform to avoid vendored code #202

Closed Ericson2314 closed 2 years ago

Ericson2314 commented 3 years ago

The git dep is used for cargo_metadata to align the semver versions. https://github.com/oli-obk/cargo_metadata/issues/164 tracks that and it is supposed to be resolved soon.


bug fix in second commit:

Use Cargo platform's Platform in our ResolvedDerivation

Furthermore, instead of manually converting to a string, we simply let the default Serde deserializers do their job.

I am a bit peeved to say this actually fixed my bug where

[target.'cfg(unix)'.dependencies]

dependencies such as 1 and 2 where being silently dropped from the cargo metadata input into Cargo.nix. cfg_to_nix_expr_filter does its job making a nice error. I can't believe Tera would just throw it away silently by default.

Sorry to rant, but this is not the first time I am have burned by templating engines and their sloppy and untreated treatment of the "context" they render. If we just concatenated strings on the Rust side, we would never need to serialize-deserialize the Platform type in the first place, because we would be writing in a decent programming language not a templating hack-job. We should just convert it straight to Nix.

I am tempted to take crate2nix in that direction.

Ericson2314 commented 3 years ago

OK Hmm I am wrong. It works when run it in crate2nix's nix shell, it doesn't. After more testing, the difference still holds even if I clear the path in the shell and use the nix-built version rather than cargo run. Weird!

Ericson2314 commented 3 years ago

@nagisa if you are curious, here is where I have been bumbling about that issue.