crate2nix
crate2nix copied to clipboard
Scope of crate2nix and future of rusty nix
I think it makes sense to think about the goals of crate2nix
and the other two projects providing nix build support to rust. Then we can maybe converge or find at least topics to collaborate on. And we can help nix/rust users choose the best solution for their projects.
This is WIP, feel free to discuss. Obviously, these are goals
Core goals and features:
- Generates nix derivations for rust binaries and libraries that have crate cache granularity.
- Convenient to use.
- Stable interface. Both the CLI and the generated build files should not have random interface changes. Support the old interface in new versions, at least for a while, if offering new interfaces.
- Stable implementation. Strong regression tests so that new releases don't break what already worked.
- Works in fully sandboxed mode.
- Convenient "import-from-derivation" support which allows not to check in the generated "Cargo.nix" file. See https://github.com/kolloch/crate2nix/issues/110, https://github.com/kolloch/crate2nix/issues/101
- Support for selecting features at eval time (and not only at generation time).
- Good support of nixpkgs target platforms Linux and Mac OS.
Developer convenience:
- Good testing support (
cargo test
). - Good nix-shell support. See https://github.com/kolloch/crate2nix/issues/111
- Support for git sources with sub modules.
- Support bigger workspaces and collaboration. That deserves examples:
-
crate2nix
currently stores hashes of prefetched sources incrate-hashes.json
. If this is checked in, this can lead to merge conflicts. Therefore, I propose a change that prevents this: https://github.com/kolloch/crate2nix/issues/82 - If
crate2nix
or evaluating the generated build file takes too long, that's worth some optimizations even if that increases code complexity.
-
- Fast debug builds.
Packaging features:
- Convenient support for
out-of-tree
builds alanixpkgs
where the root crate/worksapce is fetched. See https://github.com/kolloch/crate2nix/issues/102 - Works out-of-the box for all common open source crates if they are not too crazy (e.g. make building in a sandbox deliberately difficult). This can be achieved by making
buildRustCrate
andcrate2nix
better or by getting appropriate pull requests merged. - Make the output reasonably small.
Cross building (currently no support at all):
- WASM build support.
- Cross builds e.g. for Windows. Might be difficult, I don't know.
Out of scope:
- Convenient, non-sandboxed builds.