This repository has no description
0

Configure Feed

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

core / nix / modules / spindle.nix
6.3 kB 184 lines
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 21 server = { 22 listenAddr = mkOption { 23 type = types.str; 24 default = "0.0.0.0:6555"; 25 description = "Address to listen on"; 26 }; 27 28 dbPath = mkOption { 29 type = types.path; 30 default = "/var/lib/spindle/spindle.db"; 31 description = "Path to the database file"; 32 }; 33 34 hostname = mkOption { 35 type = types.str; 36 example = "my.spindle.com"; 37 description = "Hostname for the server (required)"; 38 }; 39 40 plcUrl = mkOption { 41 type = types.str; 42 default = "https://plc.directory"; 43 description = "atproto PLC directory"; 44 }; 45 46 jetstreamEndpoint = mkOption { 47 type = types.str; 48 default = "wss://jetstream1.us-west.bsky.network/subscribe"; 49 description = "Jetstream endpoint to subscribe to"; 50 }; 51 52 dev = mkOption { 53 type = types.bool; 54 default = false; 55 description = "Enable development mode (disables signature verification)"; 56 }; 57 58 owner = mkOption { 59 type = types.str; 60 example = "did:plc:qfpnj4og54vl56wngdriaxug"; 61 description = "DID of owner (required)"; 62 }; 63 64 maxJobCount = mkOption { 65 type = types.int; 66 default = 2; 67 example = 5; 68 description = "Maximum number of concurrent jobs to run"; 69 }; 70 71 queueSize = mkOption { 72 type = types.int; 73 default = 100; 74 example = 100; 75 description = "Maximum number of jobs queue up"; 76 }; 77 78 maxConcurrentWorkflows = mkOption { 79 type = types.int; 80 default = 8; 81 description = "Maximum number of workflow containers running simultaneously (controls total memory usage)"; 82 }; 83 84 secrets = { 85 provider = mkOption { 86 type = types.str; 87 default = "sqlite"; 88 description = "Backend to use for secret management, valid options are 'sqlite', and 'openbao'."; 89 }; 90 91 openbao = { 92 proxyAddr = mkOption { 93 type = types.str; 94 default = "http://127.0.0.1:8200"; 95 description = "Address of the OpenBAO proxy server"; 96 }; 97 mount = mkOption { 98 type = types.str; 99 default = "spindle"; 100 description = "Mount path in OpenBAO to read secrets from"; 101 }; 102 }; 103 }; 104 }; 105 106 pipelines = { 107 nixery = mkOption { 108 type = types.str; 109 default = "nixery.tangled.sh"; # note: this is *not* on tangled.org yet 110 description = "Nixery instance to use"; 111 }; 112 113 workflowTimeout = mkOption { 114 type = types.str; 115 default = "5m"; 116 description = "Timeout for each step of a pipeline"; 117 }; 118 119 maxJobMemoryMb = mkOption { 120 type = types.int; 121 default = 6144; 122 description = "Memory limit per workflow container in MiB (default 6 GiB)"; 123 }; 124 125 logBucket = mkOption { 126 type = types.str; 127 default = "tangled-logs"; 128 description = "S3 bucket for workflow logs"; 129 }; 130 }; 131 132 environmentFile = mkOption { 133 type = with types; nullOr path; 134 default = null; 135 example = "/etc/spindle.env"; 136 description = '' 137 Additional environment file as defined in {manpage}`systemd.exec(5)`. 138 139 Sensitive secrets such as {env}`AWS_SECRET_ACCESS_KEY`, 140 {env}`AWS_ACCESS_KEY_ID`, {env}`AWS_REGION` 141 may be passed to the service 142 without making them world readable in the nix store. 143 ''; 144 }; 145 }; 146 }; 147 148 config = mkIf cfg.enable { 149 virtualisation.docker.enable = true; 150 151 systemd.services.spindle = { 152 description = "spindle service"; 153 after = ["network.target" "docker.service"]; 154 wantedBy = ["multi-user.target"]; 155 serviceConfig = { 156 LogsDirectory = "spindle"; 157 StateDirectory = "spindle"; 158 EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile; 159 160 Environment = [ 161 "SPINDLE_SERVER_LISTEN_ADDR=${cfg.server.listenAddr}" 162 "SPINDLE_SERVER_DB_PATH=${cfg.server.dbPath}" 163 "SPINDLE_SERVER_HOSTNAME=${cfg.server.hostname}" 164 "SPINDLE_SERVER_PLC_URL=${cfg.server.plcUrl}" 165 "SPINDLE_SERVER_JETSTREAM_ENDPOINT=${cfg.server.jetstreamEndpoint}" 166 "SPINDLE_SERVER_DEV=${lib.boolToString cfg.server.dev}" 167 "SPINDLE_SERVER_OWNER=${cfg.server.owner}" 168 "SPINDLE_SERVER_MAX_JOB_COUNT=${toString cfg.server.maxJobCount}" 169 "SPINDLE_SERVER_QUEUE_SIZE=${toString cfg.server.queueSize}" 170 "SPINDLE_SERVER_MAX_CONCURRENT_WORKFLOWS=${toString cfg.server.maxConcurrentWorkflows}" 171 "SPINDLE_SERVER_SECRETS_PROVIDER=${cfg.server.secrets.provider}" 172 "SPINDLE_SERVER_SECRETS_OPENBAO_PROXY_ADDR=${cfg.server.secrets.openbao.proxyAddr}" 173 "SPINDLE_SERVER_SECRETS_OPENBAO_MOUNT=${cfg.server.secrets.openbao.mount}" 174 "SPINDLE_NIXERY_PIPELINES_NIXERY=${cfg.pipelines.nixery}" 175 "SPINDLE_NIXERY_PIPELINES_WORKFLOW_TIMEOUT=${cfg.pipelines.workflowTimeout}" 176 "SPINDLE_NIXERY_PIPELINES_MAX_JOB_MEMORY_MB=${toString cfg.pipelines.maxJobMemoryMb}" 177 "SPINDLE_S3_LOG_BUCKET=${cfg.pipelines.logBucket}" 178 ]; 179 ExecStart = "${cfg.package}/bin/spindle"; 180 Restart = "always"; 181 }; 182 }; 183 }; 184 }