devcontainer-env 0.4.0

Bridge devcontainers and the host environment — run host commands with devcontainer service environments and automatically rewrite container service URLs to host ports
{
  "$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.base.schema.json",
  "name": "example-api",
  "service": "workspace",
  "dockerComposeFile": "docker-compose.yml",
  "workspaceFolder": "/home/vscode/workspace",
  "containerEnv": {
    "EXAMPLE_API_DATABASE_URL": "postgres://vscode@postgres:5432/example-db?sslmode=disable"
  },
  "mounts": [
    "source=${localWorkspaceFolderBasename}-nix,target=/nix,type=volume",
    "source=${localWorkspaceFolderBasename}-cache,target=/home/vscode/.cache,type=volume"
  ],
  "features": {
    "ghcr.io/devcontainers/features/nix:1": {
      "extraNixConfig": "experimental-features = nix-command flakes"
    }
  },
  "postCreateCommand": "sudo chown -R vscode:vscode /nix /home/vscode/.cache",
  "customizations": {
    "vscode": {
      "settings": {
        "terminal.integrated.defaultProfile.linux": "default",
        "terminal.integrated.profiles.linux": {
          "default": {
            "path": "nix",
            "args": [
              "develop"
            ]
          }
        }
      }
    }
  }
}