summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/Reaktor.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-08-31 19:55:38 +0200
committermakefu <github@syntax-fehler.de>2015-08-31 19:55:38 +0200
commit3e581053f4a1ccf22154f46bb04acea3fe1b29ab (patch)
treed0bb11446547ce179a4f56d1f01037719bb7a113 /krebs/3modules/Reaktor.nix
parentba2cb6c3a865780263125558fa07bf4299f62335 (diff)
add extraConfig and overrideConfig
this allows of preserving the original config while adding bonus features
Diffstat (limited to 'krebs/3modules/Reaktor.nix')
-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 2ca7a0ee..407f1bce 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 ""}";
};
};