nvim-neorg / nixpkgs-neorg-overlay

Nixpkgs overlay for Neorg and related packages
MIT License
25 stars 6 forks source link

Bug with withAllGrammars #10

Open BirdeeHub opened 1 day ago

BirdeeHub commented 1 day ago

The overlay does not interact well with the new iterations to pkgs.neovimUtils.grammarToPlugin and thus also pkgs.nvim-treesitter.withAllGrammars

I get an error building with this grammar after the most recent update to pkgs.neovimUtils.grammarToPlugin, but the change fixes a lot of issues in nixpkgs, so this flake should be the one to update.

The interesting part of the stack trace is as follows.

Your entry to grammarPlugins does not contain an origGrammar field in some circumstances it seems


       … while evaluating a branch condition
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/lib/lists.nix:1793:28:
         1792|   */
         1793|   unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
             |                            ^
         1794|

       … while calling the 'elem' builtin
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/lib/lists.nix:1793:31:
         1792|   */
         1793|   unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
             |                               ^
         1794|

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'vimplugin-treesitter-grammar-norg_meta'
         whose name attribute is located at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'installQueries' of derivation 'vimplugin-treesitter-grammar-norg_meta'
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/applications/editors/neovim/utils.nix:210:7:
          209|       # See also https://github.com/NixOS/nixpkgs/pull/344849#issuecomment-2381447839
          210|       installQueries = !isNvimGrammar grammar;
             |       ^
          211|

       … in the argument of the not operator
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/applications/editors/neovim/utils.nix:210:25:
          209|       # See also https://github.com/NixOS/nixpkgs/pull/344849#issuecomment-2381447839
          210|       installQueries = !isNvimGrammar grammar;
             |                         ^
          211|

       … from call site
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/applications/editors/neovim/utils.nix:210:25:
          209|       # See also https://github.com/NixOS/nixpkgs/pull/344849#issuecomment-2381447839
          210|       installQueries = !isNvimGrammar grammar;
             |                         ^
          211|

       … while calling 'isNvimGrammar'
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/applications/editors/neovim/utils.nix:180:23:
          179|       nvimGrammars = lib.mapAttrsToList (name: value: value.origGrammar) vimPlugins.nvim-treesitter.grammarPlugins;
          180|       isNvimGrammar = x: builtins.elem x nvimGrammars;
             |                       ^
          181|

       … while calling the 'elem' builtin
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/applications/editors/neovim/utils.nix:180:26:
          179|       nvimGrammars = lib.mapAttrsToList (name: value: value.origGrammar) vimPlugins.nvim-treesitter.grammarPlugins;
          180|       isNvimGrammar = x: builtins.elem x nvimGrammars;
             |                          ^
          181|

       … while calling anonymous lambda
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/lib/attrsets.nix:1095:10:
         1094|     attrs:
         1095|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
         1096|

       … from call site
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/lib/attrsets.nix:1095:16:
         1094|     attrs:
         1095|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
         1096|

       … while calling anonymous lambda
         at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/applications/editors/neovim/utils.nix:179:48:
          178|
          179|       nvimGrammars = lib.mapAttrsToList (name: value: value.origGrammar) vimPlugins.nvim-treesitter.grammarPlugins;
             |                                                ^
          180|       isNvimGrammar = x: builtins.elem x nvimGrammars;

       error: attribute 'origGrammar' missing
       at /nix/store/jfdpyszsgvsnz68y36qi65irx7r6a52q-source/pkgs/applications/editors/neovim/utils.nix:179:55:
          178|
          179|       nvimGrammars = lib.mapAttrsToList (name: value: value.origGrammar) vimPlugins.nvim-treesitter.grammarPlugins;
             |                                                       ^
          180|       isNvimGrammar = x: builtins.elem x nvimGrammars;
BirdeeHub commented 1 day ago

sorry about the confusion, this is occuring on the most recent version

BirdeeHub commented 1 day ago
            p.nvim-treesitter.overrideAttrs (a: {
              passthru = a.passthru // {
                inherit builtGrammars allGrammars withPlugins withAllGrammars;
        grammarPlugins = a.passthru.grammarPlugins // {
            norg = norgGrammars.tree-sitter-norg;
            norg-meta = norgGrammars.tree-sitter-norg-meta;
        };
              };
            });

It looks like the grammars you are passing in here are not being passed through grammarToPlugin first.

Will try this and test