2018-01-06 14:25:13 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.weechat;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.services.weechat = {
|
|
|
|
enable = mkEnableOption "weechat";
|
|
|
|
root = mkOption {
|
|
|
|
description = "Weechat state directory.";
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/weechat";
|
|
|
|
};
|
2018-09-05 17:01:57 +02:00
|
|
|
sessionName = mkOption {
|
|
|
|
description = "Name of the `screen' session for weechat.";
|
|
|
|
default = "weechat-screen";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
binary = mkOption {
|
|
|
|
description = "Binary to execute (by default \${weechat}/bin/weechat).";
|
|
|
|
example = literalExample ''
|
|
|
|
''${pkgs.weechat}/bin/weechat-headless
|
|
|
|
'';
|
|
|
|
default = "${pkgs.weechat}/bin/weechat";
|
|
|
|
};
|
2018-01-06 14:25:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users = {
|
2018-09-05 17:01:57 +02:00
|
|
|
groups.weechat = {};
|
2018-01-06 14:25:13 +01:00
|
|
|
users.weechat = {
|
|
|
|
createHome = true;
|
|
|
|
group = "weechat";
|
|
|
|
home = cfg.root;
|
2018-09-05 17:01:57 +02:00
|
|
|
isSystemUser = true;
|
2018-01-06 14:25:13 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.weechat = {
|
|
|
|
environment.WEECHAT_HOME = cfg.root;
|
|
|
|
serviceConfig = {
|
|
|
|
User = "weechat";
|
|
|
|
Group = "weechat";
|
2018-09-05 17:01:57 +02:00
|
|
|
RemainAfterExit = "yes";
|
2018-01-06 14:25:13 +01:00
|
|
|
};
|
2018-10-10 01:20:42 +02:00
|
|
|
script = "exec ${config.security.wrapperDir}/screen -Dm -S ${cfg.sessionName} ${cfg.binary}";
|
2018-01-06 14:25:13 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
wants = [ "network.target" ];
|
|
|
|
};
|
2018-10-10 01:20:42 +02:00
|
|
|
|
|
|
|
security.wrappers.screen.source = "${pkgs.screen}/bin/screen";
|
2018-01-06 14:25:13 +01:00
|
|
|
};
|
2018-09-05 17:01:57 +02:00
|
|
|
|
|
|
|
meta.doc = ./weechat.xml;
|
2018-01-06 14:25:13 +01:00
|
|
|
}
|