2018-01-06 14:25:13 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.weechat;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.services.weechat = {
|
2022-08-28 21:18:44 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "weechat");
|
2018-01-06 14:25:13 +01:00
|
|
|
root = mkOption {
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Weechat state directory.";
|
2018-01-06 14:25:13 +01:00
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/weechat";
|
|
|
|
};
|
2018-09-05 17:01:57 +02:00
|
|
|
sessionName = mkOption {
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Name of the `screen' session for weechat.";
|
2018-09-05 17:01:57 +02:00
|
|
|
default = "weechat-screen";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
binary = mkOption {
|
2021-01-31 12:34:31 +01:00
|
|
|
type = types.path;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "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
|
|
|
}
|