-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Weechat plugin split #25274
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
Weechat plugin split #25274
Conversation
@lheckemann, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @lovek323 and @aneeshusa to be potential reviewers. |
56cf3ef
to
049036f
Compare
I would also appreciate if anyone could comment on whether they think lheckemann@e8bf1f9 is an improvement on this. It has yet to address the issue of plugin-specific environment variables properly, so is also WIP on top of this. |
platforms = stdenv.lib.platforms.unix; | ||
}; | ||
}; | ||
in weechat // { |
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 more standard way to extend expressions is to rely on .override
function. That means that have to specify withPlugins
as argument of weechat expression.
When somebody wants to use a customized weechat they will do something like:
custom_weechat = pkgs.weechat.override {
guileSupport = false;
withPlugins = [ plugin1, plugin2 ];
};
You can check neovim expression how I did it to conditionally (when configuration is present) return wrapped and configured neovim.
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'm aware of this; the idea behind the approach I've used here is to take advantage of weechat's modularity to significantly reduce weechat's closure size without the need for rebuilding weechat itself (as is necessary if any of the xSupport
flags are passed in). Customising weechat's plugins has already been possible simply by disabling them in the build, but that means that it needs to be rebuilt on the user's end which somewhat dampens the resulting improvement in closure size as all the build deps need to be available (at least initially) and the build takes longer.
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.
using withPlugins
in does not go against reducing weechat's closure size. If you looked at neovim's expression you will see that by default default weechat is returned. if plugins are set you wrap the returning weechat executable. The only things that changes is how you go about customizing this. The preferred way to do this is via .override
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.
Right, that makes sense... so something like d421f4aefcaddf0ec07582ffb62fa6f625dd8f96 ?
(usage: weechat.override {withPlugins = ["perl" "python" "ruby"];}
)
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.
👍
@lheckemann to not wait for upstream you could also point to that PR and add it to the patches list. |
Of course, I forgot about that! |
src = fetchFromGitHub { | ||
owner = "lheckemann"; | ||
repo = "weechat"; | ||
rev = "546e260fd58e41db20e7bc4ec5585e93fb6994c1"; |
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 this v1.7.1 tag?
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.
No, it's master as of yesterday + my patch. I've changed it back to use v1.7.1 plus my patch
368edaf
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.
sorry commenting on old code :)
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.
@lheckemann 💯 on the change. I would just squash the commits before we merge this to nixpkgs.
Yes, that was my plan. I also still need to fix the perl/python path stuff in the wrapper — currently just |
It also still needs docs, which I don't know where to put. |
This definitely isn't ready for merging yet — for instance, |
@lheckemann I think you can open a new section about weechat at Chapter 10. Package Notes I'll do a bit of dreaming in this comment and you stop me when I go too far :P Also I'm interested to work on this myself, just for some things I'm too short on my skills. (1) nixos module: maybe it would be worthwhile to also create a nixos module for weechat. eg
(2) like with plugins it would be nice to have a variable to configure weechat to write logs in location other then (3) configuring weechat: it would be also nice to be able to disallow weechat to write configuration. and create a nice way to configure weechat (eg. like i already do with neovim for example), we could add this as an argument like withPlugins (4) work on weechat2nix script that will package weechat plugins |
|
|
Yeah, I'll have a look at making those changes to weechat in the next few days. As for script installation, yes I guess that would be the logical next step from there. I'll see what I can do! |
The python plugin needs some python libraries on its path. I think the right solution would be to allow passing in a python environment as created by weechat.override { configure = {
plugins = ["python"];
environment = {
PYTHON_HOME = python.withPackages (ps: with ps; [pycrypto dbus-python]);
};
};} But I'm not really sure if this is a nice way to do it, particularly because it relies on "magical" values so much. It would be nicer if it could somehow be included in the plugins attribute, something like weechat.override { configure = {
plugins = available: [
(available.python.withPackages (ps: with ps; [pycrypto python-dbus]))
];
};} or even weechat.override {
configure = {availablePlugins, ...}: {
plugins = [availablePlugins.python.withPackages (ps: with ps; [pycrypto python-dbus])];
};
} But all of these look rather complicated to use. Any thoughts? |
@lheckemann does the basic package, without plugins, need Python, or is it only needed for a plugin? If it does not build against a Python env, then you can just add the Python env to |
pluginFile = "${weechat.python}/lib/weechat/plugins/python.so"; | ||
withPackages = pkgsFun: (python // { | ||
extraEnv = '' | ||
export PYTHONHOME="${pythonPackages.python.withPackages pkgsFun}" |
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.
This is not going to work. python.withPackages
uses itself --set PYTHONHOME
.
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.
It worked for me.
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 python.withPackages does is build an environment containing symlinks to all the packages and a python wrapper which sets PYTHONHOME
to the location of the resulting environment. The wrapper won't actually be used by weechat's python plugin, but the python plugin does load the python interpreter as a shared library and at that point the interpreter looks at PYTHONHOME to see where to import stuff from.
ln -s $plugin $out/plugins | ||
done | ||
''; | ||
in writeScriptBin "weechat" '' |
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.
Have you considered using buildEnv
for composition? This does look neat btw.
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.
Not sure how that would work in this case, since the paths are the actual shared libraries and not the derivations.
The python plugin for weechat requires python obviously. It does not execute python as a process though, it uses the library interface to the interpreter, so I think the approach I'm taking is the right one? |
b041f15
to
9fb0d2a
Compare
That's it documented. If nobody has any further objections, I'll rebase and squash for the actual merge. |
8415302
to
f0291e0
Compare
<section xml:id="sec-weechat"> | ||
<title>Weechat</title> | ||
<para> | ||
Weechat can currently be configured to include your choice of 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.
"You can configure plugins as follows" is shorter and says the same.
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.
Explicitly mentioning that this is an expression to install is more helpful, as some other packages are configured via nixpkgs config settings instead.
ceefe38
to
cb8360a
Compare
@lheckemann I'd like to give the final word to whoever maintains this |
cb8360a
to
e79a846
Compare
Oh yeah, maybe @the-kenny and @lovek323 would like to weigh in as well :) |
@lheckemann merge conflicts can you rebase? Also @garbas @the-kenny and @lovek323 we're looking for feedback here. If we don't get a response, I say we go ahead and merge it. |
Also add a wrapper generator that allows adding the plugins back conveniently and corresponding documentation in the package notes section of the nixpkgs manual.
e79a846
to
05f96bf
Compare
Would this PR make it possible to use plugins like https://github.com/wee-slack/wee-slack which, for instance, depend on other Python packages? |
@jluttine yes, see the addition to the manual for details on how. The packages in question do need to be included in nixpkgs though. |
@lheckemann are there any remaining blockers? I've packaged some Weechat plugins for Nixpkgs and I'd try to make them compatible with this in the next time :-) |
Just approval from maintainers. |
ah nice :-D |
@lheckemann just to ensure that I got this right: your change adds the ability to builda weechat with plugins. |
Yes, in principle: they're concerned with different parts of weechat, mine is for plugins and yours for scripts. I think the "patch weechat to search an alternative path" approach would be nicer than building a FHS env for scripts too, but I don't see any reason the latter approach would be incompatible with this PR either. |
just found your weechat patch. If such an approach is applicable to weechat scripts as well, I'll close this and open another PR
… On 17. Nov 2017, at 10:32 AM, Linus Heckemann ***@***.***> wrote:
Yes, in principle: they're concerned with different parts of weechat, mine is for plugins and yours for scripts. I think the "patch weechat to search an alternative path" approach would be nicer than building a FHS env for scripts too, but I don't see any reason the latter approach would be incompatible with this PR either.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I started using this feature and it seems really great. I figured out how to add Python dependencies that some scripts need, but I couldn't figure out how to do the same for Lua dependencies.. There's no |
Yes, it doesn't currently have support for this, largely because lua library support in nixpkgs isn't that great in general as far as I remember. I seem to remember @teto doing some work on that, maybe you can advise? |
the work is visible here #33903. It works well except for some torch packages. I have yet to understand what's the problem there. |
Ok, thanks! So at the moment, weechat cannot be used with lua dependencies. (?) |
Other packages hack their way around via adjusting the LUA_PATH in a wrapper but if you are not hurry, there should be a better way soon :) |
Motivation for this change
#22746
This change moves each language plugin into a separate output, significantly reducing weechat's closure size. It also adds a
withPlugins
function to weechat, which generates a wrapper for adding the plugins.This relies on weechat/weechat#971 and so probably shouldn't be merged until the next stable release which will (hopefully!) include that change.
This is probably my biggest nixpkgs change yet, so I'm PRing it now in search of feedback — any input would be highly appreciated! Particularly, the way in which I add the
withPlugins
function to weechat. This should allow using it likeweechat.withPlugins [weechat.ruby weechat.guile]
, but is there a more elegant way of adding it than the set union I'm doing here? I'd also like to know what people think about the mechanism as a whole, i.e. how this runtime composition is implemented.Checklist before this can be merged:
Search WEECHAT_EXTRA_LIBDIR for plugins weechat/weechat#971 merged and incorporated into a releasepatch added to expression insteadIdeas:
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)