3 ms·
Wait til you see the eight ways Nix has of packaging Rust applications! https://nixos.wiki/wiki/Rust#Packaging_Rust_projects_with_nix https://nixos.wiki/wiki/Ru
by Smaug123 4y ago
Wait til you see the eight ways Nix has of packaging Rust applications! https://nixos.wiki/wiki/Rust#Packaging_Rust_projects_with_nix https://nixos.wiki/wiki/Rust#Packaging_Rust_projects_with_ni...
- baby 4y agoAnd they’re all horrible
- 0x457 4y agoWhy? As long as it can take `Cargo.lock` as input instead of making you calculate hash yourself - it's all good. I'm using `crane` and `buildRustPackage` to build wasm front-end that is embedded into server binary (also rust). It works like a charm.
- baby 4y agoSo one problem we have at the moment in our project is that outdated Cargo.lock will basically break everything. Using `nix develop` will just fail to build the derivation, instead of regenerating the correct Cargo.lock (because it depends on someone not using `nix develop` to build the Rust project). It seems like the ideal way to mix nix and cargo is to simply trust and delegate to cargo once you reach a rust dependency, not try to nixify it. I think there was a rustup library for nix that probably would allow doing that but I haven't spent enough time trying (it's such a pain to debug flake.nix files)
- earthling8118 4y agoWhat do you mean by outdated Cargo.lock? You definitely should be leaving a sort of boundary between them. You can use fenix in your devshell to get a toolchain and then use crane for building. You just use cargo like normal when developing, including dependent crates, but CI can be handled with nix from that point. I've got my flakes organized in a way that they are basically modular, so I can easily reuse files from other ones. If I need a rust toolchain, cargo builds, python toolchail, postgres, or whatever I can just import the file and change it up slightly (mostly names)