diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 312c24db98b9..dcefd1c51a7f 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -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 diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8a4adfc24f52..a1bb9b89f38f 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/services/networking/lambdabot.nix b/nixos/modules/services/networking/lambdabot.nix new file mode 100644 index 000000000000..3230ef2be85f --- /dev/null +++ b/nixos/modules/services/networking/lambdabot.nix @@ -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; + + }; + +}