Nix variables

From wikinotes
Revision as of 22:39, 5 August 2021 by Will (talk | contribs) (→‎with)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

scope

var = "value"  # assign variable (global)

# under 'let' variables are local to current scope
let
  local_var = "value"
  other_var = "value"

with

'with' exposes set keys as local variables within scope

fn = x:
  with { a="A"; b="B"; c=x }
    a + b + c

fn "C"
"ABC"