1# WeeChat {#sec-weechat}
2
3WeeChat can be configured to include your choice of plugins, reducing its closure size from the default configuration which includes all available plugins. To make use of this functionality, install an expression that overrides its configuration, such as:
4
5```nix
6weechat.override {configure = {availablePlugins, ...}: {
7 plugins = with availablePlugins; [ python perl ];
8 }
9}
10```
11
12If the `configure` function returns an attrset without the `plugins` attribute, `availablePlugins` will be used automatically.
13
14The plugins currently available are `python`, `perl`, `ruby`, `guile`, `tcl` and `lua`.
15
16The Python and Perl plugins allows the addition of extra libraries. For instance, the `inotify.py` script in `weechat-scripts` requires D-Bus or libnotify, and the `fish.py` script requires `pycrypto`. To use these scripts, use the plugin's `withPackages` attribute:
17
18```nix
19weechat.override { configure = {availablePlugins, ...}: {
20 plugins = with availablePlugins; [
21 (python.withPackages (ps: with ps; [ pycrypto python-dbus ]))
22 ];
23 };
24}
25```
26
27In order to also keep all default plugins installed, it is possible to use the following method:
28
29```nix
30weechat.override { configure = { availablePlugins, ... }: {
31 plugins = builtins.attrValues (availablePlugins // {
32 python = availablePlugins.python.withPackages (ps: with ps; [ pycrypto python-dbus ]);
33 });
34}; }
35```
36
37WeeChat allows to set defaults on startup using the `--run-command`. The `configure` method can be used to pass commands to the program:
38
39```nix
40weechat.override {
41 configure = { availablePlugins, ... }: {
42 init = ''
43 /set foo bar
44 /server add libera irc.libera.chat
45 '';
46 };
47}
48```
49
50Further values can be added to the list of commands when running `weechat --run-command "your-commands"`.
51
52Additionally, it's possible to specify scripts to be loaded when starting `weechat`. These will be loaded before the commands from `init`:
53
54```nix
55weechat.override {
56 configure = { availablePlugins, ... }: {
57 scripts = with pkgs.weechatScripts; [
58 weechat-xmpp weechat-matrix-bridge wee-slack
59 ];
60 init = ''
61 /set plugins.var.python.jabber.key "val"
62 '':
63 };
64}
65```
66
67In `nixpkgs` there's a subpackage which contains derivations for WeeChat scripts. Such derivations expect a `passthru.scripts` attribute, which contains a list of all scripts inside the store path. Furthermore, all scripts have to live in `$out/share`. An exemplary derivation looks like this:
68
69```nix
70{ stdenv, fetchurl }:
71
72stdenv.mkDerivation {
73 name = "exemplary-weechat-script";
74 src = fetchurl {
75 url = "https://scripts.tld/your-scripts.tar.gz";
76 hash = "...";
77 };
78 passthru.scripts = [ "foo.py" "bar.lua" ];
79 installPhase = ''
80 mkdir $out/share
81 cp foo.py $out/share
82 cp bar.lua $out/share
83 '';
84}
85```