forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
1{ 2 config, 3 lib, 4 ... 5}: let 6 cfg = config.services.tangled.appview; 7in 8 with lib; { 9 options = { 10 services.tangled.appview = { 11 enable = mkOption { 12 type = types.bool; 13 default = false; 14 description = "Enable tangled appview"; 15 }; 16 package = mkOption { 17 type = types.package; 18 description = "Package to use for the appview"; 19 }; 20 port = mkOption { 21 type = types.int; 22 default = 3000; 23 description = "Port to run the appview on"; 24 }; 25 environmentFile = mkOption { 26 type = with types; nullOr path; 27 default = null; 28 example = "/etc-/appview.env"; 29 description = '' 30 Additional environment file as defined in {manpage}`systemd.exec(5)`. 31 32 Sensitive secrets such as {env}`TANGLED_COOKIE_SECRET` may be 33 passed to the service without makeing them world readable in the 34 nix store. 35 36 ''; 37 }; 38 }; 39 }; 40 41 config = mkIf cfg.enable { 42 systemd.services.appview = { 43 description = "tangled appview service"; 44 wantedBy = ["multi-user.target"]; 45 46 serviceConfig = { 47 ListenStream = "0.0.0.0:${toString cfg.port}"; 48 ExecStart = "${cfg.package}/bin/appview"; 49 Restart = "always"; 50 EnvironmentFile = optional (cfg.environmentFile != null) cfg.environmentFile; 51 }; 52 53 environment = { 54 TANGLED_DB_PATH = "appview.db"; 55 }; 56 }; 57 }; 58 }