2024-12-10 20:27:17 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2015-04-14 02:06:37 +03:00
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.lambdabot;
|
|
|
|
|
|
|
|
rc = builtins.toFile "script.rc" cfg.script;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
### configuration
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.lambdabot = {
|
|
|
|
|
2024-08-28 21:19:11 +02:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2015-04-14 02:06:37 +03:00
|
|
|
default = false;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Enable the Lambdabot IRC bot";
|
2015-04-14 02:06:37 +03:00
|
|
|
};
|
|
|
|
|
2024-08-28 21:19:11 +02:00
|
|
|
package = lib.mkPackageOption pkgs "lambdabot" { };
|
2015-04-14 02:06:37 +03:00
|
|
|
|
2024-08-28 21:19:11 +02:00
|
|
|
script = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2015-04-14 02:06:37 +03:00
|
|
|
default = "";
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Lambdabot script";
|
2015-04-14 02:06:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
### implementation
|
|
|
|
|
2024-08-28 21:19:11 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2015-04-14 02:06:37 +03:00
|
|
|
|
|
|
|
systemd.services.lambdabot = {
|
|
|
|
description = "Lambdabot daemon";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
# Workaround for https://github.com/lambdabot/lambdabot/issues/117
|
|
|
|
script = ''
|
|
|
|
mkdir -p ~/.lambdabot
|
|
|
|
cd ~/.lambdabot
|
2015-04-20 16:51:14 +03:00
|
|
|
mkfifo /run/lambdabot/offline
|
|
|
|
(
|
|
|
|
echo 'rc ${rc}'
|
|
|
|
while true; do
|
|
|
|
cat /run/lambdabot/offline
|
|
|
|
done
|
|
|
|
) | ${cfg.package}/bin/lambdabot
|
2015-04-14 02:06:37 +03:00
|
|
|
'';
|
2015-04-20 16:51:14 +03:00
|
|
|
serviceConfig = {
|
|
|
|
User = "lambdabot";
|
|
|
|
RuntimeDirectory = [ "lambdabot" ];
|
|
|
|
};
|
2015-04-14 02:06:37 +03:00
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.lambdabot = {
|
2015-04-14 02:06:37 +03:00
|
|
|
group = "lambdabot";
|
|
|
|
description = "Lambdabot daemon user";
|
|
|
|
home = "/var/lib/lambdabot";
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.lambdabot;
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.lambdabot.gid = config.ids.gids.lambdabot;
|
2015-04-14 02:06:37 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|