From dbfc6c72699827187ea550f1335e8705b5744322 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 19 Nov 2025 10:36:50 +0000 Subject: [PATCH] Add templateFile option to Nix module Allows users to specify a custom post.gohtml template file for formatting RSS feed posts. The template file is copied to the service's state directory at /var/lib/rssbot and the bot runs from that directory so it can find the template. - Added templateFile option (nullable path) - Added StateDirectory and WorkingDirectory to systemd service config - Added preStart hook to copy custom template when specified --- module.nix | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/module.nix b/module.nix index df80edb..857cd55 100644 --- a/module.nix +++ b/module.nix @@ -41,12 +41,11 @@ in description = "File containing Telegram Bot Token"; }; - # TODO: Find a way to load a custom post.gohtml - # template = mkOption { - # type = types.nullOr types.lines; - # default = null; - # description = "Custom post.gohtml template content"; - # }; + templateFile = mkOption { + type = types.nullOr types.path; + default = null; + description = "Path to a custom post.gohtml template file"; + }; database = { host = lib.mkOption { @@ -129,6 +128,10 @@ in requires = [ "network-online.target" "mysql.service" ]; wantedBy = [ "multi-user.target" ]; + preStart = optionalString (cfg.templateFile != null) '' + cp ${cfg.templateFile} $STATE_DIRECTORY/post.gohtml + ''; + script = '' export BOT_TOKEN="$(< $CREDENTIALS_DIRECTORY/BOT_TOKEN )" ${optionalString (cfg.database.passwordFile != null) '' @@ -143,6 +146,8 @@ in "BOT_TOKEN:${cfg.botTokenFile}" ] ++ optional (cfg.database.passwordFile != null) "MYSQL_PASSWORD:${cfg.database.passwordFile}"; + StateDirectory = "rssbot"; + WorkingDirectory = "/var/lib/rssbot"; Restart = "always"; User = cfg.user; Group = defaultUser;