lambdabot: add nixos service

This commit is contained in:
Nikolay Amiantov 2015-04-14 02:06:37 +03:00
parent 4947f918ad
commit 1d6723c085
3 changed files with 75 additions and 0 deletions

View File

@ -216,6 +216,7 @@
rdnssd = 188;
ihaskell = 189;
i2p = 190;
lambdabot = 191;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
@ -409,6 +410,7 @@
#rdnssd = 188; # unused
ihaskell = 189;
i2p = 190;
lambdabot = 191;
# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal

View File

@ -273,6 +273,7 @@
./services/networking/iodined.nix
./services/networking/ircd-hybrid/default.nix
./services/networking/kippo.nix
./services/networking/lambdabot.nix
./services/networking/mailpile.nix
./services/networking/minidlna.nix
./services/networking/mstpd.nix

View File

@ -0,0 +1,72 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.lambdabot;
rc = builtins.toFile "script.rc" cfg.script;
in
{
### configuration
options = {
services.lambdabot = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable the Lambdabot IRC bot";
};
package = mkOption {
type = types.package;
default = pkgs.lambdabot;
description = "Used lambdabot package";
};
script = mkOption {
type = types.str;
default = "";
description = "Lambdabot script";
};
};
};
### implementation
config = mkIf cfg.enable {
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
exec ${cfg.package}/bin/lambdabot -e 'rc ${rc}'
'';
serviceConfig.User = "lambdabot";
};
users.extraUsers.lambdabot = {
group = "lambdabot";
description = "Lambdabot daemon user";
home = "/var/lib/lambdabot";
createHome = true;
uid = config.ids.uids.lambdabot;
};
users.extraGroups.lambdabot.gid = config.ids.gids.lambdabot;
};
}