commit 0774de53fd6b6f8944204f42bba2dd0d31a0bfcd
parent 843901c8de98e511c76045bbe86b03c7ab0d87b3
Author: Silas Brack <silasbrack@gmail.com>
Date: Fri, 12 Jun 2026 20:22:13 +0200
feat: remove TrailBase from simple-web-app deployment
App now uses direct SQLite access, no separate database service
needed. Removed TrailBase service, /api/ nginx proxy, and
traildepot references.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 17 insertions(+), 66 deletions(-)
diff --git a/hosts/helios.nix b/hosts/helios.nix
@@ -122,8 +122,6 @@
services.simple-web-app = {
enable = true;
package = simple-web-app.packages.${pkgs.stdenv.hostPlatform.system}.default;
- trailbasePackage = simple-web-app.packages.${pkgs.stdenv.hostPlatform.system}.trailbase;
- traildepotPath = "${simple-web-app}/traildepot";
};
# Daily Tracker
diff --git a/modules/simple-web-app.nix b/modules/simple-web-app.nix
@@ -19,15 +19,6 @@ in
defaultText = lib.literalMD "`packages.default` from the simple-web-app flake";
};
- trailbasePackage = mkOption {
- defaultText = lib.literalMD "`packages.trailbase` from the simple-web-app flake";
- };
-
- traildepotPath = mkOption {
- type = types.path;
- description = "Path to the traildepot configuration directory";
- };
-
port = mkOption {
type = types.nullOr types.int;
default = 8000;
@@ -37,70 +28,47 @@ in
'';
};
- trailbasePort = mkOption {
- type = types.int;
- default = 4000;
+ dbPath = mkOption {
+ type = types.str;
+ default = "/var/lib/simple-web-app/data/app.db";
description = ''
- The port for Trailbase to listen on.
+ Path to the SQLite database file.
'';
};
- };
- };
-
- config = mkIf cfg.enable {
- # Run Trailbase backend service
- systemd.services.simple-web-app-trailbase = {
- wantedBy = [ "multi-user.target" ];
- description = "Trailbase backend for simple web app.";
- after = [ "network.target" ];
- serviceConfig = {
- Type = "simple";
- ExecStart = "${cfg.trailbasePackage}/bin/trail --public-url https://simple.fnarglebeast.com run --address 127.0.0.1:${builtins.toString cfg.trailbasePort}";
- WorkingDirectory = "/var/lib/simple-web-app-trailbase";
- DynamicUser = true;
- StateDirectory = "simple-web-app-trailbase";
- StateDirectoryMode = "0755";
- CacheDirectory = "simple-web-app-trailbase";
- Environment = "HOME=/var/lib/simple-web-app-trailbase";
- # Run setup as root before dropping to DynamicUser (+ prefix = run as root)
- ExecStartPre = let
- setupScript = pkgs.writeShellScript "simple-web-app-trailbase-setup" ''
- mkdir -p /var/lib/simple-web-app-trailbase/traildepot/migrations
- mkdir -p /var/lib/simple-web-app-trailbase/traildepot/wasm
- cp ${cfg.traildepotPath}/config.textproto /var/lib/simple-web-app-trailbase/traildepot/
- cp -r ${cfg.traildepotPath}/migrations/* /var/lib/simple-web-app-trailbase/traildepot/migrations/
- cp -r ${cfg.traildepotPath}/wasm/* /var/lib/simple-web-app-trailbase/traildepot/wasm/ 2>/dev/null || true
-
- # Configure SMTP for email verification via local mailserver
- ${pkgs.gnused}/bin/sed -i 's|email {}|email {\n smtp_host: "localhost"\n smtp_port: 25\n smtp_encryption: SMTP_ENCRYPTION_NONE\n sender_name: "SimpleWebApp"\n sender_address: "noreply@silasbrack.com"\n}|' /var/lib/simple-web-app-trailbase/traildepot/config.textproto
- chmod -R 755 /var/lib/simple-web-app-trailbase
- '';
- in "+${setupScript}";
+ jwtSecret = mkOption {
+ type = types.str;
+ default = "";
+ description = ''
+ JWT secret for authentication. If empty, a random secret is generated on each restart.
+ '';
};
};
+ };
+ config = mkIf cfg.enable {
# Run simple web app service
systemd.services.simple-web-app = {
wantedBy = [ "multi-user.target" ];
description = "Run simple web app.";
- after = [ "network.target" "simple-web-app-trailbase.service" ];
- requires = [ "simple-web-app-trailbase.service" ];
+ after = [ "network.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${cfg.package}/bin/simple-web-app";
DynamicUser = true;
StateDirectory = "simple-web-app";
+ StateDirectoryMode = "0755";
};
environment = {
PORT = builtins.toString cfg.port;
DEBUG = "false";
- TRAILBASE_URL = "http://127.0.0.1:${builtins.toString cfg.trailbasePort}";
+ DB_PATH = cfg.dbPath;
+ JWT_SECRET = cfg.jwtSecret;
RUST_LOG = "info";
};
};
- # Route requests to the API via nginx
+ # Route requests via nginx
networking.firewall.allowedTCPPorts = [ cfg.port ];
services.nginx.virtualHosts."simple.fnarglebeast.com" = {
forceSSL = true;
@@ -109,21 +77,6 @@ in
proxyPass = "http://127.0.0.1:${builtins.toString cfg.port}";
recommendedProxySettings = true;
};
- # Trailbase admin panel and API
- locations."/_/" = {
- proxyPass = "http://127.0.0.1:${builtins.toString cfg.trailbasePort}";
- recommendedProxySettings = true;
- };
- locations."/api/" = {
- proxyPass = "http://127.0.0.1:${builtins.toString cfg.trailbasePort}";
- recommendedProxySettings = true;
- extraConfig = ''
- # SSE support for realtime subscriptions
- proxy_buffering off;
- proxy_cache off;
- proxy_read_timeout 86400s;
- '';
- };
};
# Archive logs to volume