diff options
author | Sebastian Zivota | 2024-01-14 14:11:40 +0000 |
---|---|---|
committer | GitHub | 2024-01-14 14:11:40 +0000 |
commit | a0b02106c35ede95438bd23069d2b7f999ed8684 (patch) | |
tree | 9b7c295925d07385da31ddd31682d4b72bbc5ecb | |
parent | 054ce3961af4006d66529fe5fbbc44b47e2ee079 (diff) |
Make nix flake respect unused grammars (#9326)
* Make nix flake respect unused grammars
* Use default value
* Refactor
* Take use-grammars.only into account
---------
Co-authored-by: Sebastian Zivota <sebastian.zivota@mailbox.org>
-rw-r--r-- | grammars.nix | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/grammars.nix b/grammars.nix index 843fa02a..5152b520 100644 --- a/grammars.nix +++ b/grammars.nix @@ -28,7 +28,17 @@ owner = builtins.elemAt match 0; repo = builtins.elemAt match 1; }; - gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar; + # If `use-grammars.only` is set, use only those grammars. + # If `use-grammars.except` is set, use all other grammars. + # Otherwise use all grammars. + useGrammar = grammar: + if languagesConfig?use-grammars.only then + builtins.elem grammar.name languagesConfig.use-grammars.only + else if languagesConfig?use-grammars.except then + !(builtins.elem grammar.name languagesConfig.use-grammars.except) + else true; + grammarsToUse = builtins.filter useGrammar languagesConfig.grammar; + gitGrammars = builtins.filter isGitGrammar grammarsToUse; buildGrammar = grammar: let gh = toGitHubFetcher grammar.source.git; sourceGit = builtins.fetchTree { |