Nix(OS)purely functionalpackage managementFueled by
View Slide
f(x)
Why is state evil?
Expensive to keeptrack of mutation
Which in turnsmeans no rollback
Which in turnsmeans no portability
The Nix language
Why?
$ nix-repl> truetrue> 1 + 12> (a: a + 1) 12
We use Nix to describehow to build packages
{ stdenv, fetchurl, perl }:stdenv.mkDerivation {name = "hello-2.1.1";builder = ./builder.sh;src = fetchurl {url = “${packageURL};md5 = “${md5hash};};inherit perl;}
Packages are immutableonce built
Everything lives inside asingle directory, the store
“Live” packages aresymlinked
Old packages are still in thestore, just not accessible
Rollback for free
Multiple versions for free
Multiple envs for free
Puppies for free
Ok, maybe not puppies
$ nix-replcommand not found: nix-repl$ nix-shell -p nix-repl[nix-shell:~]$ nix-repl -vnix-repl v1.1.2[nix-shell:~]$ exit$ nix-replcommand not found: nix-repl
NixOS is a distributionbuilt around Nix
In Nix, to build a packageyou write a function
In NixOS, to build a systemyou write a function
configuration.nix
$ fdisk /dev/sda$ mkfs.ext4 -L nixos /dev/sda1$ mkswap -L swap /dev/sda2$ swapon /dev/sda2$ mount /dev/disk/by-label/nixos /mnt$ nixos-generate-config --root /mnt$ nano /mnt/etc/nixos/configuration.nix$ nixos-install$ reboot
{ config, pkgs, ... }:{imports =[./hardware-configuration.nix];boot.loader.grub.device = "/dev/sda";}
Building your system ispurely functional
Upgrading is the same asrebuilding from scratch
No /usr, /sbin/, /share
Just /nix/store
Nix(OS)cryoptographicallyhashes all build inputs
That meansbuilt-in versioning
dotfiles, just store‘em in /nix/store.emacs.d, *wink* *wink* ;) ;)
More than just adistribution
nixops
(hail) hydra
Questions?