Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
NixOS - Purely Functional Package Management
Search
yawnt
June 01, 2016
Programming
0
1.5k
NixOS - Purely Functional Package Management
yawnt
June 01, 2016
Tweet
Share
More Decks by yawnt
See All by yawnt
Fun with Elixir and the Erlang VM
yawnt
2
230
Open Source as A Service
yawnt
0
170
Other Decks in Programming
See All in Programming
Clean Architecture by TypeScript & NestJS
ryounasso
0
150
Ruby メモリ管理 プログラミング
megmogmog1965
0
130
ぼっちを避けて楽しむためのアノテコノテ / Various Tips and Tricks to Avoid Loneliness and Have Fun
nrslib
3
1.7k
スクラムマスターって孤独じゃないですか?
yoshitaroyoyo
1
140
20240706_CDKConf
takuyay0ne
0
1.2k
[After Kotlin Fest 2024 LT Night @ Sansan] もっともっとKotlinを好きになる!K2 Compiler Pluginで遊んでみよう!
kitakkun
2
260
CSC307 Lecture 10
javiergs
PRO
0
310
Microservices rules (July 2024) : what good looks like
cer
PRO
0
1.6k
CSC307 Lecture 08
javiergs
PRO
0
330
なぜ宣言的 UI は壊れにくいのか / Why declarative UI is less fragile
uenitty
29
13k
Webエディタライブラリ 「CodeMirror」から学ぶ Webアプリ開発のテクニック
ryosukeigarashi
0
250
Google's Recipe for Scaling (Web) Security – LocoMocoSec 2024
lweichselbaum
0
170
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
229
130k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.9k
Scaling GitHub
holman
458
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
2.9k
Designing with Data
zakiwarfel
96
5k
Gamification - CAS2011
davidbonilla
78
4.9k
Facilitating Awesome Meetings
lara
46
5.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
15
4.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.3k
Bash Introduction
62gerente
607
210k
Thoughts on Productivity
jonyablonski
64
4.1k
GitHub's CSS Performance
jonrohan
1026
450k
Transcript
Nix(OS) purely functional package management Fueled by
f(x)
Why is state evil?
Expensive to keep track of mutation
Which in turns means no rollback
Which in turns means no portability
The Nix language
Why?
$ nix-repl > true true > 1 + 1 2
> (a: a + 1) 1 2
We use Nix to describe how 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 immutable once built
Everything lives inside a single directory, the store
“Live” packages are symlinked
Old packages are still in the store, just not accessible
Rollback for free
Multiple versions for free
Multiple envs for free
Puppies for free
Ok, maybe not puppies
$ nix-repl command not found: nix-repl $ nix-shell -p nix-repl
[nix-shell:~]$ nix-repl -v nix-repl v1.1.2 [nix-shell:~]$ exit $ nix-repl command not found: nix-repl
NixOS is a distribution built around Nix
In Nix, to build a package you write a function
In NixOS, to build a system you 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 is purely functional
Upgrading is the same as rebuilding from scratch
No /usr, /sbin/, /share
Just /nix/store
Nix(OS) cryoptographically hashes all build inputs
That means built-in versioning
dotfiles, just store ‘em in /nix/store .emacs.d, *wink* *wink* ;)
;)
More than just a distribution
nixops
(hail) hydra
Questions?