-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
neovim: make the derivation more composable #344541
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(comments and questions only)
# TODO use (coercedTo package (v: { plugin = v; }) pluginWithConfigType); | ||
map (x: defaultPlugin // (if (x ? plugin) then x else { plugin = x; })) plugins; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: is there a module option somewhere that relates to this? I'm struggling to see how types.coercedTo
is relevant otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some local code that uses nixosModule to generate the neovim config. Sadly I cant ever seem to finish it. It's not releveant here I will remove the comment
assert withPython2 -> throw "Python2 support has been removed from the neovim wrapper, please remove withPython2 and python2Env."; | ||
|
||
# assert packpathDirs -> throw "Packpathdirs removed"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# assert packpathDirs -> throw "Packpathdirs removed"; | |
assert lib.assertMsg (attrs ? packpathDirs) "packpathDirs removed"; |
I believe best practice though would be to remove the ...
so that only supported args can be passed? Unless the args truly can be anything and will be passed on to another function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
funny I am of the opposite opinion ^^' it lets the package be forward and backward compatible (you can mix different versions of nixpkgs) and add warnings such as this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe best practice though would be to remove the ... so that only supported args can be passed?
I believe I was advised this when contributing to /lib
. EDIT: #315411 (comment)
IIRC the argument was something along the lines of: it's better for the function signature to not be forward/backward compatible in ways that the function itself is not.
e.g. if someone uses a feature of the function that is supported by a newer nixpkgs than they have, they would not know that the feature has no effect.
Backwards compatibility can still be achieved by keeping stub foo ? null,
parameters in the signature, but forward compatibility is more difficult because we don't know what will be added in the future.
Either way, the ...
isn't added by this PR, so this isn't feedback on the PR itself, just commenting on the existing code 🙃
|
||
finalPackdir = neovimUtils.packDir packpathDirs; | ||
|
||
rcContent = '' | ||
${luaRcContent} | ||
'' + lib.optionalString (!isNull neovimRcContent) '' | ||
vim.cmd.source "${writeText "init.vim" neovimRcContent}" | ||
'' + lib.optionalString (!isNull neovimRcContent') '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC isNull
is deprecated, if the line is being touched anyway we can migrate to != null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know about that: do you have a reference ? isNull is a builtins so I am surprised it gets removed. But yeah np problem for changing it to != null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ (lib.concatMap (f: f ps) pluginPython3Packages)); | ||
|
||
packpathDirs.myNeovimPackages = myVimPackage; | ||
|
||
wrapperArgsStr = if lib.isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be useful to also have a runtimeInputs
or dependencies
argument that prepends to PATH via the wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally. This will be unblocked by this PR. I prefer it to be done as a follow up though since neovim is a touchy derivation: you quickly know when you break something xD and this has the potential to break configs already (at least for people using the "private/unstable" APIs)
4ba0a81
to
857dad5
Compare
, withNodeJs ? false | ||
, withRuby ? true | ||
/* the function you would have passed to lua.withPackages */ | ||
, extraLuaPackages ? (_: [ ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the new expected way of handling adding extraLuaPackages to a config? I didn't see this argument moved to the wrapper like extraPython3Packages was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In relation to https://buildbot.nix-community.org/#/builders/2809/builds/1218 trying to figure out what we need to change in https://github.com/nix-community/nixvim/blob/0ca98d02104f7f0a703787a7a080a570b7f1bedd/modules/top-level/output.nix#L266
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are absolutely correct. I would like to avoid adding them to the wrapper as extraLuaPackages was a workaround to specify plugin dependencies. Lua dependencies are now loaded correctly in the wrapper via shell hooks. A user could call the wrapper directly adding its own wrapper args to add externmal lua dependencies or convert a lua package with buildNeovimPlugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you could trigger the nnixvim job again, hopefully it is now fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, kicking off another build there
Now that we have structured attributes enabled, it's easier than ever to access the wrapper config from itself. Let's expose the 'plugins' derivations instead of the final 'packpathDir' with which one can't do much. TLDR: the neovim wrapper accepts a list of neovim derivations in `plugins` instead of the symlinkJoin of plugins in `packpathDir`. With exposed plugins, one could tweak the current wrapper with more plugins, e.g. neovim.withPlugins([fugitive]).withPlugins([plenary]) . we could also add a boolean to autoadd the plugins passthru.initLua, better handle the dependencies (runtime programs, python deps).
857dad5
to
4ebef43
Compare
@@ -19,9 +23,12 @@ let | |||
# should contain all args but the binary. Can be either a string or list | |||
, wrapperArgs ? [] | |||
# a limited RC script used only to generate the manifest for remote plugins | |||
, manifestRc ? null | |||
# , manifestRc ? null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was something meant to be noted here for commenting this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty for spotting this, I removed it, it's generated a bit later in the wrapper.
Now that we have structured attributes enabled, it's easier than ever to
access the wrapper config from itself. Let's expose the plugins instead
of the packpathDir with which one can't do much.
With exposed plugins, one could tweak the current wrapper with more
plugins, e.g. neovim.withPlugins([fugitive]).withPlugins([plenary]) .
we could also add a boolean to autoadd the plugins passthru.initLua,
better handle the dependencies (runtime programs, python deps).
�
Description of changes
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.