Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildNeovimPlugin: pass a derivation to luaAttr #343564

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkgs/applications/editors/neovim/build-neovim-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ in
{
# the lua attribute name that matches this vim plugin. Both should be equal
# in the majority of cases but we make it possible to have different attribute names
luaAttr ? (normalizeName attrs.pname)
luaAttr ? (lua.pkgs.${normalizeName attrs.pname})
teto marked this conversation as resolved.
Show resolved Hide resolved
, ...
}@attrs:
let
originalLuaDrv = lua.pkgs.${luaAttr};
# warning added Sep 2024
originalLuaDrv = lib.warnIf (lib.typeOf luaAttr == "string") "luaAttr as string is deprecated. Pass a lua derivation directly ( e.g., `buildNeovimPlugin { luaAttr = lua.pkgs.plenary-nvim; }`)" luaAttr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: a deprecation causes a warning to be printed, but still works.
This is a breaking change, because passing in a string is no longer possible.

This should either use lib.throwIf (with the wording "no longer supported" instead of "deprecated" or it should use lib.warnIf and fall back to lua.pkgs.${luaAttr}.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed. I've converted it into an if/else in a followup commit and tested with luaAttr = "haskell-tools.nvim". If that's good for you. I'll squash on merge .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to restore the default for luaAttr else the plugins in vim/generated.nix would fail to eval. So if you dont set pname and luaAttr the eval will fail. I preferred to do that since the handling of vim/generated.nix will change one way or another.
(my first take is #342884 but I dont like adding yet another updater so hopefully we can do better)


luaDrv = originalLuaDrv.overrideAttrs (oa: {
version = attrs.version or oa.version;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/editors/vim/plugins/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TODO check that no license information gets lost
{ callPackage, config, lib, vimUtils, vim, darwin, llvmPackages
, neovim-unwrapped
, neovimUtils
, luaPackages
}:

let
Expand All @@ -27,7 +27,7 @@ let
overrides = callPackage ./overrides.nix {
inherit (darwin.apple_sdk.frameworks) Cocoa CoreFoundation CoreServices;
inherit buildVimPlugin;
inherit llvmPackages luaPackages;
inherit llvmPackages;
};

aliases = if config.allowAliases then (import ./aliases.nix lib) else final: prev: {};
Expand Down
27 changes: 15 additions & 12 deletions pkgs/applications/editors/vim/plugins/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
, languagetool
, llvmPackages
, meson
, neovim-unwrapped
, nim1
, nodePackages
, openscad
Expand Down Expand Up @@ -129,10 +130,12 @@
, # hurl dependencies
hurl
, # must be lua51Packages
luaPackages
, luajitPackages
luajitPackages
,
}: self: super:
let
luaPackages = neovim-unwrapped.lua.pkgs;
in
{
alpha-nvim = super.alpha-nvim.overrideAttrs {
dependencies = [
Expand Down Expand Up @@ -915,7 +918,7 @@
dependencies = with self; [ nvim-treesitter ];
};

haskell-tools-nvim = neovimUtils.buildNeovimPlugin { luaAttr = "haskell-tools-nvim"; };
haskell-tools-nvim = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.haskell-tools-nvim; };

hex-nvim = super.hex-nvim.overrideAttrs {
postPatch = ''
Expand Down Expand Up @@ -1058,19 +1061,19 @@
};

lsp-progress-nvim = neovimUtils.buildNeovimPlugin {
luaAttr = "lsp-progress-nvim";
luaAttr = luaPackages.lsp-progress-nvim;
nvimRequireCheck = "lsp-progress";
};

luasnip = super.luasnip.overrideAttrs {
dependencies = with self; [ luaPackages.jsregexp ];
};

lz-n = neovimUtils.buildNeovimPlugin { luaAttr = "lz-n"; };
lz-n = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.lz-n; };

lze = neovimUtils.buildNeovimPlugin { luaAttr = "lze"; };
lze = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.lze; };

lzn-auto-require = neovimUtils.buildNeovimPlugin { luaAttr = "lzn-auto-require"; };
lzn-auto-require = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.lzn-auto-require; };

magma-nvim-goose = buildVimPlugin {
pname = "magma-nvim-goose";
Expand Down Expand Up @@ -1146,7 +1149,7 @@
};

middleclass = neovimUtils.buildNeovimPlugin {
luaAttr = "middleclass";
luaAttr = luaPackages.middleclass;
nvimRequireCheck = "middleclass";
};

Expand Down Expand Up @@ -1506,17 +1509,17 @@
];
};

rocks-nvim = neovimUtils.buildNeovimPlugin { luaAttr = "rocks-nvim"; };
rocks-nvim = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.rocks-nvim; };

rocks-config-nvim = neovimUtils.buildNeovimPlugin { luaAttr = "rocks-config-nvim"; };
rocks-config-nvim = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.rocks-config-nvim; };

roslyn-nvim = super.roslyn-nvim.overrideAttrs {
dependencies = with self; [ nvim-lspconfig ];
};

rtp-nvim = neovimUtils.buildNeovimPlugin { luaAttr = "rtp-nvim"; };
rtp-nvim = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.rtp-nvim; };

rustaceanvim = neovimUtils.buildNeovimPlugin { luaAttr = "rustaceanvim"; };
rustaceanvim = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.rustaceanvim; };

sg-nvim = super.sg-nvim.overrideAttrs (old:
let
Expand Down
4 changes: 1 addition & 3 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38519,9 +38519,7 @@ with pkgs;

vimUtils = callPackage ../applications/editors/vim/plugins/vim-utils.nix { };

vimPlugins = recurseIntoAttrs (callPackage ../applications/editors/vim/plugins {
luaPackages = lua51Packages;
});
vimPlugins = recurseIntoAttrs (callPackage ../applications/editors/vim/plugins { });

vimb-unwrapped = callPackage ../applications/networking/browsers/vimb { };
vimb = wrapFirefox vimb-unwrapped { };
Expand Down