Nix files

From wikinotes
Revision as of 13:14, 16 August 2020 by Will (talk | contribs) (→‎imports)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

imports

imports bind all of the let variables defined within a file to a set.

# ./foo.nix

let
  a = "A"
  fn = x: x
# ./bar.nix

foo = import ./foo.nix {};   # foo expects a hash argument, we provide it

foo         # { a="a"; fn=lambda }
foo.a       # returns attribute 'a' 
foo.fn "B"  # invokes method 'fn' with argument "B"