this repo has no description
1
fork

Configure Feed

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

at main 117 lines 3.7 kB view raw
1{ 2 config, 3 lib, 4 ... 5}: { 6 options.cow.tangled = { 7 spindle = { 8 enable = lib.mkEnableOption "tangled spindle service"; 9 port = lib.mkOption { 10 type = lib.types.port; 11 default = 6555; 12 description = "port to run spindle on"; 13 }; 14 hostname = lib.mkOption { 15 type = lib.types.str; 16 description = "virtual host for spindle"; 17 }; 18 }; 19 knot = { 20 enable = lib.mkEnableOption "tangled knot service"; 21 hostname = lib.mkOption { 22 type = lib.types.str; 23 description = "virtual host for knot"; 24 }; 25 gitUser = lib.mkOption { 26 type = lib.types.str; 27 description = "Name of git user for SSH operations"; 28 default = "git"; 29 }; 30 port = lib.mkOption { 31 type = lib.types.port; 32 default = 5555; 33 description = "Port for HTTP traffic to listen on"; 34 }; 35 internalPort = lib.mkOption { 36 type = lib.types.port; 37 default = 5444; 38 description = "Port for internal HTTP traffic to listen on"; 39 }; 40 stateDir = lib.mkOption { 41 type = lib.types.str; 42 description = "runtime path to store all state for the knot"; 43 default = "/var/lib/tangled-knot"; 44 }; 45 }; 46 }; 47 48 config = let 49 conf = config.cow.tangled; 50 in { 51 cow.imperm.keep = 52 (lib.optional conf.knot.enable conf.knot.stateDir) 53 ++ (lib.optionals conf.spindle.enable ["/var/lib/spindle" "/var/lib/docker"]); 54 55 services.tangled = { 56 knot = lib.mkIf conf.knot.enable { 57 enable = true; 58 openFirewall = lib.mkDefault false; 59 inherit (conf.knot) gitUser stateDir; 60 repo.scanPath = "${conf.knot.stateDir}/repos"; 61 server = { 62 listenAddr = "0.0.0.0:${builtins.toString conf.knot.port}"; 63 internalListenAddr = "127.0.0.1:${builtins.toString conf.knot.internalPort}"; 64 hostname = lib.mkDefault conf.knot.hostname; 65 owner = lib.mkIf config.cow.bean.enable (lib.mkDefault config.cow.bean.atproto.did); 66 }; 67 }; 68 spindle = lib.mkIf conf.spindle.enable { 69 enable = true; 70 server = { 71 listenAddr = "0.0.0.0:${builtins.toString conf.spindle.port}"; 72 owner = lib.mkIf config.cow.bean.enable (lib.mkDefault config.cow.bean.atproto.did); 73 hostname = lib.mkDefault conf.spindle.hostname; 74 }; 75 }; 76 }; 77 78 services.nginx.virtualHosts = { 79 ${conf.knot.hostname} = lib.mkIf conf.knot.enable { 80 locations = { 81 "/" = { 82 proxyPass = "http://localhost:${builtins.toString conf.knot.port}"; 83 recommendedProxySettings = true; 84 }; 85 "/events" = { 86 proxyPass = "http://localhost:${builtins.toString conf.knot.port}"; 87 proxyWebsockets = true; 88 recommendedProxySettings = true; 89 }; 90 }; 91 }; 92 93 ${conf.spindle.hostname} = lib.mkIf conf.spindle.enable { 94 locations = { 95 "/" = { 96 proxyPass = "http://localhost:${builtins.toString conf.spindle.port}"; 97 recommendedProxySettings = true; 98 }; 99 "/events" = { 100 proxyPass = "http://localhost:${builtins.toString conf.spindle.port}"; 101 proxyWebsockets = true; 102 recommendedProxySettings = true; 103 }; 104 "/logs" = { 105 proxyPass = "http://localhost:${builtins.toString conf.spindle.port}"; 106 proxyWebsockets = true; 107 recommendedProxySettings = true; 108 }; 109 }; 110 }; 111 }; 112 113 services.openssh = lib.mkIf conf.knot.enable { 114 enable = true; 115 }; 116 }; 117}