-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlightning-talk.html
634 lines (565 loc) · 24.3 KB
/
lightning-talk.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Nix(OS)</title> <!-- Nix.* -->
<link rel="stylesheet" href="reveal-js/css/reveal.css">
<link rel="stylesheet" href="reveal-js/css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="reveal-js/lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal-js/css/print/pdf.css' : 'reveal-js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<!-- TODO list:
- Release process?
- NixOS security
- Vulnix
- NixOS tests (/lib/tests + /nixos/tests)
- Overlays (demonstration?)
- Nix 1.12 (see presentation by Eelco Dolstra)
- GNU Guix
- Show websites:
- https://hydra.nixos.org/
-->
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Nix(OS) - Revolutionizing packaging and configuration management!
<!-- .element: style="font-size:1.65em" -->
<!-- ... packaging and configuration management! -->
<!-- Totally not stolen from @Profpatsch... :D -->
![NixOS logo](img/nixos-white.svg)
<!-- .element style="background:#222;border-style:none;box-shadow:none" -->
The Purely Functional Linux Distribution
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# What?
<div>
<div style="float: left; width: 70%;">
- Nix (package manager)
- Nixpkgs (Nix packages collection)
- NixOS (operating system)
- NixOps (DevOps / cloud deployment tool)
- Hydra (Nix based continuous build system)
</div>
<div style="float: left; width: 30%;">
![Nix* ISO/OSI model](img/nix-iso-osi.svg)
<!-- .element height="95%" width="95%" style="background:white;border-style:none" -->
</div>
</div>
Notes:
- Entries correspond to GH repos
- Only read out slide (details will follow later, e.g. on the next
slide)
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# nix-env (manipulate or query Nix user environments)
<!-- .element: style="font-size:1.13em" -->
![User environments](img/user-environments.png)
https://nixos.org/nix/manual/figures/user-environments.png
<!-- .element: style="font-size:0.5em" -->
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Problems of classical package managers
- Upgrades/configuration changes destructively update the system
state (overwriting files in sequence -> temporary inconsistency)
- State -> nondeterministic builds -> not reproducible
- Different versions of a binary
- Package conflicts
- No rollbacks
- No configuration management
Notes:
- Apps might have an undefined behaviour or crash when launched
during an upgrade + possibility of permanent damage when
interrupted (e.g. even unbootable!).
- Incomplete dependency specifications (no isolated build
environment)
- Nominal dependency specifications (only name and optionally
version)
- Configuration files not controlled by the package manager.
- Upgrading modified configuration files is problematic.
- Binaries = global variables (e.g. /bin/bash)
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Nix(OS)
- Atomic upgrades/rollbacks (software & configuration)
- Multiple versions of a package (side-by-side, e.g. testing a new
Apache version)
- Deterministic & Reproducible builds
- Reliable upgrades (and rollbacks - configuration bound to correct
software version + service reloads/restarts)
- Reliable channel upgrades/rollbacks (e.g. 17.03 -> 17.09)
- Unprivileged users can securely install software
Notes:
- Next slide: Declarative configuration management
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Being functional
- Classically: Imperative configuration
- Stateful changes (-> dependency hell, inconsistent states, etc.)
- NixOS: Declarative configuration
- Packages/Configuration = immutable values
- (Complete) rebuilds instead of destructive updates
- Referential transparency (~an expression always evaluates to the
same result)
Notes:
- Referential transparency: An expression always evaluates to the
same result in any contex (no side effects like (uncontrolled)
imperative updates).
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Problems
- Lacking manpower/workforce (e.g. for better
testing/security/documentation)
- Not all packages are reproducible (2016: 12.8%)
- Running pre-compiled binaries
- Scripts with hard-coded paths don't work
- No GUI for package/configuration management
- No LTS releases or super stable (i.e. old :P) branches
- Not all use-cases or configuration options supported
- Some tricks available + PRs welcome ;)
Notes:
- 13 Dec 2016: "Currently, out of 36550 build steps in a full NixOS
evaluation, only 4699 (12.8%) were detected as non-deterministic.
(Note that Hydra can only detect the presence of non-determinism,
not its absence)." - Eelco
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Nix
- A purely functional package manager (transparent source/binary
deployment)
- Secure multi-user support
- Stores packages in the Nix store (`/nix/store` by default)
- Each package has it's own unique identifier/directory
- E.g. `qn96dbgqdryaw38zw6v08da34q5v4qz3-git-repo-1.12.37`
<!-- .element: style="font-size:0.7em" -->
(cryptographic hash, name, version)
- Enables multiple versions & binary substitutes
- "Forces" complete dependencies
Notes:
- Hash captures all dependencies (160-bit truncations of SHA-256
encoded in base-32 (i.e. 32 characters))
- src/libstore/store-api.cc Store::makeStorePath + comment above
- Version: Digit after a dash
- Garbage collection (nix-collect-garbage)
- Similar to Content Addressed Storage (CAS)
- Nothing is ever overwritten!
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Nix expressions / Nix expression language
- A DSL (not a GPL!)
- Describes graphs of build actions ("derivations")
- Packages, compositions of packages, configurations, ...
- Dynamically typed ~~("Nix won't be complete until it has static
typing." @edolstra)~~ - https://typing-nix.regnat.ovh/
- Lazy (a very important feature!)
- Purely functional (no side-effects, immutable store)
- Turing complete (e.g. Dhall is not ->
[dhall-nix](https://github.com/dhall-lang/dhall-nix))
Notes:
- DSL vs GPL: MD5 collisions by @Azlig (Chromium updater) :D
- "Config files shouldn't be Turing complete" (-> always terminate)
- Dhall is explicitly typed, evaluated, and configuration files can
be reduced to a normal form
- TODO:
- Bad evaluation errors? :D
- Missing typing
- Error in anonymous function at unknown file?
- Evaluated vs interpreted?
- Bugs? :D (e.g. a-b)
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Nixpkgs (the Nix packages collection)
<!-- .element: style="font-size:1.6em" -->
- Main GitHub repository (permissive MIT/X11 license)
- Contains definitions of packages (Nix) and modules (NixOS)
- Also contains tests, library functions, etc.
- Different branches (rolling: master, stable: release-YY.MM)
- Build and tested by Hydra (+ uploaded to binary cache)
- Distributed through (nixpkgs-)channels (nixpkgs-unstable,
nixos-unstable(-small), nixos-YY.MM(-small))
Notes:
- Stable: MM = 03 or 09 (end of month, branch off one month before)
- Talk about codenames, release schedule, freezing, etc.?
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# An example Nix package (pgpdump) <!-- .element: style="font-size:1.5em" -->
```nix
pgpdump = callPackage ../tools/security/pgpdump { };
```
```nix
{ stdenv, fetchFromGitHub
, supportCompressedPackets ? true, zlib, bzip2
}:
stdenv.mkDerivation rec {
name = "pgpdump-${version}";
version = "0.32";
src = fetchFromGitHub {
owner = "kazu-yamamoto";
repo = "pgpdump";
rev = "v${version}";
sha256 = "1ip7q5sgh3nwdqbrzpp6sllkls5kma98kns53yspw1830xi1n8xc";
};
buildInputs = stdenv.lib.optionals supportCompressedPackets [ zlib bzip2 ];
meta = with stdenv.lib; {
description = "A PGP packet visualizer";
longDescription = ''
pgpdump is a PGP packet visualizer which displays the packet format of
OpenPGP (RFC 4880) and PGP version 2 (RFC 1991).
'';
homepage = http://www.mew.org/~kazu/proj/pgpdump/en/;
license = licenses.bsd3;
platforms = platforms.linux;
maintainers = with maintainers; [ primeos ];
};
}
```
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Dependency graphs
pgpdump's runtime dependencies:
```bash
nix-store -q --graph $(nix-store --realise $(nix-instantiate -A pgpdump)) | dot -Tpdf | zathura -
```
![Pgpdump runtime dependencies](img/pgpdump-rdeps.svg)
Notes:
- Build time dependencies available as well (but graph way too
large)
- E.g. CVE patches as build inputs
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# NixOS
- Implements a declarative and purely functional system
configuration model
- Based on Nix (package + configuration management)
- NixOS modules (separation of concerns)
- Form the full "system configuration"
```nix
{ config, pkgs, ... }: {
options = { nested attribute set of option declarations using mkOption };
config = { nested attribute set of option definitions };
}
```
Notes:
- modules = functions
- { config } -> config = full system configuration
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# An example NixOS module <!-- .element: style="font-size:1.5em" -->
```nix
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.vim;
in {
options.programs.vim = {
defaultEditor = mkOption {
type = types.bool;
default = false;
description = ''
When enabled, installs vim and configures vim to be the default editor
using the EDITOR environment variable.
'';
};
};
config = mkIf cfg.defaultEditor {
environment.systemPackages = [ pkgs.vim ];
environment.variables = { EDITOR = mkOverride 900 "vim"; };
};
}
```
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Another example NixOS module <!-- .element: style="font-size:1.5em" -->
```nix
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.monetdb;
in {
meta.maintainers = with maintainers; [ StillerHarpo primeos ];
###### interface
options = {
services.monetdb = {
enable = mkEnableOption "the MonetDB database server";
package = mkOption {
type = types.package;
default = pkgs.monetdb;
defaultText = "pkgs.monetdb";
description = "MonetDB package to use.";
};
user = mkOption {
type = types.str;
default = "monetdb";
description = "User account under which MonetDB runs.";
};
group = mkOption {
type = types.str;
default = "monetdb";
description = "Group under which MonetDB runs.";
};
dataDir = mkOption {
type = types.path;
default = "/var/lib/monetdb";
description = "Data directory for the dbfarm.";
};
port = mkOption {
type = types.ints.u16;
default = 50000;
description = "Port to listen on.";
};
listenAddress = mkOption {
type = types.str;
default = "127.0.0.1";
example = "0.0.0.0";
description = "Address to listen on.";
};
};
};
###### implementation
config = mkIf cfg.enable {
users.users.monetdb = mkIf (cfg.user == "monetdb") {
uid = config.ids.uids.monetdb;
group = cfg.group;
description = "MonetDB user";
home = cfg.dataDir;
createHome = true;
};
users.groups.monetdb = mkIf (cfg.group == "monetdb") {
gid = config.ids.gids.monetdb;
members = [ cfg.user ];
};
environment.systemPackages = [ cfg.package ];
systemd.services.monetdb = {
description = "MonetDB database server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
path = [ cfg.package ];
unitConfig.RequiresMountsFor = "${cfg.dataDir}";
serviceConfig = {
User = cfg.user;
Group = cfg.group;
ExecStart = "${cfg.package}/bin/monetdbd start -n ${cfg.dataDir}";
ExecStop = "${cfg.package}/bin/monetdbd stop ${cfg.dataDir}";
};
preStart = ''
if [ ! -e ${cfg.dataDir}/.merovingian_properties ]; then
# Create the dbfarm (as cfg.user)
${cfg.package}/bin/monetdbd create ${cfg.dataDir}
fi
# Update the properties
${cfg.package}/bin/monetdbd set port=${toString cfg.port} ${cfg.dataDir}
${cfg.package}/bin/monetdbd set listenaddr=${cfg.listenAddress} ${cfg.dataDir}
'';
};
};
}
```
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# An example NixOS configuration <!-- .element: style="font-size:1.5em" -->
<!-- TODO: More awesome stuff? :) -->
```nix
{ config, pkgs, ... }:
{
system.nixos.stateVersion = "18.03";
nix.useSandbox = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "de";
defaultLocale = "en_US.UTF-8";
};
time.timeZone = "Europe/Berlin";
environment = {
systemPackages = with pkgs; [
# Core
vim_configurable gitAndTools.gitFull wget
# Monitoring
htop python3Packages.glances
# Tools
time file tree lsof
pciutils hdparm zip unzip
# Network
inetutils bind.dnsutils
tcpdump
];
variables = {
EDITOR = "vim";
};
};
programs.bash.enableCompletion = true;
}
```
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Nixpkgs overlays
```nix
self: super:
# self: Final package set / fixed-point result (use as dependencies)
# super: Previous evaluation result
{
nix = super.nix.override {
storeDir = "${<nix-dir>}/store";
stateDir = "${<nix-dir>}/var";
};
boost = super.boost.override {
python = self.python3;
};
rr = super.callPackage ./pkgs/rr {
stdenv = self.stdenv_32bit;
};
}
```
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Community
- A great & kind community
([overview](https://nixos.org/nixos/community.html))
- [nix-devel mailing list](https://groups.google.com/forum/#!forum/nix-devel)
- Discourse (Forum): [discourse.nixos.org](https://discourse.nixos.org/)
- Bugs and PRs via GitHub ([Nixpkgs](https://github.com/NixOS/nixpkgs))
- [#nixos](irc://irc.freenode.net/#nixos) on irc.freenode.net
- Blogs ([NixOS planet](https://planet.nixos.org/))
- Local meetups (e.g. in [Stuttgart](https://hackmd.shackspace.de/NixOS-meetup))
- NixCon
- Commercial support via consulting companies
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Learning
- [Learn X in Y minutes, where X=nix](https://learnxinyminutes.com/docs/nix/)
- [A tour of Nix](https://nixcloud.io/tour/)
- By Joachim Schiele & Paul Seitz from Tübingen ;)
- [Unofficial user's wiki](https://nixos.wiki/wiki/Main_Page)
- Manuals
([Nix](https://nixos.org/nix/manual/),
[Nixpkgs](https://nixos.org/nixpkgs/manual/),
[NixOS](https://nixos.org/nixos/manual/), and
[NixOps](https://nixos.org/nixops/manual/))
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Trying out Nix*
- Use Nix side-by-side with your regular package manager:
```bash
curl https://nixos.org/nix/install | sh
```
- Experiment with nix-env, nix-shell, nix-repl, etc.
- Try out NixOS (e.g. VirtualBox demo appliance)
- Install NixOS
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Thank you :)
![Nix project logo](img/nix-snowflake.svg)
<!-- .element height="30%" width="30%" style="background:#222;border-style:none;box-shadow:none" -->
- Questions?
- Feedback
- Discussion
Notes:
- Feedback
- Possible improvements?
- Do or do not, there is no try.
- Q&A
- Hacking
- Summary
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# License
- For the content of these slides
- Public domain
- CC0 1.0 Universal (CC0-1.0)
- Doesn't apply to external sources like images
- Some quotes, notes, etc. are from other sources (this can
hopefully be considered fair use)
- Framework: reveal.js
- MIT (see https://github.com/hakimel/reveal.js)
</textarea>
</section>
<section data-markdown data-separator-notes="^Notes:">
<textarea data-template>
# Repology (2018-06-08)
![Repology statistics](img/map_repo_size_fresh-2018-06-08.svg)
<!-- .element height="70%" width="70%" style="border-style:none;box-shadow:none" -->
Notes:
- Is Nix production ready?
- Yes (at least definitely beyond a PoC)
- Don't trust these numbers too much
</textarea>
</section>
</div>
</div>
<script src="reveal-js/lib/js/head.min.js"></script>
<script src="reveal-js/js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'reveal-js/plugin/markdown/marked.js' },
{ src: 'reveal-js/plugin/markdown/markdown.js' },
{ src: 'reveal-js/plugin/notes/notes.js', async: true },
{ src: 'reveal-js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
],
slideNumber: true,
history: true,
width: 1080,
height: 720,
// Disable all fragments for normal viewing. They can be enabled for
// the presentation with ?fragments=true (URL parameter):
fragments: false
});
Reveal.configure({ pdfMaxPagesPerSlide: 1 });
</script>
</body>
</html>