#### Nix Language
- functional
- lazy evaluation
- immutable
- derivations
#### Derivations
Nix Code ⇒ Derivation ⇒ Nix Store Path
#### Language Structures
- Variables
- Sets
- Lists
- Functions
- Structures
#### Variables
- immutable
a = 100;
b = "string";
c = '' multi-
line
string
'';
#### Sets
{
foo = {
val = "set in set";
};
}
#### Lists
a = [1 2 3 4];
#### Functions
func1 = foo: foo + 1;
func2 = {a, b}: a + b;
- no complex functions
- one thing functions
#### Language Special Structures
- let
- with
- import
- inherit
- if
#### With
env.sysPkgs = with pkgs; {
git
vim
exa
};
#### Import
x = import ./some/file.nix;
y = import ./dir; # gets default.nix
#### Inherit
x = x;
inherit y;
- creates same name set (y?), with all the props of the set (y?)
#### If
foo = if x = 0 then "bar" else "zoo";
#### Let
- let block has stuff
- in block then yields result from stuff
my_func:
let
z = 1;
e = 2;
in {
foo = z + e;
}
#### Stuff to know
- REPL
$ nix repl
- Language server
- github rnix-lsp
- vim, emacs, VSCode
- Manuals
- nix manual
- nixpkgs manual
- A book
- https://nixos-and-flakes.thiscute.world/