Skip to main content
Create named sets of environment variables and inject them into VMs at creation time. Variables are written to /etc/environment and /etc/profile.d/machine0-env.sh via cloud-init.

env ls


env get

Show env set details and variables.

env new

Creates an empty env set. Add variables with env set.

env set

Add or update variables in an env set.
Keys must be valid POSIX names (A-Z, a-z, 0-9, _, starting with a letter or underscore). Values cannot contain newlines, carriage returns, double quotes, or null bytes.

env unset

Remove variables from an env set.

env rm

Delete an env set.
VMs that were created with the deleted env set are not affected — variables are baked in at creation time.

Limits

How injection works

Variables are injected once at VM creation via cloud-init into two files. Both are needed because Linux reads environment variables from different places depending on context:
  • /etc/environment — read by PAM and systemd (services, cron jobs, non-login sessions)
  • /etc/profile.d/machine0-env.sh — sourced by login shells (SSH sessions)
Updating an env set after creation does not affect already-running VMs. On NixOS images, variables land in user-writable files instead of /etc: ~/.machine0/env.sh (sourced by login shells and every zsh invocation) and ~/.ssh/environment (applied by sshd to every SSH session, regardless of shell). Older NixOS image versions ignore env sets until the image updates.