aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorMichael Davis2022-02-15 03:50:08 +0000
committerBlaž Hrastnik2022-03-10 08:31:57 +0000
commit37520f46ae891f77f81f4049cbb7dc2dbe2d5fc3 (patch)
tree08658b41071f7959187423824b53fa1fac646417 /flake.nix
parentb157c5a8a4472cff68de3a9be66e220dc4b80a9f (diff)
fetch and build grammars with nix in flake
This commit replaces the out-of-date builder in the flake which relied on submodules for fetching and the compiler for building. Now we disable fetching and building explicitly with the environment variable and then use builtins.fetchGit and a derivation mostly derived from upstream to compile the grammars. Anecdotally, this is still quite slow as builtins.fetchGit does not seem to do shallow clones. I'm not sure I see a way around it though without recording sha256s, which seems cumbersome.
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix46
1 files changed, 26 insertions, 20 deletions
diff --git a/flake.nix b/flake.nix
index c4838ffd..e1cd5036 100644
--- a/flake.nix
+++ b/flake.nix
@@ -33,26 +33,32 @@
package = "helix";
};
overrides = {
- crateOverrides = common: _: rec {
- helix-term = prev: {
- # disable fetching and building of tree-sitter grammars in the helix-term build.rs
- HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
- buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
- nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ [ common.pkgs.makeWrapper ];
- preConfigure = ''
- ${prev.preConfigure}
- rm -r helix-syntax/languages
- ln -s ${helix}/helix-syntax/languages helix-syntax/languages
- ln -s "$PWD/helix-syntax/languages" languages
- mkdir -p runtime/grammars
- '';
- postInstall = ''
- ${prev.postInstall or ""}
- mkdir -p $out/lib
- cp -r runtime $out/lib
- wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "$out/lib/runtime"
- '';
- };
+ crateOverrides = common: _: {
+ helix-term = prev:
+ let
+ inherit (common) pkgs;
+ grammars = pkgs.callPackage ./grammars.nix { };
+ runtimeDir = pkgs.runCommand "helix-runtime" { } ''
+ mkdir -p $out
+ ln -s ${common.root}/runtime/* $out
+ rm -r $out/grammars
+ ln -s ${grammars} $out/grammars
+ '';
+ in
+ {
+ # disable fetching and building of tree-sitter grammars in the helix-term build.rs
+ HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
+ # link languages and theme toml files since helix-term expects them (for tests)
+ preConfigure = "ln -s ${common.root}/{languages.toml,theme.toml,base16_theme.toml} ..";
+ buildInputs = (prev.buildInputs or [ ]) ++ [ common.cCompiler.cc.lib ];
+ nativeBuildInputs = [ pkgs.makeWrapper ];
+
+ postFixup = ''
+ if [ -f "$out/bin/hx" ]; then
+ wrapProgram "$out/bin/hx" --set HELIX_RUNTIME "${runtimeDir}"
+ fi
+ '';
+ };
};
shell = common: prev: {
packages = prev.packages ++ (with common.pkgs; [ lld_13 lldb cargo-tarpaulin cargo-flamegraph ]);