crate2nix
naersk
Our great sponsors
crate2nix | naersk | |
---|---|---|
10 | 6 | |
316 | 630 | |
2.8% | 1.9% | |
9.4 | 5.6 | |
8 days ago | 8 days ago | |
Nix | Nix | |
Apache License 2.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
crate2nix
- Transitioning to Rust as a company
-
How to package a Rust app using Nix
I'll use nixpkgs' buildRustPackage. There's a few other tools, my favorite being crate2nix, but we'll leave that to a future tutorial.
-
Nix shell related questions (for rust)
If you want to iterate with nix instead of cargo, crate2nix and cargo2nix provides more caching and more fine control over your dependencies. I haven't used these two so you would have to decide for yourself. You may also want to try out nocargo for something more experimental.
-
Introducing Crane: Composable and Cacheable Builds with Cargo and Nix
I'm yet to try it out, but from the blog post, the README and the source it appears that Crane builds all dependencies in one derivation (separately from the main crate). This means that if a dependency gets added, removed or changed, all dependencies of a crate will be rebuilt. This is in contrast with https://github.com/kolloch/crate2nix, which does build every dependency in a separate package, thus you don't need to rebuild other dependencies if you only change a small part of the tree.
-
Nixery – Docker images on the fly with Nix
Yes, you will have to package it if it's not already in nixpkgs.
The good news is once you learn how, it's basically trivial with crate2nix[0], which can autogenerate nix derivations from rust crates
-
Help with Nix and Rust
From my quick reading of cargo2nix's webpage yes. https://github.com/kolloch/crate2nix has a workspaces section.
-
How do you install packages not in Nixpkgs?
As for your two applications, they're both written in Rust, and I like https://github.com/kolloch/crate2nix as a way to package Rust crates with Nix. BTW, wezterm is already in nixpkgs!
-
Nix-ifying a Rust project
I like the way crate2nix works. I have made a flake template for it here. Sometimes it requires a couple of overrides to fix some misbehaving crates (see https://github.com/balsoft/simple-osd-daemons/blob/master/flake.nix#L29 for an example of such overrides), but otherwise it's fantastic. It doesn't require any hash nonsense, it downloads and builds all the crates separately (unlike naersk or other solutions) so you get all the benefits of Nix (reproducibility and proper caching).
-
How to do a full, reproducible archive of a Rust project?
Crate2nix might help: https://github.com/kolloch/crate2nix
naersk
-
Help with building a 32bit library with cargo
i would also recommend using crane or naersk since iirc rustPlaform.buildRustPackage can mangle some of these options (or maybe i just did something wrong lol)
-
Nix & Rust - cargo2nix 0.11.0 released
Have a look at naersk, it neither requires generated Nix files nor IFD.
-
Nix and NixOS Get So Close to Perfect
We use naersk[0] for Rust projects in our Nix monorepo (for example [1]). It's pretty hands-off in terms of the Nix code needed (you don't need to pin hashes inside of the Nix code as long as you have a Cargo lockfile) and all the existing tooling keeps working fine.
The main drawback of it is that it currently builds all of your dependencies in one big derivation, so any dependency changes cause a full rebuild. There's some other project I saw fly by which attempts to do a similar thing but split each crate into a separate derivation, but I forgot what it's called and have no experience with it.
[0]: https://github.com/nix-community/naersk
[1]: https://cs.tvl.fyi/depot/-/blob/ops/journaldriver/default.ni...
-
Nixery – Docker images on the fly with Nix
You can also use naersk¹ if you want to avoid a two-step process. It's especially convenient when using nix flakes.
-
niv, naersk, napalm: moving on
I created https://github.com/nmattia/napalm/issues/34 and https://github.com/nmattia/naersk/issues/183 to move them to nix-community
-
Nix-ifying a Rust project
sounds exactly like what naersk does. naersk doesn't need a cargSha256 argument since it downloads dependencies from Cargo.lock. it can also grab the version number from Cargo.toml
What are some alternatives?
cargo2nix - Granular builds of Rust projects for Nix
rust-overlay - Pure and reproducible nix overlay of binary distributed rust toolchains
rust-nix-template - Rust project template with Nix (Flakes) and VSCode support
crates.io-index - Registry index for crates.io
nix-direnv - A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10]
nix-templates - Nix Flake templates for various languages
direnv - unclutter your .profile
nixos - My NixOS Configurations
crane - A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.
nix2container - An archive-less dockerTools.buildImage implementation