Functions

pattern: body

x: x + 1 x: y: x + y

(x: x + 1) 100 let inc = x: x + 1; in inc (inc (inc 100))

{ x, y }: x + y { x, y ? “bar” }: x + y { x, y, … }: x + y { x, y } @ args: x + y args @ { x, y }: x + y args@{ x, y, z, … }: z + y + x + args.a

eg

let
concat = x: y: x+y;
f = concat "foo";
g = concat "goo";
in
[(f "bar") (f "xxx") (g "bar") (g "xxx")]
let
  f = args@{ a ? 23, ... }: [ a args ];
in
  f {}

let
  f = args @ { ... }: [ (args.a or 23) args ];
in
  f {}

Built-in functions

import ./foo.nix map (x: x + x) [ 1 2 3 ]

Lookup path

lookup-path = < identifier [ / identifier ]… >

<nixpkgs>
<nixpkgs/nixos>

Comments

   # ccccoments
   /* ... */