Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Nix Flake & make it easier to customize #12831

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

RossSmyth
Copy link
Contributor

Hello. It has been a while since #11528. I am better at Nix, so I decided to take a crack at cleaning the flake up.

My main issues with it is that it was not setup to be very customizable. Also the Cachix cache is nearly useless since it is compiled with target-cpu=native, so the cache will nearly always be missed. So I refactored it and added some comments.

  1. I am unconvinced it needs all the source filtering.
  2. By default everything uses the MSRV compiler as that is a safe default.
  3. Cleaned up a few vestigial things that my guess is were left from earlier revisions

I did preserve the behavior that the devshell will compile with target-cpu=native and other flags. But now the Cachix cache is actually possible to hit.

You can see an example of it in use in my NixOS config here: https://github.com/RossSmyth/nixos/blob/f518f62d4c0ce5b4b97bc6b1b8e1a27affc5ed66/home-manager/helix.nix#L10-L18

It should also be relatively straight-forward in the future if anyone wants to add other customization options.

The main issue is that the previous weird setup may be relied one by some people. So this will break them. Also, if customized the overlay will not use the custom build of Helix. I'm not sure if there is a good solution to this.

Commits can be squashed when merged.

@the-mikedavis
Copy link
Member

I was considering trying to remove the dependency on crane and only use rust-overlay directly (for example like nil does) but I'm not sure if that's an easy change. I haven't taken advantage of the checks part of the flake so I think it's fine to drop that part.

Removing target-cpu=native from the package build but keeping it in the shell sounds good.

Should we also consider switching to the opt profile for flake builds? (See #12453 for context - opt is what we use for releases)

@RossSmyth
Copy link
Contributor Author

RossSmyth commented Feb 10, 2025

I was considering trying to remove the dependency on crane and only use rust-overlay directly

Yeah I considered that but also didn't think it was a big deal. I don't think it would be very hard to move to that. I can take a look later to see. It should be even easier to customize with only rust-overlay.

I haven't taken advantage of the checks part of the flake so I think it's fine to drop that part.

It's not a maintenance burden so there's not really a reason to remove it imo.

Should we also consider switching to the opt profile for flake builds?

Ah, I did not look at this. Sure, makes sense. FYI fat LTO is sort of a placebo effect now days since it doesn't get much attention in LLVM anymore. The main thing it does is make your builds take longer. Thin is generally pretty close or faster (at runtime) in many cases since Google and other folks put money into thin LTO (for chrome and such).

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.

2 participants