git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/weechat: cleanup module, add module documentation

This adds several improvements the previously introduced `services.weechat` module: * Dropped `services.weechat.init` as the initialization script can now be done on package-level since 2af41719bc using the `configure` function. * Added `sessionName` option to explicitly configure a name for the `screen` session (by default: weechat-screen). * Added `binary` option to configure the binary name (e.g. `weechat-headless`). * Added docs regarding `screen` session and `weechat.service`.

commit18d419141df4958e8438b7883d6c061609f8170b authorMaximilian Bosch <maximilian@mbosch.me> dateWed 5 Sep 2018, 17:01 (8 years ago) parenta8efe61
2 files changed+79−29
nixos/modules/services/misc/weechat.nix+18−29 nixos/modules/services/misc/weechat.xml+61
nixos/modules/services/misc/weechat.nix+18−29
@@ -9,28 +9,33 @@ in
99{
1010 options.services.weechat = {
1111 enable = mkEnableOption "weechat";
12− init = mkOption {
13− description = "Weechat commands applied at start, one command per line.";
14− example = ''
15− /set relay.network.password correct-horse-battery-staple
16− /relay add weechat 9001
17− '';
18− type = types.str;
19− default = "";
20− };
2112 root = mkOption {
2213 description = "Weechat state directory.";
2314 type = types.str;
2415 default = "/var/lib/weechat";
2516 };
17+ sessionName = mkOption {
18+ description = "Name of the `screen' session for weechat.";
19+ default = "weechat-screen";
20+ type = types.str;
21+ };
22+ binary = mkOption {
23+ description = "Binary to execute (by default \${weechat}/bin/weechat).";
24+ example = literalExample ''
25+ ''${pkgs.weechat}/bin/weechat-headless
26+ '';
27+ default = "${pkgs.weechat}/bin/weechat";
28+ };
2629 };
2730
2831 config = mkIf cfg.enable {
2932 users = {
33+ groups.weechat = {};
3034 users.weechat = {
3135 createHome = true;
3236 group = "weechat";
3337 home = cfg.root;
38+ isSystemUser = true;
3439 };
3540 };
3641
@@ -39,29 +44,13 @@ in
3944 serviceConfig = {
4045 User = "weechat";
4146 Group = "weechat";
47+ RemainAfterExit = "yes";
4248 };
43− script = "exec ${pkgs.screen}/bin/screen -D -m ${pkgs.weechat}/bin/weechat";
49+ script = "exec ${pkgs.screen}/bin/screen -Dm -S ${cfg.sessionName} ${cfg.binary}";
4450 wantedBy = [ "multi-user.target" ];
4551 wants = [ "network.target" ];
4652 };
47−
48− systemd.paths.weechat-fifo = {
49− pathConfig = {
50− PathExists = "${cfg.root}/weechat_fifo";
51− Unit = "weechat-apply-init.service";
52− };
53− wantedBy = [ "multi-user.target" ];
54− };
55−
56− systemd.services.weechat-apply-init = let
57− initFile = pkgs.writeText "weechat-init" cfg.init;
58− in {
59− script = "sed 's/^/*/' ${initFile} > ${cfg.root}/weechat_fifo";
60− serviceConfig = {
61− Type = "oneshot";
62− User = "weechat";
63− Group = "weechat";
64− };
65− };
6653 };
54+
55+ meta.doc = ./weechat.xml;
6756}
nixos/modules/services/misc/weechat.xmlnew file+61
@@ -0,0 +1,61 @@
1+<chapter xmlns="http://docbook.org/ns/docbook"
2+ xmlns:xlink="http://www.w3.org/1999/xlink"
3+ xmlns:xi="http://www.w3.org/2001/XInclude"
4+ version="5.0"
5+ xml:id="module-services-weechat">
6+
7+<title>WeeChat</title>
8+<para><link xlink:href="https://weechat.org/">WeeChat</link> is a fast and extensible IRC client.</para>
9+
10+<section><title>Basic Usage</title>
11+<para>
12+By default, the module creates a
13+<literal><link xlink:href="https://www.freedesktop.org/wiki/Software/systemd/">systemd</link></literal> unit
14+which runs the chat client in a detached
15+<literal><link xlink:href="https://www.gnu.org/software/screen/">screen</link></literal> session.
16+
17+</para>
18+
19+<para>
20+This can be done by enabling the <literal>weechat</literal> service:
21+
22+<programlisting>
23+{ ... }:
24+
25+{
26+ <link linkend="opt-services.weechat.enable">services.weechat.enable</link> = true;
27+}
28+</programlisting>
29+</para>
30+<para>
31+The service is managed by a dedicated user
32+named <literal>weechat</literal> in the state directory
33+<literal>/var/lib/weechat</literal>.
34+</para>
35+</section>
36+<section><title>Re-attaching to WeeChat</title>
37+<para>
38+WeeChat runs in a screen session owned by a dedicated user. To explicitly
39+allow your another user to attach to this session, the <literal>screenrc</literal> needs to be tweaked
40+by adding <link xlink:href="https://www.gnu.org/software/screen/manual/html_node/Multiuser.html#Multiuser">multiuser</link> support:
41+
42+<programlisting>
43+{
44+ <link linkend="opt-programs.screen.screenrc">programs.screen.screenrc</link> = ''
45+ multiuser on
46+ acladd normal_user
47+ '';
48+}
49+</programlisting>
50+
51+Now, the session can be re-attached like this:
52+
53+<programlisting>
54+screen -r weechat-screen
55+</programlisting>
56+</para>
57+<para>
58+<emphasis>The session name can be changed using <link linkend="opt-services.weechat.sessionName">services.weechat.sessionName.</link></emphasis>
59+</para>
60+</section>
61+</chapter>