mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
nix is a layer devvm ships, as docker is: devvm nix, devvm node+nix, devvm build nix, or added to an existing VM in place. A folder with flake.nix, shell.nix or devenv.nix at its top level, or a default.nix that makes a shell (mkShell), gets it after its toolchains, so package.json and flake.nix give node+nix. - assets/layers/nix.sh: Nix 2.35.4's release tarball (releases.nixos.org), its version and SHA-256 per arch at the top, checked against the tarball's .sha256 files and nixos.org/nix/install, fetched with devvm-fetch; 2.35.3 fixes GHSA-hf6w-2rg9-v84g (store ownership in the scripted installer) and CVE-2026-110450 (store corruption through the daemon's repair flag). The tarball's own install --daemon --yes --no-channel-add, with experimental-features = nix-command flakes, trusted-users = root, sandbox = true and sandbox-fallback = false. The installer runs without proxy variables (it writes any it finds into a systemd override for nix-daemon, which would put a build's proxy into the image) and with NIX_SSL_CERT_FILE at the system's bundle. The layer checks the store is root's, adds Nix's default profile to the end of sudo's secure_path (/etc/sudoers.d/devvm-nix, checked with visudo), and appends Nix's profiles to BASH_ENV's PATH. direnv 2.38.2 (per arch) and nix-direnv 3.2.0's direnvrc, pinned the same way; direnv's hook in ~/.bashrc.d/direnv.sh, which loads before mise.sh so direnv's prompt hook runs after mise's and a dev shell's PATH comes first; a direnv lib file puts each project's layout under ~/.cache/direnv/layouts, so nix-direnv writes no .direnv into the project folder. Without systemd the script refuses in one line. - assets/layers/nix.policy: cache.nixos.org, channels.nixos.org, releases.nixos.org (GitHub is in base.policy). - assets/guest/sync.sh: nix-daemon gets a systemd drop-in with the VM's proxy (http_proxy, https_proxy, no_proxy) under network policy, removed when it's off, the daemon restarted when it changed. - image.NixLayer in Builtins; project.Detect's nix marker (a default.nix is read only as a regular file, at most 64 KiB); backend.FeatureNixLayer (nix-layer), needed by a VM of an image with the layer and by building one: Lima native, smolvm and Docker none, so both refuse in one line (backend_lacks); dockerLayers.choice returns every layer feature of the image, so docker+nix on Docker needs nix-layer too. - scripts/bump.sh: nix (the version nixos.org's installer names, the sums Nix publishes; it fails when the installer names no tarball, as Nix's Rust installer will), direnv, nix-direnv. - Docs: using/images (built-in layers, detection), using/toolchains (Nix projects), safety/network (the layer's hosts; source builds' hosts blocked), internals/images (the nix layer), internals/network (the daemons' drop-ins), internals/backends (nix-layer), internals/design (the nix layer beside Instead of Nix), backends, customizing, coding-agents, contributing (the e2e section); the CLI reference; AGENTS.md's assets/ and e2e lines. - Tests: Detect (markers, default.nix with and without a shell, a linked one), layer and environment lists, layer new nix reserved, nix-layer in ImageSpec and ImageFeatures, caps tests, up_checks.txtar (node+nix detected under an agent), docker.txtar (nix refused for a VM and a build). e2e nix section: the layer built behind a company proxy leaves no proxy settings and no password on its image's disk; a node+nix flake VM with network policy: pins, a root-owned store, sandbox without fallback, trusted-users root and an untrusted substituter ignored, the daemon's drop-in, nix run nixpkgs#hello, sudo nix and nix over ssh, the flake's node ahead of the shared node prompt after prompt through direnv, no .direnv in the folder, a blocked fixed-output fetch named by devvm-why, and the drop-in gone after network off. Review (security-audit skill, guidance mode, against the review task's list): the tarball and direnv's files are pinned in devvm's source and checked before tar or install runs; nothing from the host goes into the image (no proxy override, e2e greps the disk); the drop-in holds only the VM's own proxy URL, devvm's value, and goes when policy is off; trusted-users stays root and an untrusted user's substituters are ignored (the VM's user has sudo, so that guards an honest VM and the allowlist is what holds); secure_path gains only the root-owned default profile, last; /nix is on the VM's own disk and nothing mounts a host's or another VM's store. Found and fixed in review: Nix's default sandbox-fallback would build unsandboxed without a word where the kernel can't sandbox, so it's off. No confirmed findings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
58 lines
1.9 KiB
Plaintext
58 lines
1.9 KiB
Plaintext
# devvm layer new NAME: a starter script and allowlist in the layers folder;
|
|
# bad, taken and existing names are refused.
|
|
env DEVVM_MESSAGES=names
|
|
env LAYERS=$XDG_CONFIG_HOME/devvm/layers
|
|
|
|
exec devvm layer new pg
|
|
stdout '^==> layer_created layer=pg policy=\S*/devvm/layers/pg\.policy script=\S*/devvm/layers/pg\.sh$'
|
|
exec bash -n $LAYERS/pg.sh
|
|
grep '^set -euo pipefail$' $LAYERS/pg.sh
|
|
grep '^# Hosts a VM with the pg layer can reach' $LAYERS/pg.policy
|
|
|
|
# It's a layer at once: images complete it, and it's among the environments.
|
|
exec devvm __complete build p
|
|
stdout '^pg$'
|
|
! exec devvm build nope
|
|
stderr '^devvm: unknown_layer agents=.* envs=base node python rust go docker nix pg layer=nope$'
|
|
|
|
# An existing script is kept; an existing allowlist is kept for a new script.
|
|
! exec devvm layer new pg
|
|
stderr '^devvm: layer_exists file=\S*/devvm/layers/pg\.sh$'
|
|
cp mine.policy $LAYERS/db.policy
|
|
exec devvm layer new db
|
|
cmp $LAYERS/db.policy mine.policy
|
|
|
|
! exec devvm layer new node
|
|
stderr '^devvm: layer_name_reserved layer=node$'
|
|
! exec devvm layer new claude
|
|
stderr '^devvm: layer_name_reserved layer=claude$'
|
|
! exec devvm layer new base
|
|
stderr '^devvm: layer_name_reserved layer=base$'
|
|
! exec devvm layer new docker
|
|
stderr '^devvm: layer_name_reserved layer=docker$'
|
|
! exists $LAYERS/docker.sh
|
|
! exec devvm layer new nix
|
|
stderr '^devvm: layer_name_reserved layer=nix$'
|
|
! exists $LAYERS/nix.sh
|
|
! exec devvm layer new My_DB
|
|
stderr '^devvm: layer_name_invalid layer=My_DB$'
|
|
! exec devvm layer new ../x
|
|
stderr '^devvm: layer_name_invalid layer=\.\./x$'
|
|
! exec devvm layer new -- -x
|
|
stderr '^devvm: layer_name_invalid layer=-x$'
|
|
! exec devvm layer new
|
|
stderr '^devvm: usage_error '
|
|
! exec devvm layer pg
|
|
stderr '^devvm: usage_error '
|
|
! exists $LAYERS/node.sh
|
|
! exists $LAYERS/My_DB.sh
|
|
|
|
# A layers folder that can't be written to fails it.
|
|
rm $LAYERS
|
|
exec sh -c 'printf x > "$LAYERS"'
|
|
! exec devvm layer new web
|
|
stderr '^devvm: layer_new_failed reason='
|
|
|
|
-- mine.policy --
|
|
db.example.com
|