sha256:c5865d25e0d0f3ab949b15da8eb7d81a2ddc7852beed3dff8212ce94e795491e
Last pushed
9 days by matthisk
Type
Sandbox Kit
Manifest digest
sha256:c5865d25e0d0f3ab949b15da8eb7d81a2ddc7852beed3dff8212ce94e795491e
schemaVersion: "3"
displayName: Nix + direnv + nix-direnv
description: 'Single-user Nix (flakes enabled), direnv and nix-direnv, wired so that the workspace .envrc is loaded automatically: a direnv hook for interactive bash, and a BASH_ENV / CLAUDE_ENV_FILE hook so agent command shells get the same environment. nix-direnv state lives in the sandbox, not in the host-shared .direnv directory.'
sourceUrl: https://github.com/nix-community/nix-direnv
version: 0.2.0
licenses:
- LGPL-2.1-or-later
- MIT
kind: mixin
capabilities:
- type: com.docker.sandbox/network-policy@1
config:
runtime:
allow:
- cache.nixos.org
- channels.nixos.org
- releases.nixos.org
- tarballs.nixos.org
- nixos.org
- github.com
- api.github.com
- codeload.github.com
- raw.githubusercontent.com
- objects.githubusercontent.com
- release-assets.githubusercontent.com
- host.docker.internal:8080
- type: com.docker.sandbox/lifecycle@1
config:
install:
- command:
- /usr/local/libexec/nix-direnv-kit/setup.sh
- system
description: Hook direnv into /etc/sandbox-persistent.sh and configure the local cache
env:
- NIX_DIRENV_KIT_LOCAL_CACHE
user: "0"
- command:
- /usr/local/libexec/nix-direnv-kit/setup.sh
- user
description: Configure direnv and nix-direnv for the agent user
env:
- WORKSPACE_DIR
- NIX_DIRENV_KIT_AUTO_ALLOW
user: agent
startup:
- background: true
command:
- /usr/local/libexec/nix-direnv-kit/prewarm.sh
description: Pre-build the workspace .envrc environment
env:
- WORKSPACE_DIR
- NIX_DIRENV_KIT_PREWARM
user: agent
- type: com.docker.sandbox/agent-context@1
optional: true
config:
content: |
## Nix + direnv
This sandbox has single-user Nix (flakes enabled), direnv and
nix-direnv. The project's toolchain comes from its `.envrc`
(usually `use flake`, which loads the `devShell` of `flake.nix`).
- Every bash command you run loads the `.envrc` of its working
directory automatically, so the dev-shell tools are on PATH when
you run commands from the workspace. You don't need `nix develop`.
- To run something with another directory's environment, use
`direnv exec <dir> <command>`.
- If a tool is missing, add it to the dev shell in `flake.nix`
rather than installing it with apt or npm. The next command picks
up the change.
- The first evaluation of a flake can take minutes while Nix fetches
from cache.nixos.org. Run `direnv exec . true` to see its output
when debugging. Use `nix run nixpkgs#<pkg>` for one-off tools.
- Nix can reach cache.nixos.org, the nixos.org hosts and GitHub. A
different substituter or a private flake input is refused by the
sandbox network policy until it is allowed.
- type: com.docker.sandbox/agent-context@2
optional: true
config:
content: |
## Nix + direnv
This sandbox has single-user Nix (flakes enabled), direnv and
nix-direnv. The project's toolchain comes from its `.envrc`
(usually `use flake`, which loads the `devShell` of `flake.nix`).
- Every bash command you run loads the `.envrc` of its working
directory automatically, so the dev-shell tools are on PATH when
you run commands from the workspace. You don't need `nix develop`.
- To run something with another directory's environment, use
`direnv exec <dir> <command>`.
- If a tool is missing, add it to the dev shell in `flake.nix`
rather than installing it with apt or npm. The next command picks
up the change.
- The first evaluation of a flake can take minutes while Nix fetches
from cache.nixos.org. Run `direnv exec . true` to see its output
when debugging. Use `nix run nixpkgs#<pkg>` for one-off tools.
- Nix can reach cache.nixos.org, the nixos.org hosts and GitHub. A
different substituter or a private flake input is refused by the
sandbox network policy until it is allowed.
args:
autoAllow:
default: "true"
description: Trust every .envrc under the sandbox workspace (direnv whitelist), so no `direnv allow` is needed. Set to "false" to approve .envrc files by hand.
enum:
- "true"
- "false"
env: NIX_DIRENV_KIT_AUTO_ALLOW
localCache:
default: ""
description: URL of a binary cache on the host (for example a caching proxy in front of cache.nixos.org at http://host.docker.internal:8080). Nix tries it first and falls back to cache.nixos.org. Empty disables it. The kit's network policy allows only host.docker.internal:8080; for another host or port, add it with `sbx policy allow network`.
pattern: ^(https?://[A-Za-z0-9._:-]+(/[A-Za-z0-9._/-]*)?)?$
env: NIX_DIRENV_KIT_LOCAL_CACHE
nixpkgsRef:
default: nixos-26.05
description: nixpkgs branch, tag or commit that nix, direnv and nix-direnv are built from (github:NixOS/nixpkgs/<ref>). Only affects the installed tools, not the project's flake inputs.
pattern: ^[A-Za-z0-9._/-]+$
buildArg: NIXPKGS_REF
prewarm:
default: "true"
description: On every sandbox start, evaluate the workspace .envrc in the background so the first agent command does not wait for the flake to build.
enum:
- "true"
- "false"
env: NIX_DIRENV_KIT_PREWARM