1{self}: {
2 config,
3 pkgs,
4 lib,
5 ...
6}:
7with lib; {
8 options = {
9 services.tangled-appview = {
10 enable = mkOption {
11 type = types.bool;
12 default = false;
13 description = "Enable tangled appview";
14 };
15 port = mkOption {
16 type = types.int;
17 default = 3000;
18 description = "Port to run the appview on";
19 };
20 cookie_secret = mkOption {
21 type = types.str;
22 default = "00000000000000000000000000000000";
23 description = "Cookie secret";
24 };
25 };
26 };
27
28 config = mkIf config.services.tangled-appview.enable {
29 systemd.services.tangled-appview = {
30 description = "tangled appview service";
31 wantedBy = ["multi-user.target"];
32
33 serviceConfig = {
34 ListenStream = "0.0.0.0:${toString config.services.tangled-appview.port}";
35 ExecStart = "${self.packages.${pkgs.system}.appview}/bin/appview";
36 Restart = "always";
37 };
38
39 environment = {
40 TANGLED_DB_PATH = "appview.db";
41 TANGLED_COOKIE_SECRET = config.services.tangled-appview.cookie_secret;
42 };
43 };
44 };
45}