Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

nix: appview project mode and custom templates

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>

author
Anirudh Oppiliappan
date (Jun 24, 2026, 5:17 PM +0530) commit 2028259b parent 22321aa5 change-id kwlsrrum
+56 -2
+44 -2
nix/modules/appview.nix
··· 6 6 }: let 7 7 cfg = config.services.tangled.appview; 8 8 in 9 - with lib; { 9 + with lib; let 10 + effectivePackage = 11 + if cfg.project.templatesDir == null 12 + then cfg.package 13 + else cfg.package.override {customTemplatesDir = cfg.project.templatesDir;}; 14 + in { 10 15 options = { 11 16 services.tangled.appview = { 12 17 enable = mkOption { ··· 259 264 }; 260 265 }; 261 266 267 + project = { 268 + enable = mkOption { 269 + type = types.bool; 270 + default = false; 271 + description = "Enable project mode: collapses URL namespace to a single user, disables signup and timeline."; 272 + }; 273 + 274 + user = mkOption { 275 + type = types.str; 276 + default = ""; 277 + example = "anirudh.fi"; 278 + description = "The handle or DID of the project user. Required when project.enable is true."; 279 + }; 280 + 281 + templatesDir = mkOption { 282 + type = types.nullOr types.path; 283 + default = null; 284 + example = "./custom-templates"; 285 + description = '' 286 + Path to a directory of template overrides. Files are copied on 287 + top of the default templates at build time, so individual 288 + templates can be replaced without forking the whole tree. 289 + ''; 290 + }; 291 + }; 292 + 293 + 262 294 environmentFile = mkOption { 263 295 type = with types; nullOr path; 264 296 default = null; ··· 283 315 }; 284 316 285 317 config = mkIf cfg.enable { 318 + assertions = [ 319 + { 320 + assertion = !cfg.project.enable || cfg.project.user != ""; 321 + message = "services.tangled.appview.project.user must be set when project.enable is true"; 322 + } 323 + ]; 286 324 services.redis.servers.appview = { 287 325 enable = true; 288 326 port = 6379; ··· 299 337 300 338 serviceConfig = { 301 339 Type = "simple"; 302 - ExecStart = "${cfg.package}/bin/appview"; 340 + ExecStart = "${effectivePackage}/bin/appview"; 303 341 Restart = "always"; 304 342 RestartSec = "10s"; 305 343 EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile; ··· 372 410 } 373 411 // optionalAttrs (cfg.ssh.enable && cfg.ssh.hostKeyPath != null) { 374 412 TANGLED_SSH_HOST_KEY_PATH = cfg.ssh.hostKeyPath; 413 + } 414 + // optionalAttrs cfg.project.enable { 415 + TANGLED_PROJECT_MODE = "true"; 416 + TANGLED_PROJECT_USER = cfg.project.user; 375 417 }; 376 418 }; 377 419 };
+12
nix/pkgs/appview.nix
··· 4 4 appview-static-files, 5 5 sqlite-lib, 6 6 src, 7 + # optional path to a directory of template overrides; files here are 8 + # copied on top of appview/pages/templates/ before the Go embed runs, 9 + # so any template file can be replaced without forking the whole tree. 10 + customTemplatesDir ? null, 7 11 }: 8 12 buildGoApplication { 9 13 pname = "appview"; ··· 14 18 pushd source 15 19 mkdir -p appview/pages/static 16 20 cp -frv ${appview-static-files}/* appview/pages/static 21 + ${ 22 + if customTemplatesDir != null 23 + then '' 24 + echo "overlaying custom templates from ${customTemplatesDir}" 25 + cp -rfv ${customTemplatesDir}/* appview/pages/templates/ 26 + '' 27 + else "" 28 + } 17 29 popd 18 30 ''; 19 31