Clean up Nix Flake & make it easier to customize#12831
Clean up Nix Flake & make it easier to customize#12831the-mikedavis merged 22 commits intohelix-editor:masterfrom
Conversation
|
I was considering trying to remove the dependency on Removing Should we also consider switching to the |
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.
It's not a maintenance burden so there's not really a reason to remove it imo.
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). |
|
Ah, I whipped up the overlay-only version today during lunch. It has the problem of customization being pretty obtuse atm. See: Basically this line: |
|
Moving to the Rust-Overlay only version would still be a net win though because Cachix would work. And it wouldn't be much different from the status-quo wrt customization. |
|
@the-mikedavis I found a solution. Here's my NixOS config with customizations: |
f311895 to
57b3891
Compare
a9903b8 to
7bbfd57
Compare
|
On this branch I'm seeing an error when creating the dev shell: The package build with |
|
Oh yeah, I did not test that. |
flake.nix
Outdated
| rustPlatform.rust.rustc # TODO: Remove | ||
| rustPlatform.rust.cargo # TODO: Remove |
There was a problem hiding this comment.
Should we use rustc and cargo from the attrs passed to mkHelix instead? I'm seeing a deprecation warning on accessing these
There was a problem hiding this comment.
No as they are not spliced in properly if you do that. The alternative is to change the callPackage invocations to be something like
pkgs.callPackage mkHelix {
rustPlatform = msrvPlatform;
rustc = msrvToolchain.rustc;
cargo = msrvToolchain.cargo;
};There was a problem hiding this comment.
For the package build (not the shell) we don't need to follow the MSRV, it's ok to build with latest stable. We do roughly the same in CI - the build workflow for PRs checks with the MSRV and then the release workflow uses whatever is the latest stable
There was a problem hiding this comment.
This is not for Helix, but rather for me (or anyone else who overrides the toolchain) so that when I override the toolchain that the correct Cargo and Rustc are used for the entire build.
|
Hmm there's something weird with the fromRustupToolchainFile API. The check fails to build, and it was what was wrong with the devShell |
fat LTO takes a long time
|
Ok with some help from oxalica I found my typo and it should work fine now. |
|
An optional thing that could be done (and I do this in my repos at work) is move the |
|
It also looks like finalAttrs for buildRustPackage was merged, so the TODOs can be resolved. |
the-mikedavis
left a comment
There was a problem hiding this comment.
Looks great, thanks for working on this! The flake is much simpler now and I like having the actual derivation in default.nix (plus it looks very similar to what I'd expect to see for a package in nixpkgs)
|
Thanks! |
|
For reference, this is what my overrides look like with the merged changes: |
|
I may clean up the grammar file at some point but it's not as high of priority to me. |
|
Eventually we will replace the |
|
Hi guys, I have a question about the new nix drv. In the past, i can use |
|
Hmm I'm not sure we expose anything for this now - I don't think it's possible to pass through |
|
yes, i know that. i have already build my own helix-runtime for add grammar and tree-sitter libs. |
|
It would be nice to have that functionality. I'm not very handy with Nix so I'm not sure the best way to add it back. But I'd be interested in a PR that makes it possible again |
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.I am unconvinced it needs all the source filtering.I did preserve the behavior that the devshell will compile with
target-cpu=nativeand 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/338fce6a5b7c3c5fe9c1790929bae40ce1494006/home-manager/helix.nix#L10-L29
The main issue is that the previous weird setup may be relied one by some people. So this will break them.
Commits can be squashed when merged.