forked from tangled.org/core
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 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 = "spindle.tangled.sh"; 37 description = "Hostname for the server (required)"; 38 }; 39 40 jetstreamEndpoint = mkOption { 41 type = types.str; 42 default = "wss://jetstream1.us-west.bsky.network/subscribe"; 43 description = "Jetstream endpoint to subscribe to"; 44 }; 45 46 dev = mkOption { 47 type = types.bool; 48 default = false; 49 description = "Enable development mode (disables signature verification)"; 50 }; 51 52 owner = mkOption { 53 type = types.str; 54 example = "did:plc:qfpnj4og54vl56wngdriaxug"; 55 description = "DID of owner (required)"; 56 }; 57 58 secrets = { 59 provider = mkOption { 60 type = types.str; 61 default = "sqlite"; 62 description = "Backend to use for secret management, valid options are 'sqlite', and 'openbao'."; 63 }; 64 65 openbao = { 66 proxyAddr = mkOption { 67 type = types.str; 68 default = "http://127.0.0.1:8200"; 69 }; 70 mount = mkOption { 71 type = types.str; 72 default = "spindle"; 73 }; 74 }; 75 }; 76 }; 77 78 pipelines = { 79 nixery = mkOption { 80 type = types.str; 81 default = "nixery.tangled.sh"; 82 description = "Nixery instance to use"; 83 }; 84 85 workflowTimeout = mkOption { 86 type = types.str; 87 default = "5m"; 88 description = "Timeout for each step of a pipeline"; 89 }; 90 }; 91 }; 92 }; 93 94 config = mkIf cfg.enable { 95 virtualisation.docker.enable = true; 96 97 systemd.services.spindle = { 98 description = "spindle service"; 99 after = ["network.target" "docker.service"]; 100 wantedBy = ["multi-user.target"]; 101 serviceConfig = { 102 LogsDirectory = "spindle"; 103 StateDirectory = "spindle"; 104 Environment = [ 105 "SPINDLE_SERVER_LISTEN_ADDR=${cfg.server.listenAddr}" 106 "SPINDLE_SERVER_DB_PATH=${cfg.server.dbPath}" 107 "SPINDLE_SERVER_HOSTNAME=${cfg.server.hostname}" 108 "SPINDLE_SERVER_JETSTREAM=${cfg.server.jetstreamEndpoint}" 109 "SPINDLE_SERVER_DEV=${lib.boolToString cfg.server.dev}" 110 "SPINDLE_SERVER_OWNER=${cfg.server.owner}" 111 "SPINDLE_SERVER_SECRETS_PROVIDER=${cfg.server.secrets.provider}" 112 "SPINDLE_SERVER_SECRETS_OPENBAO_PROXY_ADDR=${cfg.server.secrets.openbao.proxyAddr}" 113 "SPINDLE_SERVER_SECRETS_OPENBAO_MOUNT=${cfg.server.secrets.openbao.mount}" 114 "SPINDLE_PIPELINES_NIXERY=${cfg.pipelines.nixery}" 115 "SPINDLE_PIPELINES_WORKFLOW_TIMEOUT=${cfg.pipelines.workflowTimeout}" 116 ]; 117 ExecStart = "${cfg.package}/bin/spindle"; 118 Restart = "always"; 119 }; 120 }; 121 }; 122 }