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 {
|
2021-01-31 12:34:31 +01:00
|
|
|
type = types.path;
|
2021-10-03 18:06:03 +02:00
|
|
|
description = "Binary to execute.";
|
2018-09-05 17:01:57 +02:00
|
|
|
default = "${pkgs.weechat}/bin/weechat";
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression ''"''${pkgs.weechat}/bin/weechat"'';
|
|
|
|
example = literalExpression ''"''${pkgs.weechat}/bin/weechat-headless"'';
|
2018-09-05 17:01:57 +02:00
|
|
|
};
|
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
|
|
|
|
2021-09-12 18:53:48 +02:00
|
|
|
security.wrappers.screen =
|
|
|
|
{ setuid = true;
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
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
|
|
|
}
|