Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 489 Bytes

af9g-nix-let-in.md

File metadata and controls

36 lines (29 loc) · 489 Bytes

Nix: let...in

#nix #nixos #programming #language

Expressions let...in are expressions that can access variables inside itself.

Valid ones:

let
	b = a + 1;
	a = 1;
in
	a + b

let
	attrset = { x = 1; };
in
	attrset.x

let
	a = {
		x = 1;
		y = 2;
		z = 3;
	}
in
	with a; [ x y z ] # or [a.x a.y a.z]

Invalid ones

a = let x = 1; in x;
b = x;

[[17dv-inherit]] is a way to assign a variable inside a scope that is nested inside another scope using the same name.