Skip to content

Use cargo crane in Nix flake and set up cachix action - #539

Merged
ulyssa merged 5 commits into
ulyssa:mainfrom
benjajaja:cargo_crane
Oct 25, 2025
Merged

ulyssa merged 5 commits into
ulyssa:mainfrom
benjajaja:cargo_crane

Conversation

@benjajaja

@benjajaja benjajaja commented Oct 15, 2025 •

Copy link
Copy Markdown
Collaborator
  • Crane allows to separately cache dependencies, use cachix, and more
  • Fenix seems to be the preferred way to overlay a specific rust version
  • Let fenix use rust-toolchain.toml to pick up the exact version
  • Exception for fmt, uses nightly pinned by flake.lock (the CI job uses nightly at the current time)
  • Add nix github actions job that runs flake checks (clippy, fmt, and tests)
  • Remove obsolete macos/darwin inputs
  • Update all flake inputs
  • Allow specific unused_variables for macos (fix warning)

The job took 16m, but it should speed up substantially since the dependencies are cached separately. I've used this setup successfully in some of my projects - it should end up taking less time than the non-nix checks, at least when dependencies did not change.

@ulyssa you would need to register at https://www.cachix.org/, it's free for public repos. Then create a new cache (call it iamb-ci, for example), click Settings, click Auth tokens, select "Never" for expiry, and click Generate. Copy the token, and add it as CACHIX_AUTH_TOKEN secret in the github project Settings -> Actions -> Repository secrets.
Alternatively, I can give you the token for my public iamb cache at https://app.cachix.org/cache/iamb-ci.

Fixes #533

@benjajaja
benjajaja force-pushed the cargo_crane branch 2 times, most recently from 687f361 to 408d106 Compare October 15, 2025 09:08
@benjajaja
benjajaja marked this pull request as draft October 15, 2025 09:09
@benjajaja
benjajaja force-pushed the cargo_crane branch 8 times, most recently from 0bc9db0 to 90d0c49 Compare October 15, 2025 09:59
@benjajaja
benjajaja marked this pull request as ready for review October 15, 2025 10:32
@benjajaja

Copy link
Copy Markdown
Collaborator Author

For reference, with cachix the jobs take 1-5 minutes if the dependencies didn't change: https://github.com/benjajaja/iamb/actions/runs/18530985398/job/52815174904?pr=1

@benjajaja
benjajaja force-pushed the cargo_crane branch 2 times, most recently from 3f3cbe8 to 8dda371 Compare October 15, 2025 14:26
Comment thread flake.nix Outdated
lockFile = ./Cargo.lock;

nativeBuildInputs = with pkgs; [
pkg-config

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and openssl aren't used

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! removed.

* Crane allows to separately cache dependencies, use cachix, and more
* Fenix seems to be the preferred way to overlay a specific rust version
* Let fenix use rust-toolchain.toml to pick up the exact version
* Exception for fmt, uses nightly pinned by flake.lock
* Update flake.lock / all flake inputs
* Remove unnecessary/obsolete macos/darwin buildInputs
@ulyssa

ulyssa commented Oct 25, 2025

Copy link
Copy Markdown
Owner

Thank you for adding this! I'll hold off on making it a required check for PRs for now, but hopefully it'll make it more obvious when a change breaks the Nix flakes. 🤞

I've made an iamb-prs cache and added a CACHIX_AUTH_TOKEN to the repository secrets for it.

@ulyssa

ulyssa commented Oct 25, 2025

Copy link
Copy Markdown
Owner

For some reason, it doesn't seem to be using the cache. Looking at the configuration for cachix-action, I thought that it might just need useDaemon: false, but setting that didn't fix it either, and it still ends with the "Pushing is disabled" message.

I'll merge it for now, since having something that tests running Nix is better than nothing. Maybe the action only does pushing on main?

@ulyssa ulyssa changed the title cargo crane Use cargo crane in Nix flake and set up cachix action Oct 25, 2025
@ulyssa
ulyssa enabled auto-merge (squash) October 25, 2025 22:44
@ulyssa
ulyssa merged commit 1ec3115 into ulyssa:main Oct 25, 2025
10 checks passed
@ulyssa

ulyssa commented Oct 25, 2025

Copy link
Copy Markdown
Owner

Maybe the action only does pushing on main?

Looks like that's the case. The main job successfully pushed to the cache.

@benjajaja

Copy link
Copy Markdown
Collaborator Author

Yes it looks good on main, thank you for setting up the cache!

@ulyssa ulyssa added this to the v0.0.11 milestone Oct 25, 2025
@ulyssa ulyssa mentioned this pull request Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nix build fails with darwin.apple_sdk_11_0 has been removed as it was a legacy compatibility stub

3 participants