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 dbPath = mkOption { 39 type = types.path; 40 default = "/var/lib/spindle/spindle.db"; 41 description = "Path to the database file"; 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 jetstreamEndpoint = mkOption { 57 type = types.str; 58 default = "wss://jetstream1.us-west.bsky.network/subscribe"; 59 description = "Jetstream endpoint to subscribe to"; 60 }; 61 62 dev = mkOption { 63 type = types.bool; 64 default = false; 65 description = "Enable development mode (disables signature verification)"; 66 }; 67 68 owner = mkOption { 69 type = types.str; 70 example = "did:plc:qfpnj4og54vl56wngdriaxug"; 71 description = "DID of owner (required)"; 72 }; 73 74 maxJobCount = mkOption { 75 type = types.int; 76 default = 2; 77 example = 5; 78 description = "Maximum number of concurrent jobs to run"; 79 }; 80 81 queueSize = mkOption { 82 type = types.int; 83 default = 100; 84 example = 100; 85 description = "Maximum number of jobs queue up"; 86 }; 87 88 secrets = { 89 provider = mkOption { 90 type = types.str; 91 default = "sqlite"; 92 description = "Backend to use for secret management, valid options are 'sqlite', and 'openbao'."; 93 }; 94 95 openbao = { 96 proxyAddr = mkOption { 97 type = types.str; 98 default = "http://127.0.0.1:8200"; 99 }; 100 mount = mkOption { 101 type = types.str; 102 default = "spindle"; 103 }; 104 }; 105 }; 106 }; 107 108 pipelines = { 109 nixery = mkOption { 110 type = types.str; 111 default = "nixery.tangled.sh"; # note: this is *not* on tangled.org yet 112 description = "Nixery instance to use"; 113 }; 114 115 workflowTimeout = mkOption { 116 type = types.str; 117 default = "5m"; 118 description = "Timeout for each step of a pipeline"; 119 }; 120 }; 121 }; 122 }; 123 124 config = mkIf cfg.enable { 125 virtualisation.docker.enable = true; 126 127 systemd.services.spindle-tap = { 128 description = "spindle tap service"; 129 after = ["network.target" "docker.service"]; 130 wantedBy = ["multi-user.target"]; 131 serviceConfig = { 132 LogsDirectory = "spindle-tap"; 133 StateDirectory = "spindle-tap"; 134 Environment = [ 135 "TAP_BIND=:2480" 136 "TAP_PLC_URL=${cfg.server.plcUrl}" 137 "TAP_RELAY_URL=${cfg.atpRelayUrl}" 138 "TAP_DATABASE_URL=sqlite:///var/lib/spindle-tap/tap.db" 139 "TAP_RETRY_TIMEOUT=3s" 140 "TAP_COLLECTION_FILTERS=${concatStringsSep "," [ 141 "sh.tangled.repo" 142 "sh.tangled.repo.collaborator" 143 "sh.tangled.spindle.member" 144 ]}" 145 ]; 146 ExecStart = "${getExe cfg.tap-package} run"; 147 }; 148 }; 149 150 systemd.services.spindle = { 151 description = "spindle service"; 152 after = ["network.target" "docker.service"]; 153 wantedBy = ["multi-user.target"]; 154 serviceConfig = { 155 LogsDirectory = "spindle"; 156 StateDirectory = "spindle"; 157 Environment = [ 158 "SPINDLE_SERVER_LISTEN_ADDR=${cfg.server.listenAddr}" 159 "SPINDLE_SERVER_DB_PATH=${cfg.server.dbPath}" 160 "SPINDLE_SERVER_HOSTNAME=${cfg.server.hostname}" 161 "SPINDLE_SERVER_PLC_URL=${cfg.server.plcUrl}" 162 "SPINDLE_SERVER_JETSTREAM_ENDPOINT=${cfg.server.jetstreamEndpoint}" 163 "SPINDLE_SERVER_DEV=${lib.boolToString cfg.server.dev}" 164 "SPINDLE_SERVER_OWNER=${cfg.server.owner}" 165 "SPINDLE_SERVER_MAX_JOB_COUNT=${toString cfg.server.maxJobCount}" 166 "SPINDLE_SERVER_QUEUE_SIZE=${toString cfg.server.queueSize}" 167 "SPINDLE_SERVER_SECRETS_PROVIDER=${cfg.server.secrets.provider}" 168 "SPINDLE_SERVER_SECRETS_OPENBAO_PROXY_ADDR=${cfg.server.secrets.openbao.proxyAddr}" 169 "SPINDLE_SERVER_SECRETS_OPENBAO_MOUNT=${cfg.server.secrets.openbao.mount}" 170 "SPINDLE_NIXERY_PIPELINES_NIXERY=${cfg.pipelines.nixery}" 171 "SPINDLE_NIXERY_PIPELINES_WORKFLOW_TIMEOUT=${cfg.pipelines.workflowTimeout}" 172 ]; 173 ExecStart = "${cfg.package}/bin/spindle"; 174 Restart = "always"; 175 }; 176 }; 177 }; 178 }