Skip to content

neovim: make the derivation more composable#344541

Merged
GaetanLepage merged 2 commits intoNixOS:masterfrom
teto:teto/neovim-move-plugins-to-wrapper
Oct 13, 2024
Merged

neovim: make the derivation more composable#344541
GaetanLepage merged 2 commits intoNixOS:masterfrom
teto:teto/neovim-move-plugins-to-wrapper

Conversation

@teto
Copy link
Copy Markdown
Member

@teto teto commented Sep 25, 2024

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

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: vim Advanced text editor label Sep 25, 2024
@teto teto changed the title neovim: make the wrapper more evolvable neovim: make the derivation more composable Sep 25, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Sep 26, 2024
Copy link
Copy Markdown
Contributor

@MattSturgeon MattSturgeon left a 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)

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# 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.

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Contributor

@MattSturgeon MattSturgeon Oct 3, 2024

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 🙃

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's a warning on Noogle and nix.dev. Not a big deal but better to avoid usage if possible 🙂

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

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)

@teto teto force-pushed the teto/neovim-move-plugins-to-wrapper branch from 4ba0a81 to 857dad5 Compare October 3, 2024 22:05
@teto teto marked this pull request as ready for review October 3, 2024 22:13
@teto teto requested a review from figsoda as a code owner October 3, 2024 22:13
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Contributor

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

@teto teto force-pushed the teto/neovim-move-plugins-to-wrapper branch from 857dad5 to 4ebef43 Compare October 6, 2024 22:50
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

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.

teto added 2 commits October 11, 2024 00:25
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).
@teto teto force-pushed the teto/neovim-move-plugins-to-wrapper branch from e6388b4 to 7da346b Compare October 10, 2024 22:25
Indeed, note that wrapping with `-u init.vim` has sideeffects like .nvimrc wont be loaded
anymore, $MYVIMRC wont be set etc
*/
makeNeovimConfig =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this removed? Could you add a deprecation stub that throws an appropriate error message for any publicly exposed functions/etc that have been removed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, my mistake. This is not removed. Is anything else removed without a throw?

@GaetanLepage
Copy link
Copy Markdown
Contributor

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 344541


x86_64-linux

✅ 8 packages built:
  • gnvim
  • lunarvim
  • neovide
  • neovim-qt
  • neovim-remote
  • neovim-remote.dist
  • nvimpager
  • vim-startuptime

aarch64-linux

✅ 8 packages built:
  • gnvim
  • lunarvim
  • neovide
  • neovim-qt
  • neovim-remote
  • neovim-remote.dist
  • nvimpager
  • vim-startuptime

x86_64-darwin

✅ 5 packages built:
  • gnvim
  • lunarvim
  • neovim-qt
  • nvimpager
  • vim-startuptime

aarch64-darwin

✅ 6 packages built:
  • gnvim
  • lunarvim
  • neovide
  • neovim-qt
  • nvimpager
  • vim-startuptime

Copy link
Copy Markdown
Contributor

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

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

Let's merge this and tackle eventual problems in subsequent PRs.

@GaetanLepage GaetanLepage merged commit d2d9d9f into NixOS:master Oct 13, 2024
@teto teto deleted the teto/neovim-move-plugins-to-wrapper branch October 13, 2024 17:01
@obreitwi
Copy link
Copy Markdown
Member

Hey, thanks for your efforts.

Speaking of eventual problems:
Some commit between b69de56..d4f247e caused programs.neovim.plugins.<plugin>.config (example) to not show up in the final vimrc at all.

I have a suspicion that it might be this PR, wanted to leave a quick note prior to investigating further.

@MattSturgeon
Copy link
Copy Markdown
Contributor

Hey, thanks for your efforts.

Speaking of eventual problems: Some commit between b69de56..d4f247e caused programs.neovim.plugins.<plugin>.config (example) to not show up in the final vimrc at all.

This sounds like what we were discussing over at nix-community/nixvim#2343 (comment) (onwards)

@teto teto mentioned this pull request Oct 21, 2024
12 tasks
azuwis added a commit to azuwis/nixpkgs that referenced this pull request Oct 29, 2024
The wrapper refactor NixOS#344541
effectively make withRuby always enabled.

Fix NixOS#351839.
@azuwis azuwis mentioned this pull request Oct 29, 2024
13 tasks
teto pushed a commit that referenced this pull request Oct 29, 2024
The wrapper refactor #344541
effectively make withRuby always enabled.

Fix #351839.
keatonhasse pushed a commit to keatonhasse/nixpkgs that referenced this pull request Oct 30, 2024
The wrapper refactor NixOS#344541
effectively make withRuby always enabled.

Fix NixOS#351839.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: vim Advanced text editor 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants