code wiki / (root) / env.nx

env.nx

buildroot/runtime/env.nx

7865 B253 linesdepth 3pulls 3 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

syscalls.nx env.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

structs

37struct EnvEntry {

consts

35const ENV_ERR_OVERFLOW: i64 = -1

functions

42func env_is_key_start(b: i64) -> i64 {
53func env_is_key_cont(b: i64) -> i64 {
called by 1: env_parse calls 1: env_is_key_start
61func env_is_ws(b: i64) -> i64 {
called by 1: env_parse
68func env_eol(buf: *u8, n: i64, off: i64) -> i64 {
called by 1: env_parse
78func env_parse(buf: *u8, n: i64,
200func env_find(buf: *u8, entries: *EnvEntry, count: i64,
223func main() -> i64 {