diff --git a/module.nix b/module.nix index 70a742b..a30599a 100644 --- a/module.nix +++ b/module.nix @@ -3,7 +3,7 @@ let cfg = config.services.gobot; defaultUser = "gobot"; - inherit (lib) mkEnableOption mkMerge mkPackageOption mkOption mkIf types optionalAttrs; + inherit (lib) mkEnableOption mkMerge mkPackageOption mkOption mkIf types optionalAttrs optional optionalString; in { options.services.gobot = { @@ -144,7 +144,7 @@ in script = '' export BOT_TOKEN="$(< $CREDENTIALS_DIRECTORY/BOT_TOKEN )" export MYSQL_PASSWORD="$(< $CREDENTIALS_DIRECTORY/MYSQL_PASSWORD )" - ${lib.optionalString (cfg.useWebhook && cfg.webhookSecretFile != null) '' + ${optionalString (cfg.useWebhook && cfg.webhookSecretFile != null) '' export WEBHOOK_SECRET="$(< $CREDENTIALS_DIRECTORY/WEBHOOK_SECRET )" ''} @@ -155,8 +155,8 @@ in LoadCredential = [ "BOT_TOKEN:${cfg.botTokenFile}" "MYSQL_PASSWORD:${cfg.database.passwordFile}" - (optionalAttrs (cfg.useWebhook && cfg.webhookSecretFile != null) "WEBHOOK_SECRET:${cfg.webhookSecretFile}") - ]; + ] ++ optional (cfg.useWebhook && cfg.webhookSecretFile != null) "WEBHOOK_SECRET:${cfg.webhookSecretFile}"; + Restart = "always"; User = cfg.user; Group = defaultUser; @@ -177,7 +177,7 @@ in PORT = toString cfg.port; WEBHOOK_PUBLIC_URL = cfg.webhookPublicUrl; WEBHOOK_URL_PATH = cfg.webhookUrlPath; - WEBHOOK_SECRET = lib.optionalString (cfg.webhookSecret != null) cfg.webhookSecret; + WEBHOOK_SECRET = optionalString (cfg.webhookSecret != null) cfg.webhookSecret; }) ]; };