Replies: 3 comments
-
There's a big difference between the local developer workflows (1 and 2) which typically is just a
I don't see a practical way to combine them, though caching will re-use build inputs between dev shell and CI.
You should use cachix. It's a huge improvement. It comes down to creating account, putting secret in your github settings and using the appropriate actions to use it. You can put your cachix in your flake.nix https://github.com/fedimint/fedimint/blob/32d9423f47ceeee170a81f688f3c67f50b47c555/flake.nix#L947 so the developers will be asked do they want to trust it and use it locally. It makes a difference only for some unconventional build inputs (that wouldn't be already in normal nixpkgs cache) or if these developers actually run
I've built a system that derives debug flake outputs from normal flake outputs if you are interested. https://github.com/fedimint/fedimint/blob/32d9423f47ceeee170a81f688f3c67f50b47c555/flake.nix#L668 In CI we build and test debug builds, but for containers and anything release-like we use release ones. If you go this route and e.g. run tests in debug builds, make sure to have |
Beta Was this translation helpful? Give feedback.
-
Hi @edulix!
In theory this may be possible to achieve but I have not yet seen it done in practice: one could imagine defining a Nix derivation which invokes For my projects I usually stick with rust-analyzer building things locally and the CI building things via Nix, though unfortunately this won't take advantage of the cached artifacts.
I briefly tried experimenting with this a while back by copying the artifacts out of the Nix store locally and then trying to run If this issue ever gets resolved you could at least bootstrap local builds that way, but I haven't had any success myself.
I haven't used codespaces myself yet, but if you are somehow invoking Nix through it they should be able to take advantage of cachix just like you would anywhere else (either in CI or locally). I'd checkout the cachix docs (or the example @dpc mentioned) for some inspiration!
Crane allows this to be fully configurable so it's entirely up to you! The defaults will build in release mode since that's probably what downstream consumers would want to use anyway, but if you find it useful to have a separate set of derivations which build in debug mode for CI/flake checks feel free to take that approach! |
Beta Was this translation helpful? Give feedback.
-
Thank you guys for the detailed responses. I'll keep investigating a bit what can I achieve and report back here when I have something interesting and related to the topics mentioned. |
Beta Was this translation helpful? Give feedback.
-
First, thanks @ipetkov for making development easier for Rust developers that use Nix.
I'm trying to figure out how to best integrate crane in our tooling. The project I'm working on is https://github.com/sequentech/bulletin-board (open source and has Nix Flake and other tools integrated). Crane has clear the advantages for CI tasks and Nix.
The questions I have revolve how to reuse/integrate the cache of the build that is generated from Nix with Crane into the rest of the development tooling:
cargo build
etc and not start the build from scratch.I suspect I should approach this using some of the API calls like lib.vendorCargoDeps, but I don't know exactly how.
Beta Was this translation helpful? Give feedback.
All reactions