6 ms·
I’ve been trying out GUIX, but I wasn’t able to figure out a good way to do rust development on it. Tools like Cargo and Rust analyzer are extremely useful but
by BaculumMeumEst 5y ago
I’ve been trying out GUIX, but I wasn’t able to figure out a good way to do rust development on it. Tools like Cargo and Rust analyzer are extremely useful but introduce a lot of complexity which doesn’t seem to mix well with functional package managers like guix and nix.
- xena 5y agoIn Nix land I've been using naersk[1] to build Rust packages into Nix packages. Here's a minimal example of a Nix project that uses Rust, Naersk and puts cargo/rust analyzer in the devshell environment: https://tulpa.dev/cadey/printerfacts https://tulpa.dev/cadey/printerfacts [1]: https://github.com/nix-community/naersk https://github.com/nix-community/naersk
- tazjin 5y agoWe 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 https://github.com/nix-community/naersk [1]: https://cs.tvl.fyi/depot/-/blob/ops/journaldriver/default.nix https://cs.tvl.fyi/depot/-/blob/ops/journaldriver/default.ni...
- xena 5y agoIt's crate2nix: https://github.com/kolloch/crate2nix https://github.com/kolloch/crate2nix
- 42jd 5y agoHere are my two favorite (bookmarked) links for packaging and developing for rust. The trick is keep packaging and rust development separate and use specific dev environment flakes. So for dev work just bring cargo and rust as the nativeBuildInputs in mkShell (and any non rust dependencies) and then use standard cargo for development. But for packaging use one of the fancy tools. 1. https://srid.ca/rust-nix https://srid.ca/rust-nix 2. https://discourse.nixos.org/t/cargo2nix-dramatically-simpler https://discourse.nixos.org/t/cargo2nix-dramatically-simpler...