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
kakoune: rework plugin support #91792
Conversation
@jcpetruzza FWIW, I have been using Kakoune on macOS installed with this patch for weeks now, it fixed a problem I had with the previous setup and seems to be working great. What is needed to get this merged? |
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 think I (the original author of the plugin support being changed here) like this approach.
👍 Using symlinkJoin.
👍 Copying the kak binary instead of the big and potentially fragile wrapper script.
👎 Renaming the packages.
Renaming the packages will break existing users. kakoune-unwrapped
was the name introduced by the original PR, based on a request from @teto and precedent with neovim. I'm happy to go along with a name change if Nix has decided on a de-facto naming convention for this pattern, but otherwise it seems arbitrary.
Also, I'm not sure what's going on, but the |
Thanks for the feedback, @eraserhd! I'm not sure what is the convention for naming packages in nixpkgs, tbh. My understanding was that the The point about backwards compatibility is a very good one. If we were to go with |
@jcpetruzza I assume most people are currently using I get the naming thing, and that's really unfortunate. <rant/>Names are the principle method of abstraction in functional programming, and they should tell the caller their contract and hide the implementation details if possible.... hrmmm... <rant/> Ok, how about (Also, this PR now has conflicts from the recent release.) |
@jcpetruzza Hey, this would be nice to get merged... what do you think of the package renaming? Also, there's now a merge conflict to resolve. |
Yes, it'd be good to get this merged; it's been on my TODO list for a while, sorry! I'll be afk for the next two weeks, happy to look into it after that! Notice that nix-community/home-manager#1356 recently added support for kakoune plugins (so this now works via home-manager) but it requires I still think we should deprecate it, and use |
5cd4177
to
243e007
Compare
@eraserhd, I've updated the PR. Notable changes:
Let me know what you think? @joefiorini If you are able to try the new version on macOS again, that'd be great! |
Code looks good to me. I'm currently bisecting Darwin breakages this morning, so I haven't tested yet. Will post back when that's resolved. |
Took me a while to get a chance to look at it, but it is working nicely for me! |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
The previous implementation of plugin-support for the kakoune derivation was based on generating, at build time, a `plugins.kak` file that would source all .kak files in the list of plugins, and wrap the `kak` binary in a script that would add some command-line arguments so that this file gets loaded on start-up. The main problem with this approach is that the plugins' code get executed *after* the user's configuration file is loaded, so effectively one cannot automatically activate/configure these plugins. The idiomatic way of loading plugins is ensuring they end up installed somwhere under `share/kak/autoload`. Because plugins are already being packaged to have their code in `share/kak/autoload/plugins/<name-of-plugin>`, we can obtain a derivation that includes the plugins simply by doing a `symlinkJoin` of `kakoune-unwrapped` and all the requested plugins. For this to work, we need to fix two issues: 1. By default, kakoune makes `share/kak/autoload` a symbolic link to `share/kak/rc`, which contains all builtin definitions. We need to patch this to put the symlink under `share/kak/autoload/rc`, so that the join works. 2. By default kakoune expects the `autoload` directory to be in `../share/kak/autoload` relative to the location of the `kak` binary. We need to set the `KAKOUNE_RUNTIME` to point the symlinked share/kak for this to work.
So, kakoune takes the documentation shown for `:doc` from `$KAKOUNE_RUNTIME/share/kak/doc`. Unfortunately, it seems that it will ignore files that are symlinks. This is arguably a bug in kakoune, we workaround it for now by copying the content of the docfiles.
243e007
to
464804b
Compare
Following NixOS/nixpkgs#91792
Following NixOS/nixpkgs#91792
Following NixOS/nixpkgs#91792
Following NixOS/nixpkgs#91792
Motivation for this change
The previous implementation of plugin-support for the kakoune derivation
was based on generating, at build time, a
plugins.kak
file that wouldsource all .kak files in the list of plugins, and wrap the
kak
binaryin a script that would add some command-line arguments so that this
file gets loaded on start-up. The main problem with this approach
is that the plugins' code get executed after the user's configuration
file is loaded, so effectively one cannot automatically activate/configure
these plugins.
The idiomatic way of loading plugins is ensuring they end up installed
somwhere under
share/kak/autoload
. Because plugins are already beingpackaged to have their code in
share/kak/autoload/plugins/<name-of-plugin>
,we can obtain a
kakoune-with-plugins
derivation simply by doing asymlinkJoin
ofkakoune
and all the requested plugins.For this to work, we need to fix two issues:
By default, kakoune makes
share/kak/autoload
a symbolic link toshare/kak/rc
, which contains all builtin definitions. We needto patch this to put the symlink under
share/kak/autoload/rc
, so thatthe join works.
kakoune actually expects the
autoload
directory to be in../share/kak/autoload
relative to the location of thekak
binary(and this can't currently be overriden, say, with environment. So we set the newly addedvariables), so we can't rely on a symlink for the
kak
binary andneed to copy it instead
KAKOUNE_RUNTIME
environment variable.
Things done
sandbox
innix.conf
on non-NixOS linux)Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)