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 9, 2022
1 parent a2a54cf commit 963e7bc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 65 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 "master";
shallow = true;
};
in stdenv.mkDerivation rec {
# see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix
Expand Down
40 changes: 20 additions & 20 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", ref = "main" }

[[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", ref = "main" }

[[language]]
name = "fish"
Expand Down Expand Up @@ -426,7 +426,7 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "twig"
source = { git = "https://github.com/eirabben/tree-sitter-twig", rev = "b7444181fb38e603e25ea8fcdac55f9492e49c27" }
source = { git = "https://github.com/eirabben/tree-sitter-twig", rev = "b7444181fb38e603e25ea8fcdac55f9492e49c27", ref = "main" }

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

[[grammar]]
name = "lean"
source = { git = "https://github.com/Julian/tree-sitter-lean", rev = "d98426109258b266e1e92358c5f11716d2e8f638" }
source = { git = "https://github.com/Julian/tree-sitter-lean", rev = "d98426109258b266e1e92358c5f11716d2e8f638", ref = "main" }

[[language]]
name = "julia"
Expand Down Expand Up @@ -613,7 +613,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "zig"
source = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "93331b8bd8b4ebee2b575490b2758f16ad4e9f30" }
source = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "93331b8bd8b4ebee2b575490b2758f16ad4e9f30", ref = "main" }

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

[[grammar]]
name = "tsq"
source = { git = "https://github.com/tree-sitter/tree-sitter-tsq", rev = "b665659d3238e6036e22ed0e24935e60efb39415" }
source = { git = "https://github.com/tree-sitter/tree-sitter-tsq", rev = "b665659d3238e6036e22ed0e24935e60efb39415", ref = "main" }

[[language]]
name = "cmake"
Expand All @@ -664,7 +664,7 @@ indent = { tab-width = 4, unit = "\t" }

[[grammar]]
name = "make"
source = { git = "https://github.com/alemuller/tree-sitter-make", rev = "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" }
source = { git = "https://github.com/alemuller/tree-sitter-make", rev = "a4b9187417d6be349ee5fd4b6e77b4172c6827dd", ref = "main" }

[[language]]
name = "glsl"
Expand Down Expand Up @@ -735,7 +735,7 @@ injection-regex = "llvm"

[[grammar]]
name = "llvm"
source = { git = "https://github.com/benwilliamgraham/tree-sitter-llvm", rev = "3b213925b9c4f42c1acfe2e10bfbb438d9c6834d" }
source = { git = "https://github.com/benwilliamgraham/tree-sitter-llvm", rev = "3b213925b9c4f42c1acfe2e10bfbb438d9c6834d", ref = "main" }

[[language]]
name = "llvm-mir"
Expand Down Expand Up @@ -784,7 +784,7 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "markdown"
source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "ad8c32917a16dfbb387d1da567bf0c3fb6fffde2" }
source = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "ad8c32917a16dfbb387d1da567bf0c3fb6fffde2", ref = "main" }

[[language]]
name = "dart"
Expand Down Expand Up @@ -825,7 +825,7 @@ language-server = { command = "docker-langserver", args = ["--stdio"] }

[[grammar]]
name = "dockerfile"
source = { git = "https://github.com/camdencheek/tree-sitter-dockerfile", rev = "7af32bc04a66ab196f5b9f92ac471f29372ae2ce" }
source = { git = "https://github.com/camdencheek/tree-sitter-dockerfile", rev = "7af32bc04a66ab196f5b9f92ac471f29372ae2ce", ref = "main" }

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

[[grammar]]
name = "git-commit"
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-commit", rev = "066e395e1107df17183cf3ae4230f1a1406cc972" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-commit", rev = "066e395e1107df17183cf3ae4230f1a1406cc972", ref = "main" }

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

[[grammar]]
name = "git-diff"
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-diff", rev = "c12e6ecb54485f764250556ffd7ccb18f8e2942b" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-diff", rev = "c12e6ecb54485f764250556ffd7ccb18f8e2942b", ref = "main" }

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

[[grammar]]
name = "git-rebase"
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-rebase", rev = "332dc528f27044bc4427024dbb33e6941fc131f2" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-rebase", rev = "332dc528f27044bc4427024dbb33e6941fc131f2", ref = "main" }

[[language]]
name = "regex"
Expand All @@ -888,7 +888,7 @@ indent = { tab-width = 4, unit = "\t" }

[[grammar]]
name = "git-config"
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-config", rev = "0e4f0baf90b57e5aeb62dcdbf03062c6315d43ea" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-git-config", rev = "0e4f0baf90b57e5aeb62dcdbf03062c6315d43ea", ref = "main" }

[[language]]
name = "graphql"
Expand All @@ -915,7 +915,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "elm"
source = { git = "https://github.com/elm-tooling/tree-sitter-elm", rev = "bd50ccf66b42c55252ac8efc1086af4ac6bab8cd" }
source = { git = "https://github.com/elm-tooling/tree-sitter-elm", rev = "bd50ccf66b42c55252ac8efc1086af4ac6bab8cd", ref = "main" }

[[language]]
name = "iex"
Expand All @@ -926,7 +926,7 @@ roots = []

[[grammar]]
name = "iex"
source = { git = "https://github.com/elixir-lang/tree-sitter-iex", rev = "39f20bb51f502e32058684e893c0c0b00bb2332c" }
source = { git = "https://github.com/elixir-lang/tree-sitter-iex", rev = "39f20bb51f502e32058684e893c0c0b00bb2332c", ref = "main" }

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

[[grammar]]
name = "rescript"
source = { git = "https://github.com/jaredramirez/tree-sitter-rescript", rev = "789a171d9bcf73f6d76e67aca39ed14a75375b04" }
source = { git = "https://github.com/jaredramirez/tree-sitter-rescript", rev = "789a171d9bcf73f6d76e67aca39ed14a75375b04", ref = "main" }

[[language]]
name = "erlang"
Expand All @@ -954,7 +954,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "erlang"
source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "86985bde399c5f40b00bc75f7ab70a6c69a5f9c3" }
source = { git = "https://github.com/the-mikedavis/tree-sitter-erlang", rev = "86985bde399c5f40b00bc75f7ab70a6c69a5f9c3", ref = "main" }

[[language]]
name = "kotlin"
Expand All @@ -967,7 +967,7 @@ language-server = { command = "kotlin-language-server" }

[[grammar]]
name = "kotlin"
source = { git = "https://github.com/fwcd/tree-sitter-kotlin", rev = "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569" }
source = { git = "https://github.com/fwcd/tree-sitter-kotlin", rev = "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569", ref = "main" }

[[language]]
name = "hcl"
Expand All @@ -982,4 +982,4 @@ auto-format = true

[[grammar]]
name = "hcl"
source = { git = "https://github.com/MichaHoffmann/tree-sitter-hcl", rev = "3cb7fc28247efbcb2973b97e71c78838ad98a583" }
source = { git = "https://github.com/MichaHoffmann/tree-sitter-hcl", rev = "3cb7fc28247efbcb2973b97e71c78838ad98a583", ref = "main" }

0 comments on commit 963e7bc

Please sign in to comment.