From 14124e496163832257aae211ce119e3fd1b544fb Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 9 Mar 2022 08:34:52 -0600 Subject: [PATCH] flake: use builtins.fetchTree to shallow-clone grammar repos 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. --- flake.lock | 49 +++++++++++++++---------------------------------- flake.nix | 10 +--------- grammars.nix | 6 ++++-- languages.toml | 40 ++++++++++++++++++++-------------------- 4 files changed, 40 insertions(+), 65 deletions(-) diff --git a/flake.lock b/flake.lock index f061c80fbeaf1..40a87eb55fd00 100644 --- a/flake.lock +++ b/flake.lock @@ -25,11 +25,11 @@ ] }, "locked": { - "lastModified": 1646322147, - "narHash": "sha256-XwrdjThHPq/APV7B6mXJwYvN/3RmsjX1W4zPgjvCp0A=", + "lastModified": 1646667754, + "narHash": "sha256-LahZHvCC3UVzGQ55iWDRZkuDssXl1rYgqgScrPV9S38=", "owner": "numtide", "repo": "devshell", - "rev": "2cc45675b223a35ca1d8af6383752c3d4b66f484", + "rev": "59fbe1dfc0de8c3332957c16998a7d16dff365d8", "type": "github" }, "original": { @@ -75,11 +75,11 @@ ] }, "locked": { - "lastModified": 1646647374, - "narHash": "sha256-sFGoE9LbHfP5t8NGcNkX4sPVq9kp8+ae8ODnW5eOkzo=", + "lastModified": 1646710334, + "narHash": "sha256-eLBcDgcbOUfeH4k6SEW5a5v0PTp2KNCn+5ZXIoWGYww=", "owner": "nix-community", "repo": "dream2nix", - "rev": "76412363073ea1252700eb48901849cf8480e138", + "rev": "5dcfbfd3b60ce0208b894c1bdea00e2bdf80ca6a", "type": "github" }, "original": { @@ -119,24 +119,6 @@ "type": "github" } }, - "helix": { - "flake": false, - "locked": { - "lastModified": 1646500939, - "narHash": "sha256-M0QvrRuluDkBWUfd5CYwvj9WtgalKlm5stJUAwnhrwI=", - "ref": "master", - "rev": "7633c5acd30258fc9caca926bfaa264d07d508ec", - "revCount": 2438, - "submodules": true, - "type": "git", - "url": "https://github.com/helix-editor/helix.git" - }, - "original": { - "submodules": true, - "type": "git", - "url": "https://github.com/helix-editor/helix.git" - } - }, "nixCargoIntegration": { "inputs": { "devshell": "devshell", @@ -149,11 +131,11 @@ ] }, "locked": { - "lastModified": 1646681124, - "narHash": "sha256-1ytR1z6RyBbxhk0LiO18QBH6Mu1JfAEWuUVBdbD4Bw8=", + "lastModified": 1646766572, + "narHash": "sha256-DV3+zxvAIKsMHsHedJKYFsracvFyLKpFQqurUBR86oY=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "3b08d21177cecd5d69bdf76400a6145a021d1e49", + "rev": "3a3f47f43ba486b7554164a698c8dfc5a38624ce", "type": "github" }, "original": { @@ -164,11 +146,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1646254136, - "narHash": "sha256-8nQx02tTzgYO21BP/dy5BCRopE8OwE8Drsw98j+Qoaw=", + "lastModified": 1646497237, + "narHash": "sha256-Ccpot1h/rV8MgcngDp5OrdmLTMaUTbStZTR5/sI7zW0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3e072546ea98db00c2364b81491b893673267827", + "rev": "062a0c5437b68f950b081bbfc8a699d57a4ee026", "type": "github" }, "original": { @@ -180,7 +162,6 @@ }, "root": { "inputs": { - "helix": "helix", "nixCargoIntegration": "nixCargoIntegration", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" @@ -194,11 +175,11 @@ ] }, "locked": { - "lastModified": 1642128126, - "narHash": "sha256-av8JUACdrTfQYl/ftZJvKpZEmZfa0avCq7tt5Usdoq0=", + "lastModified": 1646792695, + "narHash": "sha256-2drCXIKIQnJMlTZbcCfuHZAh+iPcdlRkCqtZnA6MHLY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "ce4ef6f2d74f2b68f7547df1de22d1b0037ce4ad", + "rev": "7f599870402c8d2a5806086c8ee0f2d92b175c54", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e1cd50360b8dd..38ba9fd0c5559 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; }; diff --git a/grammars.nix b/grammars.nix index 6dbc05c873325..bc531bc721a03 100644 --- a/grammars.nix +++ b/grammars.nix @@ -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 diff --git a/languages.toml b/languages.toml index 1818201121dae..cce2b1317f83f 100644 --- a/languages.toml +++ b/languages.toml @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" }