@@ -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}