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.
This commit is contained in:
Michael Davis 2022-03-09 08:34:52 -06:00 committed by Blaž Hrastnik
parent 7044d7d804
commit e01c53551d
4 changed files with 22 additions and 47 deletions

View File

@ -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": {

View File

@ -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"; };

View File

@ -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

View File

@ -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"
@ -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"