Nix Language Quirks

From NixOS Wiki
Revision as of 09:32, 26 October 2017 by imported>Danbst (added let and with)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

with and let

with gets less priority then let. This can lead to confusions, especially if you like to write with pkgs;:

nix-repl> pkgs = { x = 1; }

nix-repl> with pkgs; x
1

nix-repl> with pkgs; let x = 2; in x
2

So we see, that let binding overrides with binding. But what about this?

nix-repl> let x = 2; in with pkgs; x
2

Nah, with and let have different priority when resolving names.

Good discussion on this topic