/etc/environment and /etc/profile.d/machine0-env.sh via cloud-init.
env ls
env get
Show env set details and variables.env new
env set.
env set
Add or update variables in an env set.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.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)
/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.