Skip to content

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 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, brokered gh, 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.org configured
  • Anastro helpers: git-credential-anastro (GitHub) and anastro-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.

Because every Linux machine includes Nix (with its built-in nixpkgs already cached locally), you or an agent can install tools on the fly:

Terminal window
nix profile install nixpkgs#go # persists across local restarts
nix shell nixpkgs#rustc -c rustc -V # one-off command
nix develop # enter the workspace flake's dev shell
nix-shell -p jq

Because 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.

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.

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:

Terminal window
nix build .#python
nix store sign --key-file cache-key.sec --recursive ./result
nix copy --to 's3://acme-nix-cache' ./result

Ask your operator which binary cache URL to push to and which signing key the cluster trusts.

In the web UI, choose Nix flake under Environment in New machine. From the CLI:

Terminal window
anastroctl machine create --project <project> --nix github:acme/envs#python

Agents 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#python3 are rejected because they aren’t guest images; use the base image and install single packages inside the machine instead.

Project owners can set a default environment and required worker capabilities on the Machines page or from the CLI:

Terminal window
anastroctl project machine-defaults --project api --nix github:acme/envs#python
anastroctl project machine-defaults --project training --capability gpu:cuda
anastroctl project machine-defaults --project api # inspect current defaults
anastroctl machine create --project api --base --no-capabilities # override defaults

New machines created from the UI, CLI, or an agent inherit any fields you don’t specify. Changing defaults doesn’t rebuild existing machines.

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 snapshots
include = ["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.