summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/reaktor2.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2019-01-21 21:49:10 +0100
committermakefu <github@syntax-fehler.de>2019-01-21 21:49:10 +0100
commit8bb94c519f44ba584af4964faa42eb28a4414bc9 (patch)
tree994fc675a41f4d1a96e3cd16ccae8896b05061d6 /krebs/3modules/reaktor2.nix
parent93f1ce72844bf2bc63cd919c38c3323a6f8f14ef (diff)
parentbc2aedb2d0a6d22089d4f666082d440e4ffb07e6 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'krebs/3modules/reaktor2.nix')
-rw-r--r--krebs/3modules/reaktor2.nix63
1 files changed, 63 insertions, 0 deletions
diff --git a/krebs/3modules/reaktor2.nix b/krebs/3modules/reaktor2.nix
new file mode 100644
index 000000000..b667bcc92
--- /dev/null
+++ b/krebs/3modules/reaktor2.nix
@@ -0,0 +1,63 @@
+with import <stockholm/lib>;
+{ config, pkgs, ... }: {
+
+ options.krebs.reaktor2 = mkOption {
+ default = {};
+ type = types.attrsOf (types.submodule (self: let
+ name = self.config._module.args.name;
+ in {
+ options = {
+ nick = mkOption {
+ default = name;
+ # TODO types.irc.nickname
+ type = types.str;
+ };
+ hostname = mkOption {
+ default = "irc.r";
+ type = types.hostname;
+ };
+ port = mkOption {
+ default = "6667";
+ # TODO type = types.service-name
+ };
+ plugins = mkOption {
+ default = [];
+ type = types.listOf types.attrs;
+ };
+ stateDir = mkOption {
+ default = "/var/lib/${self.config.systemd-service-name}";
+ readOnly = true;
+ type = types.absolute-pathname;
+ };
+ systemd-service-name = mkOption {
+ default = "reaktor2${optionalString (name != "default") "-${name}"}";
+ type = types.filename;
+ };
+ };
+ }));
+ };
+
+ config = {
+ systemd.services = flip mapAttrs' config.krebs.reaktor2 (_: cfg:
+ nameValuePair cfg.systemd-service-name {
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ User = cfg.systemd-service-name;
+ Group = "reaktor2";
+ DynamicUser = true;
+ StateDirectory = cfg.systemd-service-name;
+ ExecStart = let
+ configFile = pkgs.writeJSON configFileName configValue;
+ configFileName = "${cfg.systemd-service-name}.config.json";
+ configValue = recursiveUpdate {
+ logTime = false;
+ } (removeAttrs cfg ["_module"]);
+ in "${pkgs.reaktor2}/bin/reaktor ${configFile}";
+ Restart = "always";
+ RestartSec = "30";
+ };
+ }
+ );
+ };
+}