-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
338 lines (328 loc) · 11 KB
/
default.nix
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
let
pkgs = import <nixpkgs> {};
presentation = {
title = "Nix/NixOS Seminar";
titleImage = "./assets/nix-logo.svg";
description = "What is it and why is it useful?";
authors = ["Cole Stowell"];
theme = "gaia";
assets = [
./images/presentation_repo.png
(pkgs.fetchurl
{
url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/56b7a5788005a3eaecb5298f0dbed0f7d1573abc/logo/nix-snowflake-colours.svg";
hash = "sha256-43taHBHoFJbp1GrwSQiVGtprq6pBbWcKquSTTM6RLrI=";
name = "nix-logo.svg";
})
];
slides = [
{
type = "basic";
title = "A Little About Me";
body = ''
My name is Cole (he/him).
I'm a 2nd year CS major.
I love Linux, Rust, and NIX.
'';
}
{
type = "basic";
title = "Save questions to the end";
body = ''
I am horribly distractable and might trail off in this presentation.
'';
}
{
type = "numbered";
title = "'Nix' refers to many things!";
slideGroups = [
{
title = "Nix Language";
slides = [
{
type = "basic";
title = "Data Types";
body = ''
```nix
10 # Numbers
"hello!" # Strings
[ 10 20 50 ] # Lists
# Attribute Sets
{
hello = "world";
foo = "bar";
num = 20;
}
```
'';
}
{
type = "columns";
title = "Nix Expressions";
bodies = [
''
- Returns a value (number, string, list, attribute set, etc.)
- Are files
- No main function, just "building a value"
''
''
```nix
# authors.nix
["Eddie" "Wilson"]
```
```nix
# default.nix
let
authors = import ./authors.nix;
in
"By ''${builtins.concatStringsSep " and " authors}"
# By Eddie and Wilson
```
''
];
}
{
type = "columns";
title = "Nix is a *Functional* Language";
bodies = [
''
- "Turn a thing into a different thing"
- Single parameter (but we can curry functions together)
''
''
```nix
let
add = s: t: s + t;
in
add 10 20
```
```nix
multiplier:
builtins.map (x: x * multiplier) [1 3 4 7 20]
```
''
];
}
];
}
{
title = "Nix Package Manager";
slides = [
{
type = "basic";
title = "Nix can be installed almost everywhere!";
body = ''
- Linux
- MacOS
- Windows WSL
- Docker
- And (with some added work) even more!
'';
}
{
type = "basic";
title = "Nix is not a traditional package manager";
body = ''
- Packages are called **derivations**.
- Created via evaluating nix expressions
- Can be installed in many ways so not really important
'';
}
{
type = "basic";
title = "What is it made of?";
body = ''
The most important parts are the
- Input paths (Folders, files, **other derivations**, etc.)
- Builder script (with some arguments)
An **out path** is *automatically* generated based on the inputs and builder script.
'';
}
{
type = "basic";
title = "Where does this all take place?";
body = ''
- THE NIX STORE!
- Exists at /nix/store
- Contains just about everything (compiled software, source code, images, libraries, etc.)
- Paths look like...
<span class='small'>
- `${pkgs.firefox}`
- `${pkgs.bash}`
- `${./images/nix_language_basics.png}`
</span>
'';
}
{
type = "basic";
title = "How is a derivation built? (1/2)";
body = ''
1) Nix Expression is evaluated and it returns a derivation
2) Derivation is **instantiated** (.drv file is created in the Nix Store)
'';
}
{
type = "basic";
title = "How is a derivation built? (2/2)";
body = ''
After instantiation, we now have to **realize** the derivation...
1) Before realizing the target derivation, we realize all derivations depended on
2) Then the builder is run with the fully realized inputs and writes to output path
'';
}
{
type = "basic";
title = "";
body = ''
- **Anybody** can build **anything** and get the **exact same result, bit-for-bit**
- When inputs change like...
- Source code
- Compiler
- Library
- Builder script
- Considered a brand new derivation
- Upgrading **cannot** break other software
'';
}
];
}
{
title = "Nixpkgs";
slides = [
{
type = "basic";
title = "What the hell is Nixpkgs?";
body = ''
- A massive nix expression containing 100,000+ derivations!
- Technically a function which returns a **massive** attribute set
- Contains some useful functions too
'';
}
{
type = "columns";
title = "We can use Nixpkgs!";
bodies = [
''
`<nixpkgs>` evaluates to the path of the current version in the nix store
Mine is `${<nixpkgs>}`
''
''
```nix
let
pkgs = import <nixpkgs> { };
in
pkgs.firefox
```
''
];
}
];
}
{
title = "NixOS";
slides = [
{
type = "basic";
title = "What is it?";
body = ''
> What if an **operating system** was the output *instead* of a derivation?
- Define all software, services, configurations, drivers, bootloader, etc.
- **Super** maintainable
'';
}
{
type = "basic";
title = "NixOS can do so much...";
center = true;
body = "";
}
{
type = "columns";
title = "Easily Configure Services";
bodies = [
''
Example: CalDAV server on the domain "cal.example.domain" with an automatically generated verified SSL certificate
''
''
```nix
services = {
radicale = {
enable = true;
settings.server.hosts = ["127.0.0.1:5232"];
};
nginx.virtualHosts = {
"cal.example.domain" = {
forceSSL = true; # Redirect to https
enableACME = true; # Request SSL cert
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://localhost:5232/";
};
};
};
};
```
*Only 16 lines!*
''
];
}
{
type = "basic";
title = "Rollbacks";
body = ''
- Everytime you "build" your NixOS config, a new generation is created
- Switch between generations at runtime **and** boot time
*Shaun Thornton is the 🐐*
'';
}
{
type = "basic";
title = "Impermanence";
body = ''
NixOS can be set up to not retain any files you don't *explicitly* list
*I only keep what I want!*
'';
}
{
type = "basic";
title = "Ecosystem Stuff";
body = ''
- **home-manager**: Configure individual users
- **nixos-anywhere**: Overwrite *any* Linux system with your NixOS config
- **deploy-rs**: Deploy your config to a machine easily
- **sops-nix**: Store secrets and decrypt at runtime
- **nixos-generators**: Generate bootable image from NixOS config
- Any literally so much more!
'';
}
];
}
];
}
{
type = "basic";
title = "Nix is so powerful!";
center = true;
body = ''
It can build so much reproducibly...
'';
}
{
type = "basic";
title = "...even a presentation on Nix!";
body = ''

'';
}
{
type = "basic";
title = "Thank you for listening!!";
titleImage = "./assets/nix-logo.svg";
body = "Any questions?";
center = true;
}
];
};
buildPresentation = import ./lib/builder.nix pkgs;
in
buildPresentation presentation