-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Clean up Nix Flake & make it easier to customize #12831
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
Merged
the-mikedavis
merged 22 commits into
helix-editor:master
from
RossSmyth:NixCustomization
Mar 4, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d998cf9
Format grammars.nix with alejandra
RossSmyth 2488754
Update nix flake to be easier to understand and overrideable
RossSmyth 4ba82e4
Fix dependencies and application crates being build with different ru…
RossSmyth 86ba656
Fix recursion
RossSmyth fdf4271
Fix completions
RossSmyth f6b7689
Add docs and the rustFlags argument
RossSmyth c313993
Fix typo
RossSmyth 93bf32a
Refactor Flake to only use rust-overlay
RossSmyth 2ae9ac3
Use mkDerivation directly so that customizablity is greatly enhanced
RossSmyth de02aa3
Fix nits
RossSmyth e4e7646
Forgot to add rec
RossSmyth 57b3891
Ignore some files
RossSmyth 1fe71da
Build Helix with the latest stable Rust toolchain by default
RossSmyth 901f964
Fix fileset extension filtering
RossSmyth 7bbfd57
Ignore all *.git* files
RossSmyth 9ed6cbd
Fix devShell
RossSmyth 2dc3dd3
Fix the msrv override
RossSmyth 703a962
buildType opt -> release
RossSmyth bb2141c
Move mkHelix to default.nix
RossSmyth 4edfad0
Bump flake lock and use rustPackage finalAttrs
RossSmyth f261ac8
Fix some nits in the default
RossSmyth f8b8da5
minor: Remove unused let+in, unused bindings from default.nix
the-mikedavis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,78 @@ | ||
| # Flake's default package for non-flake-enabled nix instances | ||
| let | ||
| compat = builtins.fetchTarball { | ||
| url = "https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz"; | ||
| sha256 = "sha256:1qc703yg0babixi6wshn5wm2kgl5y1drcswgszh4xxzbrwkk9sv7"; | ||
| }; | ||
| { | ||
| lib, | ||
| rustPlatform, | ||
| callPackage, | ||
| runCommand, | ||
| installShellFiles, | ||
| git, | ||
| ... | ||
| }: let | ||
| fs = lib.fileset; | ||
|
|
||
| src = fs.difference (fs.gitTracked ./.) (fs.unions [ | ||
| ./.envrc | ||
| ./rustfmt.toml | ||
| ./screenshot.png | ||
| ./book | ||
| ./docs | ||
| ./flake.lock | ||
| (fs.fileFilter (file: lib.strings.hasInfix ".git" file.name) ./.) | ||
| (fs.fileFilter (file: file.hasExt "svg") ./.) | ||
| (fs.fileFilter (file: file.hasExt "md") ./.) | ||
| (fs.fileFilter (file: file.hasExt "nix") ./.) | ||
| ]); | ||
|
|
||
| # Next we actually need to build the grammars and the runtime directory | ||
| # that they reside in. It is built by calling the derivation in the | ||
| # grammars.nix file, then taking the runtime directory in the git repo | ||
| # and hooking symlinks up to it. | ||
| grammars = callPackage ./grammars.nix {}; | ||
| runtimeDir = runCommand "helix-runtime" {} '' | ||
| mkdir -p $out | ||
| ln -s ${./runtime}/* $out | ||
| rm -r $out/grammars | ||
| ln -s ${grammars} $out/grammars | ||
| ''; | ||
| in | ||
| (import compat {src = ./.;}).defaultNix | ||
| # Currently rustPlatform.buildRustPackage doesn't have the finalAttrs pattern | ||
| # hooked up. To get around this while having good customization, mkDerivation is | ||
| # used instead. | ||
| rustPlatform.buildRustPackage (self: { | ||
| cargoLock.lockFile = ./Cargo.lock; | ||
|
|
||
| nativeBuildInputs = [ | ||
| installShellFiles | ||
| git | ||
| ]; | ||
|
|
||
| buildType = "release"; | ||
|
|
||
| name = with builtins; (fromTOML (readFile ./helix-term/Cargo.toml)).package.name; | ||
| src = fs.toSource { | ||
| root = ./.; | ||
| fileset = src; | ||
| }; | ||
|
|
||
| # Helix attempts to reach out to the network and get the grammars. Nix doesn't allow this. | ||
| HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1"; | ||
|
|
||
| # So Helix knows what rev it is. | ||
| HELIX_NIX_BUILD_REV = self.rev or self.dirtyRev or null; | ||
|
|
||
| doCheck = false; | ||
| strictDeps = true; | ||
|
|
||
| # Sets the Helix runtimedir to the grammars | ||
| env.HELIX_DEFAULT_RUNTIME = "${runtimeDir}"; | ||
|
|
||
| # Get all the application stuff in the output directory. | ||
| postInstall = '' | ||
| mkdir -p $out/lib | ||
| installShellCompletion ${./contrib/completion}/hx.{bash,fish,zsh} | ||
| mkdir -p $out/share/{applications,icons/hicolor/256x256/apps} | ||
| cp ${./contrib/Helix.desktop} $out/share/applications | ||
| cp ${./contrib/helix.png} $out/share/icons/hicolor/256x256/apps | ||
| ''; | ||
|
|
||
| meta.mainProgram = "hx"; | ||
| }) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.