2018-01-06 13:25:13 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.weechat;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options.services.weechat = {
|
2024-04-13 12:54:15 +00:00
|
|
|
enable = mkEnableOption "weechat";
|
2018-01-06 13:25:13 +00:00
|
|
|
root = mkOption {
|
2024-04-13 12:54:15 +00:00
|
|
|
description = "Weechat state directory.";
|
2018-01-06 13:25:13 +00:00
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/weechat";
|
|
|
|
};
|
2018-09-05 15:01:57 +00:00
|
|
|
sessionName = mkOption {
|
2024-04-13 12:54:15 +00:00
|
|
|
description = "Name of the `screen` session for weechat.";
|
2018-09-05 15:01:57 +00:00
|
|
|
default = "weechat-screen";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
binary = mkOption {
|
2021-01-31 11:34:31 +00:00
|
|
|
type = types.path;
|
2024-04-13 12:54:15 +00:00
|
|
|
description = "Binary to execute.";
|
2018-09-05 15:01:57 +00:00
|
|
|
default = "${pkgs.weechat}/bin/weechat";
|
2021-10-03 16:06:03 +00:00
|
|
|
defaultText = literalExpression ''"''${pkgs.weechat}/bin/weechat"'';
|
|
|
|
example = literalExpression ''"''${pkgs.weechat}/bin/weechat-headless"'';
|
2018-09-05 15:01:57 +00:00
|
|
|
};
|
2018-01-06 13:25:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users = {
|
2018-09-05 15:01:57 +00:00
|
|
|
groups.weechat = {};
|
2018-01-06 13:25:13 +00:00
|
|
|
users.weechat = {
|
|
|
|
createHome = true;
|
|
|
|
group = "weechat";
|
|
|
|
home = cfg.root;
|
2018-09-05 15:01:57 +00: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 15:01:57 +00:00
|
|
|
RemainAfterExit = "yes";
|
2018-01-06 13:25:13 +00:00
|
|
|
};
|
2018-10-09 23:20:42 +00: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-09 23:20:42 +00:00
|
|
|
|
2021-09-12 16:53:48 +00: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 15:01:57 +00:00
|
|
|
|
2023-01-24 23:33:40 +00:00
|
|
|
meta.doc = ./weechat.md;
|
2018-01-06 13:25:13 +00:00
|
|
|
}
|