You have almost certainly seen Nix code before you decided to learn any of it. Somebody’s configuration on GitHub, a snippet in a forum answer that happened to fix your problem, or a wall of curly braces and semicolons that clearly meant something to somebody.
So here is the one idea that makes all of it readable, and it is far smaller than that wall of punctuation seems to suggest: all Nix code you will ever work with describes one single value.
That value might be a number, a string or even an entire operating system. Either way, you write an expression and Nix works out what it comes to.
Everything below runs as you type. Change the code, then watch the value appear.
Nix gives you five basic types of value that stand on their own. Lists, attribute sets and functions all arrive later, and every one of them is just a way of holding these or putting them together.
423.14-7Int, or float with a point."nix""hello world""26.05"In quotes. Joined with +.truefalseYes or no. Nothing else.nullDeliberately nothing../flake.nix/etc/nixosNo quotes, and a slash in it.Paths on this website belong to the course’s small virtual project. This page never reads files from your computer.
Arithmetic is arithmetic. * and / go before + and -, just like in school.
Parentheses can be used to change the order.
Division is where int and float part ways. Two whole numbers divide into a whole number and the remainder is thrown away, so this is 3 rather than 3.5.
Put a point on either side, write 7.0 / 2, and the fraction survives.
Make this come out as 100.
Surprisingly, numbers are the part of Nix you will likely use the least. Strings on the other hand you will be knee-deep in forever, so let’s get comfortable with them.
They join together with +, exactly like you would hope.
Make this come out as "hello world".
Single values are cool, but lists are where it’s at.
A list holds a bunch of values in square brackets. No commas. This trips up everybody coming from another language.
++ is just like +, but for lists. It joins two of them into one.
Join a second list on, so you get [ 1 2 3 4 ].
- Nix describes one value, and everything is an expression.
- Numbers and strings use familiar operators, and brackets change precedence.
- Lists use spaces, not commas.
++joins two lists together into a new one.- The live result is your quickest feedback loop: change an expression and watch.
Next you will give values names and start building the shape used by every Nix configuration.


Share your thoughts