code wiki / (root) / nx_env_v1.nx

nx_env_v1.nx

buildroot/runtime/nx_env_v1.nx

7866 B259 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic env
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_env_v1.nx

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

main sys_mmap

structs

43struct EnvEntry

consts

41const ENV_ERR_OVERFLOW: i64 = -1

functions

48func env_is_key_start(b: i64) -> i64
59func env_is_key_cont(b: i64) -> i64
called by 1: env_parse calls 1: env_is_key_start
67func env_is_ws(b: i64) -> i64
called by 1: env_parse
74func env_eol(buf: *u8, n: i64, off: i64) -> i64
called by 1: env_parse
84func env_parse(buf: *u8, n: i64,
206func env_find(buf: *u8, entries: *EnvEntry, count: i64,
229func main() -> i64
calls 1: sys_mmap