A vibe coded tangled fork which supports pijul.
at 5a2fe5d25f6f516b53537c224dca5885a1d5d2c4 174 lines 5.7 kB view raw
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 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 description = "Address of the OpenBAO proxy server"; 94 }; 95 mount = mkOption { 96 type = types.str; 97 default = "spindle"; 98 description = "Mount path in OpenBAO to read secrets from"; 99 }; 100 }; 101 }; 102 }; 103 104 pipelines = { 105 nixery = mkOption { 106 type = types.str; 107 default = "nixery.tangled.sh"; # note: this is *not* on tangled.org yet 108 description = "Nixery instance to use"; 109 }; 110 111 workflowTimeout = mkOption { 112 type = types.str; 113 default = "5m"; 114 description = "Timeout for each step of a pipeline"; 115 }; 116 }; 117 }; 118 }; 119 120 config = mkIf cfg.enable { 121 virtualisation.docker.enable = true; 122 123 systemd.services.spindle-tap = { 124 description = "spindle tap service"; 125 after = ["network.target" "docker.service"]; 126 wantedBy = ["multi-user.target"]; 127 serviceConfig = { 128 LogsDirectory = "spindle-tap"; 129 StateDirectory = "spindle-tap"; 130 Environment = [ 131 "TAP_BIND=:2480" 132 "TAP_PLC_URL=${cfg.server.plcUrl}" 133 "TAP_RELAY_URL=${cfg.atpRelayUrl}" 134 "TAP_DATABASE_URL=sqlite:///var/lib/spindle-tap/tap.db" 135 "TAP_RETRY_TIMEOUT=3s" 136 "TAP_COLLECTION_FILTERS=${concatStringsSep "," [ 137 "sh.tangled.repo" 138 "sh.tangled.repo.collaborator" 139 "sh.tangled.spindle.member" 140 ]}" 141 ]; 142 ExecStart = "${getExe cfg.tap-package} run"; 143 }; 144 }; 145 146 systemd.services.spindle = { 147 description = "spindle service"; 148 after = ["network.target" "docker.service" "spindle-tap.service"]; 149 wantedBy = ["multi-user.target"]; 150 serviceConfig = { 151 LogsDirectory = "spindle"; 152 StateDirectory = "spindle"; 153 Environment = [ 154 "SPINDLE_SERVER_LISTEN_ADDR=${cfg.server.listenAddr}" 155 "SPINDLE_SERVER_DB_PATH=${cfg.server.dbPath}" 156 "SPINDLE_SERVER_HOSTNAME=${cfg.server.hostname}" 157 "SPINDLE_SERVER_PLC_URL=${cfg.server.plcUrl}" 158 "SPINDLE_SERVER_DEV=${lib.boolToString cfg.server.dev}" 159 "SPINDLE_SERVER_OWNER=${cfg.server.owner}" 160 "SPINDLE_SERVER_MAX_JOB_COUNT=${toString cfg.server.maxJobCount}" 161 "SPINDLE_SERVER_QUEUE_SIZE=${toString cfg.server.queueSize}" 162 "SPINDLE_SERVER_SECRETS_PROVIDER=${cfg.server.secrets.provider}" 163 "SPINDLE_SERVER_SECRETS_OPENBAO_PROXY_ADDR=${cfg.server.secrets.openbao.proxyAddr}" 164 "SPINDLE_SERVER_SECRETS_OPENBAO_MOUNT=${cfg.server.secrets.openbao.mount}" 165 "SPINDLE_SERVER_TAP_URL=http://localhost:2480" 166 "SPINDLE_NIXERY_PIPELINES_NIXERY=${cfg.pipelines.nixery}" 167 "SPINDLE_NIXERY_PIPELINES_WORKFLOW_TIMEOUT=${cfg.pipelines.workflowTimeout}" 168 ]; 169 ExecStart = "${cfg.package}/bin/spindle"; 170 Restart = "always"; 171 }; 172 }; 173 }; 174 }