1 hour ago · 10 min read2011 words · Tech · hide · 0 comments

Most people meet Nix as a package manager, get scared by the syntax, and leave. That's a shame, because the whole thing is built on about three ideas. Once they click, the weird /nix/store/ paths, the reproducibility, the rollbacks, all of it stops being magic. No fluff. Let's look at what Nix is actually doing under the hood. 1. The language is just a calculator for attribute sets Before any packaging, Nix is a small, lazy, purely functional language. No statements, no loops, no mutation. Every expression evaluates to a value. Open a repl and poke it: $ nix repl nix-repl> 1 + 2 3 nix-repl> "pwn" + "writer" "pwnwriter" nix-repl> { name = "nix"; year = 2003; } { name = "nix"; year = 2003; } nix-repl> let x = 10; in x * x 100 Functions are arg: body. That colon is the whole syntax. nix-repl> square = x: x * x nix-repl> square 12 144 nix-repl> greet = name: "hello ${name}" nix-repl> greet "world" "hello world" Everything you write in Nix is one big expression that evaluates to an…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.