Author here. Feel free to ask any questions.
carnix did not work for my personal projects and after failing to fix it, I created crate2nix.
For me, it is also a personal goal for this year to publish software and/or blog articles. Despite of or because of being an experienced professional software developer, this has been difficult for me: I always think that I should be able to do better. So, publishing this in an early but useful state is already a medium-sized triumph for me :)
The README states that crate2nix only works on Linux. But after replacing nixos-unstable in the shell.nix of crate2nix and replacing nixos in the generated default.nix file, it seems to work fine in macOS.
It doesn’t seem to work correctly in a directory that is a Cargo workspace.
Keep up the good work!
Thanks a lot!
platform support: nice to know! for the generated files, it still filters all dependencies restricted to a target config to Linux. if you don’t have Linux specific targets, that’s fine, of course. I did this because some obscure fuchsia, windows libs broke my build.
true: I should mention it in the restrictions. it should also be easy to do better.
feel very free to file bugs for dependencies that break the tool.
Any thoughts on using https://github.com/google/cargo-raze and Bazel inside Nix?
I haven’t tried cargo-raze but I looked at the code for inspiration. I decided to use tera because of that.
I use sandboxed builds. If bazel uses its own caches, I don’t know how that should work. Do you have an idea?
For me, it is important and what I like about nix that I just run nix build or nixops deploy and I do not have to install any other dependencies.
Oh, I forgot to mention that the other way around looks quite fancy:
Using nix to install some binaries/dependencies from blaze.
That said, I am not sure if there is a proper ecosystem around blaze? E.g. deployment tools integration or similar?
I think it would be a sandbox in a sandbox, which should work fine. The Bazel build would benefit users on Windows (without MinGW)
Bazel has a nixpkg IIRC, so it shouldn’t be too difficult to get started.
Bazel sandbox would also give you a few additional features:
These can accelerate the build process.
I haven’t tried Rust + Bazel + Nix, so was interested if you had!
The sandboxing problem that I had in mind was no network connectivity (except in-built nix fetchers). That would block the features that you mentioned, correct? also how to access even a local cache and update it?
I haven’t really set it up for myself but remote builders look easy to setup. Not sure how hard it is to generalize that to a bigger cluster.
Remote caching should also be possible, e.g. with cachix.
Maybe bazel does it better.
Various problems with Nix builds were one reason I was recently arguing in another thread that one reason I wouldn’t promote Rust over C for system tools and things like Emacs, at this stage, is that C toolchains are basically guaranteed to be the first thing that works and that never breaks in all of the distributions and build systems. That might be mostly just a self-perpetuating situation, but there’s something to be said for being the decades-old established base system…
A C compiler is everywhere. But the whole C toolchains? Many of them haven’t even been properly ported to Windows.
Nice work! And kuddos for the very clean codebase.
Out of curiosity, did you try reaching pmeunier to report your bug? I guess he would be happy to know which use cases of yours failed with his tool :).
Thank you! Yes, I did report bugs and also tried to fix them. There are quite some open bugs: carnix. I don’t blame him, probably just not enough bandwidth.
That said, I am very willing to work together with anyone on a cool/canonical solution for rust/nix that also works for me.