nx_env_v1.nx
buildroot/runtime/nx_env_v1.nx
about
env.nx -- parse .env / dotenv-style configuration files.
The de facto standard for deployment config (Heroku, Vercel,
Docker Compose, direnv, 12-factor apps all use this format).
Line-oriented; each non-comment non-blank line is:
KEY=value
KEY=\"value with spaces\"
KEY='single-quoted'
KEY= (explicit empty)
Comments start with '#'. Blank lines ignored. Unquoted values
are trimmed of leading/trailing whitespace; quoted values are
taken verbatim between quote marks (no escape handling for
simplicity -- callers with \"dangerous\" values use JSON in the
.env + parse with json.nx).
Keys must match [A-Za-z_][A-Za-z0-9_]* or the line is skipped.
Used by: every Nishi service runtime for config, local dev
workflows, CI environment injection.
Complements ini.nx (which has sections) + query.nx (URL encode)
by covering the linear-only case.
Invariants:
E1 Zero-alloc: offsets into caller's buffer.
E2 Malformed lines silently skipped (caller logs if needed).
E3 Duplicate keys both emitted; caller-supplied last-wins
semantics if desired.
E4 CRLF and bare LF line endings both accepted.
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 43 | struct EnvEntry |
consts
| 41 | const ENV_ERR_OVERFLOW: i64 = -1 |
functions
| 48 | func env_is_key_start(b: i64) -> i64 |
| 59 | func env_is_key_cont(b: i64) -> i64 |
| 67 | func env_is_ws(b: i64) -> i64 called by 1: env_parse |
| 74 | func env_eol(buf: *u8, n: i64, off: i64) -> i64 called by 1: env_parse |
| 84 | func env_parse(buf: *u8, n: i64, |
| 206 | func env_find(buf: *u8, entries: *EnvEntry, count: i64, |
| 229 | func main() -> i64 calls 1: sys_mmap |