Skip to content

Commit

Permalink
flake: use builtins.fetchTree to shallow-clone grammar repos
Browse files Browse the repository at this point in the history
Here we perform a shallow fetch using builtins.fetchTree. In order
to make this work, we need to specify the `ref' for any repository
that doesn't have `master' as its default branch (I'm not sure why
this limitation exists since we don't need this when performing
the shallow fetch in `--grammar build')

This `ref' field is ignored by helix, so I have left it undocumented
for now, but I could be open to documenting it.
  • Loading branch information
the-mikedavis committed Mar 10, 2022
1 parent c05b6b3 commit af0383d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 47 deletions.
49 changes: 15 additions & 34 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,9 @@
inputs.nixpkgs.follows = "nixpkgs";
inputs.rustOverlay.follows = "rust-overlay";
};
# NOTE: the flake looks like it is hanging when it pulls this input because
# the submodules take a long time to clone. This will be fixed in #1659.
helix = {
url = "https://github.com/helix-editor/helix.git";
type = "git";
submodules = true;
flake = false;
};
};

outputs = inputs@{ nixCargoIntegration, helix, ... }:
outputs = inputs@{ nixCargoIntegration, ... }:
nixCargoIntegration.lib.makeOutputs {
root = ./.;
renameOutputs = { "helix-term" = "helix"; };
Expand Down
6 changes: 4 additions & 2 deletions grammars.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ let
gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
buildGrammar = grammar:
let
source = builtins.fetchGit {
source = builtins.fetchTree {
type = "git";
url = grammar.source.git;
rev = grammar.source.rev;
allRefs = true;
ref = grammar.source.ref or "HEAD";
shallow = true;
};
in stdenv.mkDerivation rec {
# see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix
Expand Down
4 changes: 2 additions & 2 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "protobuf"
source = { git = "https://github.com/yusdacra/tree-sitter-protobuf", rev = "19c211a01434d9f03efff99f85e19f967591b175" }
source = { git = "https://github.com/yusdacra/tree-sitter-protobuf", rev = "19c211a01434d9f03efff99f85e19f967591b175"}

[[language]]
name = "elixir"
Expand All @@ -88,7 +88,7 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "elixir"
source = { git = "https://github.com/elixir-lang/tree-sitter-elixir", rev = "f5d7bda543da788bd507b05bd722627dde66c9ec" }
source = { git = "https://github.com/elixir-lang/tree-sitter-elixir", rev = "f5d7bda543da788bd507b05bd722627dde66c9ec" }

[[language]]
name = "fish"
Expand Down

0 comments on commit af0383d

Please sign in to comment.