Environments
Linux machines boot a read-only base image packed with common developer tools. When a project needs
more, you can install packages ad hoc with Nix inside the machine, or build a reusable Nix guest
environment so every machine boots ready to go. A .dwfs.toml file in your repo controls
snapshot exclusions, rebuild hooks, background services, and declared secrets.
The base image
Section titled “The base image”The Linux base image includes:
- Core shell and utilities:
bash, coreutils,findutils,diffutils,grep,sed,gawk,tar,gzip,xz,zstd,bzip2,zip,unzip,rsync,patch,file,tree,less,procps,which,ncurses,util-linux(mount,lsblk) - Developer & search tools:
git,git-lfs, brokeredgh, Chromium,curl,wget, CA certificates,ripgrep,fd,jq,sqlite3,tmux,vim,nano - Runtimes & build tools:
python3,uv,node,npm,gcc,make,pkg-config - Networking:
ssh,nc,dig,ip,ss,lsof - Nix: single-user Nix with flakes enabled and
https://cache.nixos.orgconfigured - Anastro helpers:
git-credential-anastro(GitHub) andanastro-secret(Secrets)
There is no system-wide pip—use uv instead (uv venv && uv pip install <pkg>, or
uv run --with <pkg> <cmd>). Prebuilt wheels and standard Linux binaries (from npm, GitHub
releases, or wheels) work out of the box thanks to
nix-ld.
Commands run as root in /workspace. Anything installed outside /workspace lives on the
machine’s own disk—it survives local restarts and spin-downs, but isn’t captured in snapshots.
Install tools inside a machine
Section titled “Install tools inside a machine”Because every Linux machine includes Nix (with its built-in nixpkgs already cached locally), you
or an agent can install tools on the fly:
nix profile install nixpkgs#go # persists across local restartsnix shell nixpkgs#rustc -c rustc -V # one-off commandnix develop # enter the workspace flake's dev shellnix-shell -p jqBecause Nix installs live on the machine’s private disk rather than /workspace, they aren’t
replayed across rollbacks, forks, or graceful moves to another host.
Boot from a Nix environment
Section titled “Boot from a Nix environment”To make every machine for a project boot with the same toolchain already baked in, define a guest
environment using anastro.lib.guestEnvironment:
# flake.nix in your own repository{ inputs.anastro.url = "github:leftshiftlabs/anastro";
outputs = { anastro, ... }: let python = system: anastro.lib.guestEnvironment { inherit system; name = "python"; packages = pkgs: [ pkgs.python3 pkgs.uv pkgs.ruff ]; }; in { packages.x86_64-linux.python = python "x86_64-linux"; packages.aarch64-linux.python = python "aarch64-linux"; };}Target the CPU architecture of your cluster’s worker hosts.
Build in CI and push to a binary cache
Section titled “Build in CI and push to a binary cache”Worker hosts never build guest environments—they only fetch signed closures from the binary caches
your operator configured in [machines.nix] (Configuration). Build
and push from CI:
nix build .#pythonnix store sign --key-file cache-key.sec --recursive ./resultnix copy --to 's3://acme-nix-cache' ./resultAsk your operator which binary cache URL to push to and which signing key the cluster trusts.
Launch a machine with it
Section titled “Launch a machine with it”In the web UI, choose Nix flake under Environment in New machine. From the CLI:
anastroctl machine create --project <project> --nix github:acme/envs#pythonAgents can pass an environment to machine_create too—just tell them which flake to use.
- Hosts cache a fetched flake reference for an hour. After that they re-fetch so updated branches
are picked up (falling back to the cached copy if the fetch fails). Pin a commit
(
github:acme/envs/<rev>#python) for strict reproducibility. - Fetch or evaluation errors surface on the machine and retry with backoff.
- Plain package references like
nixpkgs#python3are rejected because they aren’t guest images; use the base image and install single packages inside the machine instead.
Project defaults
Section titled “Project defaults”Project owners can set a default environment and required worker capabilities on the Machines page or from the CLI:
anastroctl project machine-defaults --project api --nix github:acme/envs#pythonanastroctl project machine-defaults --project training --capability gpu:cudaanastroctl project machine-defaults --project api # inspect current defaultsanastroctl machine create --project api --base --no-capabilities # override defaultsNew machines created from the UI, CLI, or an agent inherit any fields you don’t specify. Changing defaults doesn’t rebuild existing machines.
Workspace settings
Section titled “Workspace settings”Drop a .dwfs.toml at your workspace root (and commit it with your repo) to configure snapshot
exclusions, rebuild hooks, background services, and secrets:
format = 1
[exclude]add = ["coverage/", "*.log"] # keep out of snapshotsinclude = ["dist/"] # opt back into snapshotting a default-excluded path
[[rebuild]]name = "deps"when = ["pnpm-lock.yaml"]run = "pnpm install --frozen-lockfile"timeout = "10m"
[[service]]name = "web"run = "pnpm dev"ready = { tcp = 3000 }
[[secret]]name = "STRIPE_KEY"env = "STRIPE_KEY"| Section | What it does |
|---|---|
[exclude] |
Keeps regenerable files on disk but out of snapshots. Excluded by default: node_modules/, .venv/, venv/, __pycache__/, target/, .next/, .turbo/, dist/, build/, .gradle/, and DerivedData/. |
[[rebuild]] |
Runs after any boot (create, resume, restore, rollback) whenever a when file changed since the hook last succeeded. Commands wait for hooks to finish; terminals don’t. |
[[service]] |
Starts in the background after boot, waits up to 2 minutes for its ready check (tcp or http), and restarts with backoff if it exits. Logs go to /var/log/anastro/<name>.log. |
[[secret]] |
Declares a secret your project expects from 1Password (Secrets). |
Because excluded paths aren’t stored in snapshots, restored or forked machines won’t have them until
your [[rebuild]] hook recreates them.
- Machines: create machines, run commands, and manage snapshots.
- Full design: Layers, exclusions and
.dwfs.tomlin the spec.