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 {
7 configure = (
8 { availablePlugins, ... }:
9 {
10 plugins = with availablePlugins; [
11 python
12 perl
13 ];
14 }
15 );
16}
17```
18
19If the `configure` function returns an attrset without the `plugins` attribute, `availablePlugins` will be used automatically.
20
21The plugins currently available are `python`, `perl`, `ruby`, `guile`, `tcl` and `lua`.
22
23The Python and Perl plugins allow 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:
24
25```nix
26weechat.override {
27 configure =
28 { availablePlugins, ... }:
29 {
30 plugins = with availablePlugins; [
31 (python.withPackages (
32 ps: with ps; [
33 pycrypto
34 python-dbus
35 ]
36 ))
37 ];
38 };
39}
40```
41
42In order to also keep all default plugins installed, it is possible to use the following method:
43
44```nix
45weechat.override {
46 configure =
47 { availablePlugins, ... }:
48 {
49 plugins = builtins.attrValues (
50 availablePlugins
51 // {
52 python = availablePlugins.python.withPackages (
53 ps: with ps; [
54 pycrypto
55 python-dbus
56 ]
57 );
58 }
59 );
60 };
61}
62```
63
64WeeChat allows to set defaults on startup using the `--run-command`. The `configure` method can be used to pass commands to the program:
65
66```nix
67weechat.override {
68 configure =
69 { availablePlugins, ... }:
70 {
71 init = ''
72 /set foo bar
73 /server add libera irc.libera.chat
74 '';
75 };
76}
77```
78
79Further values can be added to the list of commands when running `weechat --run-command "your-commands"`.
80
81Additionally, it's possible to specify scripts to be loaded when starting `weechat`. These will be loaded before the commands from `init`:
82
83```nix
84weechat.override {
85 configure =
86 { availablePlugins, ... }:
87 {
88 scripts = with pkgs.weechatScripts; [
89 weechat-xmpp
90 weechat-matrix-bridge
91 wee-slack
92 ];
93 init = ''
94 /set plugins.var.python.jabber.key "val"
95 '';
96 };
97}
98```
99
100In `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:
101
102```nix
103{ stdenv, fetchurl }:
104
105stdenv.mkDerivation {
106 name = "exemplary-weechat-script";
107 src = fetchurl {
108 url = "https://scripts.tld/your-scripts.tar.gz";
109 hash = "...";
110 };
111 passthru.scripts = [
112 "foo.py"
113 "bar.lua"
114 ];
115 installPhase = ''
116 runHook preInstall
117
118 mkdir $out/share
119 cp foo.py $out/share
120 cp bar.lua $out/share
121
122 runHook postInstall
123 '';
124}
125```