From 0ff7ccbb2c1fd06584e150b366e0c46259a32aef Mon Sep 17 00:00:00 2001 From: Marvin Strangfeld Date: Wed, 13 Mar 2024 17:23:32 +0100 Subject: [PATCH] build(nix): Fix Nix grammars build due to breaking changes in fetchTree Due to https://github.com/NixOS/nix/commit/09d76e512a468ad65bedaeda56871de7043849b0 Fixes issue #9866 --- grammars.nix | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/grammars.nix b/grammars.nix index 5152b5204..3c992992b 100644 --- a/grammars.nix +++ b/grammars.nix @@ -21,13 +21,6 @@ builtins.hasAttr "source" grammar && builtins.hasAttr "git" grammar.source && builtins.hasAttr "rev" grammar.source; - isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git; - toGitHubFetcher = url: let - match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url; - in { - owner = builtins.elemAt match 0; - repo = builtins.elemAt match 1; - }; # If `use-grammars.only` is set, use only those grammars. # If `use-grammars.except` is set, use all other grammars. # Otherwise use all grammars. @@ -40,24 +33,13 @@ grammarsToUse = builtins.filter useGrammar languagesConfig.grammar; gitGrammars = builtins.filter isGitGrammar grammarsToUse; buildGrammar = grammar: let - gh = toGitHubFetcher grammar.source.git; - sourceGit = builtins.fetchTree { + source = builtins.fetchTree { type = "git"; url = grammar.source.git; rev = grammar.source.rev; ref = grammar.source.ref or "HEAD"; shallow = true; }; - sourceGitHub = builtins.fetchTree { - type = "github"; - owner = gh.owner; - repo = gh.repo; - inherit (grammar.source) rev; - }; - source = - if isGitHubGrammar grammar - then sourceGitHub - else sourceGit; in stdenv.mkDerivation { # see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix