MCPcopy Index your code
hub / github.com/cachix/cloud.devenv.sh

github.com/cachix/cloud.devenv.sh @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
557 symbols 926 edges 102 files 146 documented · 26%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

cloud.devenv.sh

A cloud-hosted platform that provides GitHub Actions experience using Nix and devenv.

See talk What if GitHub Actions were local-first and built using Nix?.

Status

Currently in development, sign up for private beta.

Example

On top of regular devenv.sh each CI jobs gets extra information:

{ pkgs, lib, config, ... }:
let
  # https://devenv.sh/cloud/
  github = config.cloud.ci.github;
in {
  # https://devenv.sh/basics/
  packages = [ pkgs.cargo-watch ];

  # https://devenv.sh/languages/
  languages = {
    rust.enable = true;
    python = {
      enable = true;
      venv.enable = true;
      uv.enable = true;
    };
  };

  # https://devenv.sh/processes/
  processes = {
    myapp.exec = "cargo run -x";
  };

  # https://devenv.sh/services/
  services = {
    # run postgresql only locally
    postgresql.enable = !config.cloud.enable;
  };

  # https://devenv.sh/git-hooks/
  git-hooks = {
    hooks.rustfmt.enable = true;
    # run pre-commit hooks only on changes
    fromRef = github.base_ref or null;
    toRef = github.ref or null;
  };

  # https://devenv.sh/tasks/
  tasks = {
    "myapp:tests" = {
      after = [ "devenv:enterTest" ];
      exec = "cargo test";
    };
    # run code review agent on main branch
    "myapp:code-reviewer" = lib.mkIf (github.branch == "main") {
      exec = "claude @code-reviewer";
    };
  };

  # https://devenv.sh/outputs/
  outputs = {
    # package Rust app using Nix
    myapp = config.language.rust.import ./. {};
  };
}

Architecture

  • Backend (Rust) - REST API server handling authentication, project management, and GitHub webhooks
  • Frontend (Elm) - Modern web interface built with elm-land for managing environments
  • Runner (Rust) - WebSocket-connected service for executing commands in remote environments
  • Logger (Rust) - Centralized logging service for collecting and managing logs
  • Database (PostgreSQL 17) - Persistent storage with Diesel ORM migrations
  • Authentication (Zitadel) - Open Source OIDC SSO with OAuth2/LDAP/SAML2/OTP support

Development

  1. Setup Tailscale

  2. tailscale up

  3. Enable funnel at https://login.tailscale.com/admin/acls/file
  4. Copy DNS that's going to go into base_url
  5. Add export BASE_URL=... to .env

  6. Create GitHub App:

  7. Name: Choose a unique name for your app (this will be used in config as app_name)

  8. Callback URLs:
  9. Legacy zitadel login http://localhost:9500/ui/login/login/externalidp/callback
  10. V2 login UI http://localhost:9500/idps/callback
  11. Permissions: Repository: Check (write), Contents (Read)
  12. Account permissions: read only emails
  13. Subscribe to events: Pull Request, Check run, Push
  14. Webhook URL: BASE_URL/api/v1/github/webhook
  15. Secret: generate secure secret (use this as webhook_secret in config)

  16. In the GitHub app's general settings:

  17. Generate a new private key (use this in config as app_private_key)
  18. Generate a new client secret
  19. Save the client ID and client secret to .env.

shell export TF_VAR_github_client_id=... export TF_VAR_github_client_secret=... export TF_VAR_redirect_uris=["http://localhost:1234/", "<BASE_URL>/"]

  1. Create ./cloud.devenv.toml:
base_url = "https://<device-name>.<tailnet-name>.ts.net"

[github]
app_name = "your-app-name" # The name of your GitHub app
  1. Configure development secrets using secretspec:

shell secretspec set --provider env GITHUB_APP_PRIVATE_KEY="$(cat path/to/private-key.pem)" secretspec set --provider env GITHUB_WEBHOOK_SECRET="your-webhook-secret"

  1. Launch the processes

console devenv up

  1. Initialize Zitadel by following terraform/zitadel/README.md

  2. Set the Zitadel webhook signing key:

shell secretspec set --provider env ZITADEL_WEBHOOK_SIGNING_KEY="$(cat .devenv/state/zitadel/signing-key.txt)"

Migrations

diesel migration generate initial --diff-schema
cargo run -p devenv-backend migrate

Production

  1. Generate PostHog API key

  2. Configure production secrets using secretspec:

# Required production secrets
secretspec set --provider vault SENTRY_DSN="your-sentry-dsn"
secretspec set --provider vault POSTHOG_API_KEY="your-posthog-api-key"
secretspec set --provider vault DATABASE_URL="your-production-db-url"
secretspec set --provider vault GITHUB_APP_PRIVATE_KEY="$(cat path/to/private-key.pem)"
secretspec set --provider vault GITHUB_WEBHOOK_SECRET="your-webhook-secret"

Extension points exported contracts — how you extend this code

BetaAccessChecker (Interface)
Trait for checking beta access on users [1 implementers]
backend/src/auth.rs
MessageStream (Interface)
(no doc) [2 implementers]
runner/src/vsock.rs
DefaultApi (Interface)
(no doc) [1 implementers]
cloud-hypervisor-client/src/apis/default_api.rs
RequiredEnvVars (Interface)
(no doc)
frontend/src/interop.ts
SourceControlIntegration (Interface)
(no doc) [1 implementers]
backend/src/github/model.rs
Vm (Interface)
(no doc) [1 implementers]
runner/src/vm.rs

Core symbols most depended-on inside this repo

execute
called by 45
cloud-hypervisor-client/src/apis/request.rs
send
called by 32
runner/src/client.rs
returns_nothing
called by 18
cloud-hypervisor-client/src/apis/request.rs
allocate_resources
called by 17
runner/src/resource_manager.rs
with_body_param
called by 17
cloud-hypervisor-client/src/apis/request.rs
write
called by 13
runner/src/vsock.rs
success
called by 11
backend/src/job/model.rs
resource_summary
called by 6
runner/src/resource_manager.rs

Shape

Method 271
Class 145
Function 115
Enum 20
Interface 6

Languages

Rust97%
TypeScript3%

Modules by API surface

runner/src/resource_manager.rs45 symbols
backend/src/github/model.rs37 symbols
cloud-hypervisor-client/src/apis/default_api.rs32 symbols
backend/src/job/model.rs29 symbols
backend/src/zitadel/types.rs21 symbols
frontend/src/interop.ts19 symbols
runner/src/vm_impl/macos.rs16 symbols
backend/src/config.rs16 symbols
runner/src/vsock.rs14 symbols
backend/src/runner/serve.rs14 symbols
runner/src/protocol.rs13 symbols
runner/src/job_manager.rs13 symbols

Datastores touched

devenvDatabase · 1 repos

For agents

$ claude mcp add cloud.devenv.sh \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact