this repo has no description
1{
2 config,
3 lib,
4 ...
5}: let
6 cfg = config.services.tangled.spindle;
7in
8 with lib; {
9 options = {
10 services.tangled.spindle = {
11 enable = mkOption {
12 type = types.bool;
13 default = false;
14 description = "Enable a tangled spindle";
15 };
16 package = mkOption {
17 type = types.package;
18 description = "Package to use for the spindle";
19 };
20 tap-package = mkOption {
21 type = types.package;
22 description = "Package to use for the spindle";
23 };
24
25 atpRelayUrl = mkOption {
26 type = types.str;
27 default = "https://relay1.us-east.bsky.network";
28 description = "atproto relay";
29 };
30
31 server = {
32 listenAddr = mkOption {
33 type = types.str;
34 default = "0.0.0.0:6555";
35 description = "Address to listen on";
36 };
37
38 stateDir = mkOption {
39 type = types.path;
40 default = "/var/lib/spindle";
41 description = "Tangled spindle data directory";
42 };
43
44 hostname = mkOption {
45 type = types.str;
46 example = "my.spindle.com";
47 description = "Hostname for the server (required)";
48 };
49
50 plcUrl = mkOption {
51 type = types.str;
52 default = "https://plc.directory";
53 description = "atproto PLC directory";
54 };
55
56 dev = mkOption {
57 type = types.bool;
58 default = false;
59 description = "Enable development mode (disables signature verification)";
60 };
61
62 owner = mkOption {
63 type = types.str;
64 example = "did:plc:qfpnj4og54vl56wngdriaxug";
65 description = "DID of owner (required)";
66 };
67
68 maxJobCount = mkOption {
69 type = types.int;
70 default = 2;
71 example = 5;
72 description = "Maximum number of concurrent jobs to run";
73 };
74
75 queueSize = mkOption {
76 type = types.int;
77 default = 100;
78 example = 100;
79 description = "Maximum number of jobs queue up";
80 };
81
82 secrets = {
83 provider = mkOption {
84 type = types.str;
85 default = "sqlite";
86 description = "Backend to use for secret management, valid options are 'sqlite', and 'openbao'.";
87 };
88
89 openbao = {
90 proxyAddr = mkOption {
91 type = types.str;
92 default = "http://127.0.0.1:8200";
93 };
94 mount = mkOption {
95 type = types.str;
96 default = "spindle";
97 };
98 };
99 };
100 };
101
102 pipelines = {
103 nixery = mkOption {
104 type = types.str;
105 default = "nixery.tangled.sh"; # note: this is *not* on tangled.org yet
106 description = "Nixery instance to use";
107 };
108
109 workflowTimeout = mkOption {
110 type = types.str;
111 default = "5m";
112 description = "Timeout for each step of a pipeline";
113 };
114 };
115 };
116 };
117
118 config = mkIf cfg.enable {
119 virtualisation.docker.enable = true;
120
121 systemd.services.spindle-tap = {
122 description = "spindle tap service";
123 after = ["network.target" "docker.service"];
124 wantedBy = ["multi-user.target"];
125 serviceConfig = {
126 LogsDirectory = "spindle-tap";
127 StateDirectory = "spindle-tap";
128 Environment = [
129 "TAP_BIND=:2480"
130 "TAP_PLC_URL=${cfg.server.plcUrl}"
131 "TAP_RELAY_URL=${cfg.atpRelayUrl}"
132 "TAP_DATABASE_URL=sqlite:///var/lib/spindle-tap/tap.db"
133 "TAP_RETRY_TIMEOUT=3s"
134 "TAP_COLLECTION_FILTERS=${concatStringsSep "," [
135 "sh.tangled.repo"
136 "sh.tangled.repo.collaborator"
137 "sh.tangled.spindle.member"
138 ]}"
139 ];
140 ExecStart = "${getExe cfg.tap-package} run";
141 };
142 };
143
144 systemd.services.spindle = {
145 description = "spindle service";
146 after = ["network.target" "docker.service" "spindle-tap.service"];
147 wantedBy = ["multi-user.target"];
148 serviceConfig = {
149 LogsDirectory = "spindle";
150 StateDirectory = "spindle";
151 Environment = [
152 "SPINDLE_SERVER_LISTEN_ADDR=${cfg.server.listenAddr}"
153 "SPINDLE_SERVER_DATA_DIR=${cfg.server.stateDir}"
154 "SPINDLE_SERVER_HOSTNAME=${cfg.server.hostname}"
155 "SPINDLE_SERVER_PLC_URL=${cfg.server.plcUrl}"
156 "SPINDLE_SERVER_DEV=${lib.boolToString cfg.server.dev}"
157 "SPINDLE_SERVER_OWNER=${cfg.server.owner}"
158 "SPINDLE_SERVER_MAX_JOB_COUNT=${toString cfg.server.maxJobCount}"
159 "SPINDLE_SERVER_QUEUE_SIZE=${toString cfg.server.queueSize}"
160 "SPINDLE_SERVER_SECRETS_PROVIDER=${cfg.server.secrets.provider}"
161 "SPINDLE_SERVER_SECRETS_OPENBAO_PROXY_ADDR=${cfg.server.secrets.openbao.proxyAddr}"
162 "SPINDLE_SERVER_SECRETS_OPENBAO_MOUNT=${cfg.server.secrets.openbao.mount}"
163 "SPINDLE_SERVER_TAP_URL=http://localhost:2480"
164 "SPINDLE_NIXERY_PIPELINES_NIXERY=${cfg.pipelines.nixery}"
165 "SPINDLE_NIXERY_PIPELINES_WORKFLOW_TIMEOUT=${cfg.pipelines.workflowTimeout}"
166 ];
167 ExecStart = "${cfg.package}/bin/spindle";
168 Restart = "always";
169 };
170 };
171 };
172 }