summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
Diffstat (limited to 'krebs')
-rw-r--r--krebs/3modules/Reaktor.nix40
1 files changed, 34 insertions, 6 deletions
diff --git a/krebs/3modules/Reaktor.nix b/krebs/3modules/Reaktor.nix
index 2ca7a0ee3..407f1bce7 100644
--- a/krebs/3modules/Reaktor.nix
+++ b/krebs/3modules/Reaktor.nix
@@ -12,9 +12,17 @@ let
isString
optionalString
concatStrings
+ escapeShellArg
;
- ReaktorConfig = mkIf ( isString cfg.extraConfig ) pkgs.writeText "config.py" cfg.extraConfig;
+ ReaktorConfig = pkgs.writeText "config.py" ''
+ ${if (isString cfg.overrideConfig ) then ''
+ # Overriden Config
+ ${cfg.overrideConfig}
+ '' else ""}
+ ## Extra Config
+ ${cfg.extraConfig}
+ '';
cfg = config.krebs.Reaktor;
out = {
@@ -40,7 +48,7 @@ let
};
- extraConfig = mkOption {
+ overrideConfig = mkOption {
default = null;
type = types.nullOr types.str;
description = ''
@@ -48,6 +56,13 @@ let
Reaktor default cfg can be retrieved via `reaktor get-config`
'';
};
+ extraConfig = mkOption {
+ default = "";
+ type = types.str;
+ description = ''
+ configuration appended to the default or overridden configuration
+ '';
+ };
ReaktorPkg = mkOption {
default = kpkgs.Reaktor;
@@ -60,7 +75,6 @@ let
imp = {
# for reaktor get-config
environment.systemPackages = [ cfg.ReaktorPkg ];
-
users.extraUsers = singleton {
name = "Reaktor";
# uid = config.ids.uids.Reaktor;
@@ -84,12 +98,26 @@ let
description = "Reaktor IRC Bot";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
- serviceConfig.User = "Reaktor";
environment = {
GIT_SSL_CAINFO = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
- IRC_NICKNAME = cfg.nickname;
+ REAKTOR_NICKNAME = cfg.nickname;
+ };
+ serviceConfig= {
+ ExecStartPre = pkgs.writeScript "Reaktor-init" ''
+ #! /bin/sh
+ ${if (isString cfg.overrideConfig) then
+ ''cp ${ReaktorConfig} /tmp/config.py''
+ else
+ ''(${cfg.ReaktorPkg}/bin/reaktor get-config;cat "${ReaktorConfig}" ) > /tmp/config.py''
+ }
+ '';
+ ExecStart = "${cfg.ReaktorPkg}/bin/reaktor run /tmp/config.py";
+ PrivateTmp = "true";
+ User = "Reaktor";
+ Restart = "on-abort";
+ #StartLimitInterval = "5m";
+ #StartLimitBurst = "1";
};
- serviceConfig.ExecStart = "${cfg.ReaktorPkg}/bin/reaktor run ${if (isString cfg.extraConfig) then cfg.ReaktorConfig else ""}";
};
};