2018-01-06 13:25:13 +00: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 16:01:57 +01:00
|
|
|
sessionName = mkOption {
|
|
|
|
description = "Name of the `screen' session for weechat.";
|
|
|
|
default = "weechat-screen";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
binary = mkOption {
|
2021-01-31 11:34:31 +00:00
|
|
|
type = types.path;
|
2021-10-03 17:06:03 +01:00
|
|
|
description = "Binary to execute.";
|
2018-09-05 16:01:57 +01:00
|
|
|
default = "${pkgs.weechat}/bin/weechat";
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression ''"''${pkgs.weechat}/bin/weechat"'';
|
|
|
|
example = literalExpression ''"''${pkgs.weechat}/bin/weechat-headless"'';
|
2018-09-05 16:01:57 +01:00
|
|
|
};
|
2018-01-06 13:25:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users = {
|
2018-09-05 16:01:57 +01:00
|
|
|
groups.weechat = {};
|
2018-01-06 13:25:13 +00:00
|
|
|
users.weechat = {
|
|
|
|
createHome = true;
|
|
|
|
group = "weechat";
|
|
|
|
home = cfg.root;
|
2018-09-05 16:01:57 +01:00
|
|
|
isSystemUser = true;
|
2018-01-06 13:25:13 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.weechat = {
|
|
|
|
environment.WEECHAT_HOME = cfg.root;
|
|
|
|
serviceConfig = {
|
|
|
|
User = "weechat";
|
|
|
|
Group = "weechat";
|
2018-09-05 16:01:57 +01:00
|
|
|
RemainAfterExit = "yes";
|
2018-01-06 13:25:13 +00:00
|
|
|
};
|
2018-10-10 00:20:42 +01:00
|
|
|
script = "exec ${config.security.wrapperDir}/screen -Dm -S ${cfg.sessionName} ${cfg.binary}";
|
2018-01-06 13:25:13 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
wants = [ "network.target" ];
|
|
|
|
};
|
2018-10-10 00:20:42 +01:00
|
|
|
|
2021-09-12 17:53:48 +01:00
|
|
|
security.wrappers.screen =
|
|
|
|
{ setuid = true;
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
source = "${pkgs.screen}/bin/screen";
|
|
|
|
};
|
2018-01-06 13:25:13 +00:00
|
|
|
};
|
2018-09-05 16:01:57 +01:00
|
|
|
|
|
|
|
meta.doc = ./weechat.xml;
|
2018-01-06 13:25:13 +00:00
|
|
|
}
|