NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.94k stars 13.96k forks source link

use buildEnv instead of custom function in packDir #193070

Closed teto closed 2 years ago

teto commented 2 years ago

Describe the bug

vimUtils doesn't handle conflict in plugin names when creating the packdir (unlike buildEnv ): it just aborts. For instance the build will fail if you try to install these 2 vim plugins at the same time:

      plugin = (nvim-treesitter.withPlugins (
          plugins: with plugins; [
            tree-sitter-bash
            tree-sitter-c
            tree-sitter-lua
            tree-sitter-http
            tree-sitter-json
            tree-sitter-nix
            # tree-sitter-haskell # crashes with a loop
            tree-sitter-python
            tree-sitter-html  # for rest.nvim
            tree-sitter-norg
            tree-sitter-org-nvim
          ]
        ));

  orgmode = super.orgmode.overrideAttrs (old: {
    dependencies = with self; [ nvim-treesitter ];
  });

The install triggers the error in this code generated by pkgs/applications/editors/vim/plugins/vim-utils.nix

mkdir -p $out/pack/myNeovimPackages/start
if test -e "$out/pack/myNeovimPackages/start/nvim-treesitter"; then
  printf "\nERROR - Duplicated vim plugin: nvim-treesitter\n\n"
  exit 1
fi
ln -sf /nix/store/as7zwcpbk6k07wkhqahhkz75c1gm47n8-vimplugin-nvim-treesitter-2022-09-19/. $out/pack/myNeovimPackages/start/nvim-treesitter

Might be best to use buildEnv there instead of having our own logic. https://github.com/NixOS/nixpkgs/blob/14467fed7f44d6ec06e4fb303e3713cd1b609d69/pkgs/applications/editors/vim/plugins/vim-utils.nix#L175

Related: https://github.com/NixOS/nixpkgs/pull/146237

NB: comment for myself: comments at pkgs/applications/editors/vim/plugins/vim-utils.nix seem out of date

teto commented 2 years ago

I've got a fix locally, patch incoming