SuperAPI AI Directory

devbox

Deployment & operations

View repository

Updated 10-15 21:37

About this skill

devbox Skill

devbox is a Nix-based development environment management tool. It provides an isolated, reproducible environment for each project.

Installation

curl -fsSL https://get.jetify.com/devbox | bash

Basic commands

# プロジェクト初期化(devbox.json 作成)
devbox init

# パッケージ追加
devbox add nodejs@20
devbox add python@3.12 go@1.22
Remove package

devbox rm nodejs

Enter the devbox shell

devbox shell

Run a command (without entering the shell)

devbox run -- npm test

Run a script

devbox run test

Start services (process-compose)

devbox services start

Search for packages

devbox search nodejs


## devbox.json

```json
{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox.schema.json",
  "packages": [
    "nodejs@20",
    "python@3.12"
  ],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!'",
      "export FOO=bar"
    ],
    "scripts": {
      "test": "npm test",
      "dev": "npm run dev",
      "build": "npm run build"
    }
  }
}

Specify a package

{
  "packages": [
    "nodejs@20",
    "python@3.12.0",
    "go@latest",
    "github:NixOS/nixpkgs#hello"
  ]
}

Search for packages: https://www.nixhub.io

Script

{
  "shell": {
    "scripts": {
      "test": "npm test",
      "dev": "npm run dev",
      "lint": [
        "eslint .",
        "prettier --check ."
      ]
    }
  }
}
devbox run test
devbox run dev

Service (process-compose)

process-compose.yaml Create:

processes:
  web:
    command: npm run dev
  db:
    command: postgres -D /tmp/pgdata
devbox services start      # 全サービス起動
devbox services stop       # 全サービス停止
devbox services ls         # サービス一覧

Environment variables

{
  "env": {
    "DATABASE_URL": "postgresql://localhost:5432/dev",
    "NODE_ENV": "development"
  },
  "shell": {
    "init_hook": [
      "export API_KEY=$(<.api_key)"
    ]
  }
}

GitHub Actions

jetify-com/devbox-install-action is used. For a complete example, see assets/gh_action_example.yaml .

steps:
  - uses: actions/checkout@v4

  - uses: jetify-com/devbox-install-action@v0.12.0
    # with:
    #   enable-cache: true  # Nix store キャッシュ

  - run: devbox run test

Commonly used options

Options Description
--config Specify the path to devbox.json
--quiet Suppress output
--print-env Output environment variables

References