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": { "locked": {
"lastModified": 1646322147, "lastModified": 1646667754,
"narHash": "sha256-XwrdjThHPq/APV7B6mXJwYvN/3RmsjX1W4zPgjvCp0A=", "narHash": "sha256-LahZHvCC3UVzGQ55iWDRZkuDssXl1rYgqgScrPV9S38=",
"owner": "numtide", "owner": "numtide",
"repo": "devshell", "repo": "devshell",
"rev": "2cc45675b223a35ca1d8af6383752c3d4b66f484", "rev": "59fbe1dfc0de8c3332957c16998a7d16dff365d8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -75,11 +75,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1646647374, "lastModified": 1646710334,
"narHash": "sha256-sFGoE9LbHfP5t8NGcNkX4sPVq9kp8+ae8ODnW5eOkzo=", "narHash": "sha256-eLBcDgcbOUfeH4k6SEW5a5v0PTp2KNCn+5ZXIoWGYww=",
"owner": "nix-community", "owner": "nix-community",
"repo": "dream2nix", "repo": "dream2nix",
"rev": "76412363073ea1252700eb48901849cf8480e138", "rev": "5dcfbfd3b60ce0208b894c1bdea00e2bdf80ca6a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -119,24 +119,6 @@
"type": "github" "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": { "nixCargoIntegration": {
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
@ -149,11 +131,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1646681124, "lastModified": 1646766572,
"narHash": "sha256-1ytR1z6RyBbxhk0LiO18QBH6Mu1JfAEWuUVBdbD4Bw8=", "narHash": "sha256-DV3+zxvAIKsMHsHedJKYFsracvFyLKpFQqurUBR86oY=",
"owner": "yusdacra", "owner": "yusdacra",
"repo": "nix-cargo-integration", "repo": "nix-cargo-integration",
"rev": "3b08d21177cecd5d69bdf76400a6145a021d1e49", "rev": "3a3f47f43ba486b7554164a698c8dfc5a38624ce",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -164,11 +146,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1646254136, "lastModified": 1646497237,
"narHash": "sha256-8nQx02tTzgYO21BP/dy5BCRopE8OwE8Drsw98j+Qoaw=", "narHash": "sha256-Ccpot1h/rV8MgcngDp5OrdmLTMaUTbStZTR5/sI7zW0=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3e072546ea98db00c2364b81491b893673267827", "rev": "062a0c5437b68f950b081bbfc8a699d57a4ee026",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -180,7 +162,6 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"helix": "helix",
"nixCargoIntegration": "nixCargoIntegration", "nixCargoIntegration": "nixCargoIntegration",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
@ -194,11 +175,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1642128126, "lastModified": 1646792695,
"narHash": "sha256-av8JUACdrTfQYl/ftZJvKpZEmZfa0avCq7tt5Usdoq0=", "narHash": "sha256-2drCXIKIQnJMlTZbcCfuHZAh+iPcdlRkCqtZnA6MHLY=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "ce4ef6f2d74f2b68f7547df1de22d1b0037ce4ad", "rev": "7f599870402c8d2a5806086c8ee0f2d92b175c54",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -12,17 +12,9 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.rustOverlay.follows = "rust-overlay"; 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 { nixCargoIntegration.lib.makeOutputs {
root = ./.; root = ./.;
renameOutputs = { "helix-term" = "helix"; }; renameOutputs = { "helix-term" = "helix"; };

View File

@ -13,10 +13,12 @@ let
gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar; gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
buildGrammar = grammar: buildGrammar = grammar:
let let
source = builtins.fetchGit { source = builtins.fetchTree {
type = "git";
url = grammar.source.git; url = grammar.source.git;
rev = grammar.source.rev; rev = grammar.source.rev;
allRefs = true; ref = grammar.source.ref or "HEAD";
shallow = true;
}; };
in stdenv.mkDerivation rec { in stdenv.mkDerivation rec {
# see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix # 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]] [[grammar]]
name = "protobuf" 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]] [[language]]
name = "elixir" name = "elixir"
@ -88,7 +88,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]] [[grammar]]
name = "elixir" 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]] [[language]]
name = "fish" name = "fish"