start	end	text
540	1540	All right, cool.
2080	2740	All right.
3180	3980	Hello, guys.
3980	4700	I'm Alex.
4700	8220	This is my first year at DEF CON and also my first time talking about Nix.
8220	9200	So I'm a little nervous.
9200	11280	If I stumble a little bit, bear with me.
11640	15500	And my talk is Zero to Infra in 100 Days, a Nix Speedrun.
15720	20040	And I'm going to start with a little story about how I got into it and then kind of go through this crash course.
20040	22820	And it's funny, because Farid is actually the one that got me into it.
22820	25400	I met him at his younger brother's wedding.
25400	27040	Omar, he's one of my best friends.
27480	31760	And he said, you should come with me to play Nix at scale 22.
31980	33840	And I was like, I don't know what that is.
33840	35240	But I like Linux, and I'm a nerd.
35240	36880	And I have all my home lab stuff.
36880	38640	So I'll just go and try it.
38900	40680	And I was there.
40680	43840	I set up a laptop in four days trying to learn Nix.
43840	46080	Looking back, I didn't really have it.
46120	49280	But I met a bunch of really smart people, and I learned a ton of stuff.
49280	50380	And it was really awesome.
50380	52240	And I'm just super Nix-billed now.
52240	54560	So I'm going to try to get you to be the same way, maybe.
56720	59460	So I'm going to get into it.
59480	65240	My talk is pretty similar to Farid's in terms of like the beginner level.
65240	67260	Mine's going to also kind of be a crash course.
67260	70000	But I'm going to say mine's going to be even less academic.
70000	78200	I'm going to try to give you what you need to know to get started as soon as possible without knowing all the theory behind it.
78800	83040	And you can kind of pick that up as you go once you see the power and you start using it.
84440	89760	So in most of these talks, people are always going to open with like what is Nix?
89760	92400	And I think that that is not the right question.
92400	97800	I think why Nix and showing what it is and how it works for you is more powerful.
97800	104220	Because when people open with these talks, they'll say Nix is a package manager, a language, and an operating system.
104220	106640	And when you say that, it just turns everyone off immediately.
107540	109160	That's three different things.
109160	114580	That's like saying C, Ubuntu, and APT.
114780	116580	That's like what the hell?
117400	120280	But with Nix, why Nix?
120280	124640	It simplifies what you can get out of everything.
124640	129960	So in a traditional sense, I'm going to use like kitchen recipes analogies a lot.
129960	132060	At Planet Nix, somebody made that analogy and I really liked it.
132060	133280	It clicked for me a lot.
133280	140340	So the traditional is like if I'm making a tomato sauce, the traditional way would be like I got to add tomatoes and that's all I'm going to say.
140360	146320	But the Nix sauce is going to say I'm going to add tomatoes from this farm at this acidity, stored at this ripeness level.
146320	152080	And it's going to give you the precise same outputs every time because you are going to give it the same inputs every time.
153940	160300	And actually, I guess, so I also made myself like a little cheat sheet here so I don't mess up, run any commands and stuff.
160300	166380	And my talk is just going to, I'm going to run a lot of stuff live and just show you rather than talking about it.
166560	171340	So just to show you some of the really cool stuff that Nix can do to kind of get you hooked, I'm going to talk about like Nix shell.
171540	181780	So what I'm going to do is something that probably isn't normally allowed where I'm going to make an environment with Python 2 and 3 at the same time.
181780	184020	And when I run this, it's actually going to throw a fit.
184040	186180	And that's good because it's actually Nix protecting us.
186180	191780	It's saying, you know, Python 2 isn't actually marked as like secure anymore.
191920	195080	And we can just get by this by allowing to run insecure.
197880	199880	But what it's going to do is it's going to put me into a shell.
199880	201760	So this is like my own little environment.
201920	207000	And Free talked about this a little bit where it's just referencing store paths.
207000	208300	And I'll talk more about that in a second.
208300	212920	But it's just making path variables for your shell.
212920	219890	So I can run and you can see like I have Python 2.7.
219890	225090	And I can also do the same command for Python 3.
225090	226430	I have 2 and 3 in the same shell.
226430	227790	I can use either one if I want.
229330	230890	So that's pretty cool.
234780	236840	And then a couple more.
236840	242060	You can run things that are packaged by others and put up without actually having it on your system.
242060	242840	And this is super useful.
242840	246200	I use this all the time through a different command like comma.
246420	251200	So just as an example of that, I don't have this.
254540	255260	Yeah.
255400	257860	It's like a little like 2E terminal game.
257980	259140	2048 in terminal.
259140	259840	I don't have it.
259840	261620	But I can just run it.
261620	262500	I can nix run.
262500	265820	And what it's going to do is it's going to grab it from the magic world.
265820	268140	And it's going to just run it on my machine.
268140	269160	I don't have it on my machine.
269160	270840	But now I have it on my machine.
270840	272900	And now I'm playing this game.
274000	277700	So that's kind of like why use Nix.
277700	282680	So those are a couple examples of what it is, how you can use it, why you should care a little bit.
282860	285300	And now this is the whole funny thing.
285300	288440	Why does Nix seem to have such an infamous learning curve?
288440	294560	This is the graph that I found on one of the most popular discourse pages for this is one of the best lectures about Nix.
294560	298480	And it was a 30-minute dense lecture about using the language.
298860	301840	And that one of the people commented this on it.
301840	302720	And I think that makes sense.
302720	307260	It's like the learning curve is infamously super steep and treacherous.
307260	309040	And I don't think it has to be that way.
309040	313460	I don't think you actually need to learn all the theory right now.
313460	318260	I think all you need to know is just a couple commands I'll show you and the environment.
318260	321420	So Nix run, Nix develop, and how do you encode the people shit.
321420	322440	That's all you need to know.
322640	325100	You can be productive today using it.
325100	327620	You don't need to know like you can say that's a car.
327620	330340	You don't need to know about how to put the engine together inside of it yet.
330340	332980	You'll probably be interested and want to learn about that later.
333080	339560	I will get into some of the inner workings because I think it's important for you to have a baseline understanding of how it works.
339560	344280	So you're not just looking in this magical wizard orb and not knowing how the magic works.
344280	348980	But as a general guideline for all of it, don't fight immutability.
348980	356360	That this was the biggest rule for me to like start using Nix without fighting myself on it.
356360	363280	So one of the first mistakes I made was I needed to make an alias in my shell.
363280	365660	And I set my shell up with Nix.
365660	369140	So I build it and it gets put on my machine in the state that it is.
369140	374680	And I went into my ZSHRC and I added the alias and it worked for a while.
374680	376180	But the next time I rebuilt, it was gone.
376180	378320	Because it rebuilds it every time.
378320	384720	So you're not thinking of, you're not opening settings menus and trying to find the setting and setting it there.
384720	387180	You're gonna go into the configuration file for it.
387180	392340	You're gonna set the option there and just rebuild to a state where that is the state of things.
392480	398940	You'll avoid most of the roadblocks, I think, to just getting started immediately with a Nix system just by following this rule.
398940	400020	Just don't fight immutability.
400020	403320	Keep in mind, like, I'm not following steps.
403320	410460	And this gets into the whole notion of imperative versus declarative, which I'm gonna get into like what the heck does that even mean?
410640	420200	But like manually going and doing a setting would be something that's imperative and just doing it in your configuration and then rebuilding, that's gonna be declarative.
420640	423920	So declarative versus imperative, like, what the heck does this even mean?
423920	427700	So this is like the Wikipedia definition for it.
428200	431500	I'm not gonna read it because this is like my crash course talk.
431500	432680	Like, who cares?
432740	434120	This is my analogy.
434720	436860	For imperative, I want a sandwich.
437140	438320	Do I order it?
438320	439060	Do I make it?
439060	441540	I need to do XYZ to get my sandwich somehow.
441540	442400	Okay, I'm gonna make it.
442400	445900	I'm gonna, like, I'm gonna get the bread, I'm gonna put the meat on it, mustard, mayo, blah, blah, blah.
445900	448440	I did all these things and now I've got my sandwich.
449020	454440	So in a declarative approach, all I do is I want a sandwich, I declare I have a sandwich.
454440	456160	And now I just have a sandwich.
456380	460300	All the stuff to get to the sandwich, I don't care about.
460380	462180	That can be, Nix can do that for me.
462180	463980	Nix can be my sandwich guy.
464240	465780	But me, I have the sandwich.
465780	467120	I declare I have it, so now I have it.
467120	468420	That's my analogy.
468420	471440	And this is like the whole food thing I'm gonna keep going into more.
473780	474420	Yeah.
474900	478320	So this is like an example of setting up a web server imperatively.
478320	480380	You gotta run a crap load of commands.
480840	490140	You're running curl commands, you're adding PPAs, you gotta add systemd services, you gotta add a user for it, you're running all these commands one at a time, one after the other.
490180	496340	If one of those links is broken, like, stuff's busted, and then by the end of it, like, what did you even install?
497140	498740	Like, can you do this again?
498740	502260	Like, you can make a script, but what if something else is broken?
502380	504980	And this is like my, this is the point of it.
505460	508160	Do you even know all the stuff on your system, on your computer?
508160	510780	Do you actually know all the stuff installed on your computer right now?
510780	511740	I bet you don't.
511740	514460	Like, unless you use Nix, then you do.
514460	519960	But, like, you just, like, it's following, like, a medium article to set something up.
519960	523640	You copy a link, and you run some curl command, and it puts something on your computer.
523640	525180	Two months later, you don't even remember doing that.
525180	526280	It's on there somewhere.
526280	529440	Maybe you're, like, refreshing your repository, but you have no idea.
529540	542620	The declarative approach to this, this is the same thing set up, but with Nix, and I'm going to break this down a little bit in a second, but you're declaring each service, and this is going to give you the same results every time, no matter what.
542720	551760	And we're doing everything from setting up the services, like Nginx, PostgreSQL, and the systemd service, and even setting up the user to run this.
551760	555440	And so, when I look at this, this can be kind of, like, intimidating to look at at first.
555440	559700	It kind of, there's a lot of brackets, and this is how I look at it.
559700	560540	I break it down.
560540	561480	I do my scribble.
561600	573020	Just look for the, like, top-level attributes, the curlies, and when you actually look inside each of them as, like, a chunk, it actually makes it a lot easier to understand what's even going on.
573020	574780	So, like, just look at the first one.
574980	576520	It's a service, Nginx.
576520	579920	We're enabling it, and then we're just doing settings for that specifically.
579920	580840	Same thing for the other ones.
580840	585980	The systemd one, that's the same syntax you're writing to, like, write your own systemd service.
585980	588880	You're just doing it through Nginx, and it's going to end up on your system after you rebuild it.
588880	590080	Even the same thing with the user.
590080	592600	I'm making a user called MyApp.
595460	608380	So, DevShells and Durand are your gateway drug into getting into Nginx, and if you take nothing else away from this talk, it's just start using DevShells to do development of whatever you're working on.
608380	614140	It makes stuff super easy, and it makes collaborating with other people really, really easy, too.
614420	619160	Your directory becomes your full custom environment.
620380	628060	So, just to show this, I, like, and this is all the stuff you need to do a Durand and DevShell.
628060	639820	You need the envrc, which is for Durand, and flakes, which I'll get into a little bit later, but just as a top level, that's just the thing packaged reproducibly monolith.
639820	655920	So, just to show this, I did a web server in Rust, super simple, and I'm going to show, like, this is the flake, the whole thing, and, like, this kind of ties into yoinking other people's stuff.
655920	670220	You can yoink this and replace it with the stuff you need for your project, but all I'm doing is I need Rusty, I need cargo, I need Rust analyzer, and I'm spitting this stuff out when I enter it, and I have the inputs, and you'll see, like, once I enter the shell,
670220	671100	you see all this stuff.
671100	675420	Like, I loaded it, I loaded the flake, and then it spits that stuff out that was inside the flake.
676240	680580	So, if I exit now, if I go out of this, you see it says unloading.
680580	682600	If I run Rust C, I don't have it.
682600	683680	It's not on my system.
683680	689600	But as soon as I just enter that DevShell, I have Rust C now, magically.
689880	692740	I'm inside of this new environment.
692780	696440	And the same thing, I can just do cargo run.
696440	701300	All my stuff was together, and now I just, like, I have this little private web page below from Nix.
701300	702220	It just works.
702220	703940	I have it on the DevShell.
703940	710780	And for a lot of the projects I've been working on, I've repackaged them to use DevShells, and it makes sharing the setup super easy.
710780	723040	Like, if you're trying to collaborate on something with someone, they can clone your project, and then they just enter the DevShell, as long as they have Nix on their system, and they have the exact same environment that you have for working on something.
723040	730080	It makes it really easy to, like, have the same stuff on all the machines for your whole team, all working on the same stuff.
735760	736600	Okay.
736600	741700	So now is my slightly dense part of this, like, lecture part.
741700	743300	This is my speedrun lecture.
744000	745580	How does the stuff actually work?
745580	754200	I think it's important for you to have some base knowledge of what's going on under the hood, so it doesn't all seem like some mystical orb that you're pondering.
754200	755180	You're like a wizard.
755360	767540	So I think all you really need to know to get jump-started and feel not confused by what you're doing every day is derivations, what's the store, what is Nix packages, and what are flakes.
767540	773160	And I'm going to go through, like, a blitz explanation of all these, and I'm going to give some examples as I go.
773400	778620	So basically, and this goes back to my food thing, derivations, how stuff gets built.
778620	781080	A derivation is a recipe to do something.
781080	783940	For example, let's do the GNU hello program.
783940	785720	All it does is just print out hello world.
785980	790960	And this is basically, this is the stuff that's inside of that derivation.
790960	796840	It's going to say, I need this hello tar.gz source code stuff, I need GCC, and I need make.
796840	798460	And these are the recipe inputs.
798500	804120	And if I do this, if I put all these together, I'm going to get this same output every time.
805020	808020	And just to show this,
816880	820020	this is what a derivation actually looks like.
820100	825940	We showed this a little bit earlier, but so you don't actually need to read too far into it.
825940	827280	It looks like JSON.
827280	828120	It is JSON.
828120	837580	And you can see it's spitting out that hash stuff and the output where it's going to end up on the machine.
837940	839480	But this is what's inside of it.
839480	840080	It's not scary.
840080	840960	It's just JSON.
840960	843180	It's showing all the inputs.
843180	846320	You can see this is the, these are the inputs.
846320	847640	This is how it's being built.
847640	848920	These are all the flags.
848920	851620	You see CMake flags for make stuff.
851660	852660	That's how it is.
862820	875720	And just to show a little bit more about this hash thing at the bottom, just so you know what this is, that's basically the result of all the inputs and the derivation getting spit out somewhere.
875720	878820	And that will tell you that it's the same thing every time based on the inputs.
878820	885840	That's how we make sure that all the stuff that we're putting in is the exact same every time so that we get that reproducibility.
885860	892100	And so just to show this, if we do that same thing, make note of the hash thing.
892100	902220	If I do this command, all I'm doing here is I'm going to show this derivation again, but I'm just going to add a random variable to it just called my var equals demo.
902220	903180	It doesn't do anything.
903180	904120	It doesn't change anything.
904120	909960	But the fact that I added it and the fact that it's there in the inputs, it changes the output.
909960	911180	It changes the hash.
911180	913380	We can see it in the inputs here.
913820	914540	It's here.
914540	915520	It doesn't do anything.
915620	921420	But the end result, this GJI, whatever, and then down here, it's different.
921420	925400	The end result is different because of what we put in, even though it's not actually doing anything.
925400	929300	And Nix is very picky about everything that you put in.
929300	934680	And that guarantees that even if you change a comment, the entire thing is going to be different in the end.
935760	948720	And just to show what is this hash, where does it come from, I have this file, file.txt.
949120	950360	This is a test file.
950360	953120	Capital T exclamation point, just make note of that.
953600	959820	If I do Nix hash file, file.txt, it's going to give me the hash for the file of the stuff in it.
959820	968960	If I go back into that file and I change something, I'm just going to like, there, just one thing.
969040	975300	If I run that same thing, my hash is different because I changed the contents of the file.
975300	976640	So that's all that a hash is.
976640	979460	It's just making sure that your inputs are the same.
981140	983340	So next is the Nix store.
983340	985580	This is where everything lives.
985580	988420	This is like the pantry in your house for all the stuff.
988800	991420	This is like an excerpt of what all the stuff looks like in the Nix store.
991420	996860	I highlighted all the hashes so you can kind of separate out what the thing is and then the hash.
997520	1002860	And the binary cache, I think that's something important to know about as well.
1002900	1004920	You can think of that as precooked meals.
1005720	1013280	And when I go to, I think I have this, yeah, I'm going to get into it here as well.
1013280	1023000	But when I go to grab something, I'm going to grab, I'm going to get the derivation from somewhere, which I'll talk about in a second.
1023000	1024200	And I'm storing that.
1024200	1026660	And final binary, all that's being put into the store.
1026840	1034680	And when I go to actually decide whether or not I need to build something from the derivation, you can actually skip that whole step.
1034680	1039120	Because if we know the hash is the exact same, we know all the inputs are the same.
1039120	1041620	So we know the result is going to be what we want.
1041620	1050280	So if somebody else already built that for us and they put it somewhere that we can grab easily, why would we do the whole process of rebuilding it all ourselves?
1050380	1051980	So that's all a binary cache.
1051980	1053340	It's just precooked meals for you to fetch.
1053340	1055260	No need to manually rebuild stuff.
1055540	1059020	So this slide is like my densest one.
1059020	1061260	I was thinking about what the best way to explain this is.
1061260	1066320	But Nix packages, you can think of as where all these recipes come from.
1066320	1068800	It's the biggest, fattest cookbook.
1068920	1077080	And this search.nixos.org, you can go here, you can do a search for any Nix package you could probably possibly think of, and it's probably there.
1077080	1078620	Somebody's probably packaged it and put it there.
1078620	1080340	It is absolutely huge.
1080420	1082240	And it's like all the secret sauce.
1082240	1085740	It has so many recipe generators.
1086540	1090080	Before, I had this slide saying recipes themselves.
1090080	1094300	But I think saying that is a little bit too much of an oversimplification.
1095000	1103580	So here's the flow of what happens when we're run that command to run the hello program or the one where I did 2048.
1104360	1109220	When you run it, Nix is going to look up hello in Nix packages, which is your big cookbook.
1109220	1113000	It's going to look in the cookbook for the hello.
1113260	1115640	And the cookbook has a recipe generator.
1115640	1118160	You can think of this as like a template for the recipe.
1118340	1120320	And it's not the recipe itself.
1120320	1125420	So your machine's going to get the recipe from the cookbook on its own.
1125720	1132460	Nix is going to run the recipe generator to get the actual recipe, the derivation for your system.
1132640	1135380	And then it's going to ask the binary cache, yo, do you have this thing?
1135380	1138560	And if you have it, sweet, I don't have to build it myself.
1138560	1139660	Yoink, I'm going to grab it.
1139660	1142040	And if not, I'm going to build it myself.
1142360	1147300	And this process of building it yourself, like let's say for this hello, it didn't have it.
1147300	1159860	Let's say I needed GCC to do it, it's going to turtle all the way down recursively and go all the way down to the bootstrap layer if it has to, if it can't find stuff in the binary cache.
1160000	1168220	Which is really cool, because that means you can build up anything from the lowest level possible, which would take forever, but you could.
1168220	1170780	You don't need external sources to build.
1170780	1179480	All you need is the very bare minimum, like POSIX shell and bash and C compiler, stuff like that, super minimal.
1180080	1183220	And at the end, it puts all this stuff in the store.
1183260	1191060	And it puts both the recipe, the derivation, and the final binary in the store.
1191060	1192760	It puts both of those in the store together.
1192960	1195460	Not under the same hash, they're separate.
1196620	1198520	So yeah.
1198520	1199940	So that's Nix packages.
1199940	1204820	So just to recap derivations or recipes, the Nix store is your pantry.
1205040	1206820	Nix packages is the biggest, fattest cookbook.
1206820	1213660	And I went on a side tangent about these recipe generator things, just to not confuse you later if you look into it more.
1214020	1216780	And this is just a graph that shows all the...
1216780	1221420	it might be kind of hard to see, but it shows all the repositories.
1221620	1226420	And you can see that Nix packages unstable is just completely in a league of its own, all the way up at the top.
1226420	1229560	The AUR is a little bit underneath it.
1229760	1234120	But those different versions get into what we're going to talk about next for Nix packages.
1234320	1235480	So Flakes.
1235480	1237740	Flakes is the reproducibility solution.
1237980	1241760	Explaining Flakes can be pretty difficult, but just use Flakes, bro.
1241760	1242180	Trust me.
1242180	1242800	Just trust me, bro.
1242800	1244080	All the cool kids use Flakes.
1245560	1250360	In order to explain Flakes, I'm going to talk about channels really quickly.
1250360	1254720	And I think you need to know about that to understand what Flakes is doing and why you should care.
1254720	1262880	So earlier when I gave you this example for building the hello binary, I showed you these are the inputs, and I lied to you.
1262880	1263700	I'm sorry.
1263700	1269460	There's actually a hidden input, and it's the Nix packages version that you're grabbing the stuff from.
1269460	1275160	And that actually changes the output because the inputs are different.
1275560	1284740	So just to show this, I'm going to run evaluate, which is just going to do the... it's going to tell me what I'm going to get.
1284740	1285860	It's not going to do the build for me.
1285860	1287300	It's going to tell me what the result would be.
1287940	1291020	And you're going to see I have this hash here.
1291100	1294240	Really only look at the last couple of characters just to pay attention.
1294520	1301800	And I'm going to do the same thing, but this time I'm going to specify I want it from Nix packages version 2505.
1302300	1305520	And I think my system right now is on 2511 or unstable.
1305640	1309400	But you'll see if I run it, my hash is different.
1309400	1310020	And why?
1310020	1314820	It's actually a different version of this hello program.
1314820	1318800	So if I run this, just to show, this one's 2.12.2.
1318840	1321540	If I run the same thing,
1325400	1327240	this one's 2.12.1.
1328240	1330840	I actually think I have a different version in that example.
1331240	1337660	I can change this to 2505.
1342080	1343720	2.12.1, same thing.
1343880	1345660	But the versions are different.
1345660	1354700	So on my system, the one that I have currently when I ran that evaluate, I got 2.12.2 and the hash was different versus what it is if I use some different version.
1354700	1357920	So that gets back to the whole it's different.
1357920	1362840	Running different versions of stuff for the same build will give you a different result.
1362840	1365680	So this is kind of where Flakes comes in.
1365680	1370300	And what it does is it's pinning of Nix packages.
1370540	1374640	And this is like the reproducibility solution monolith all in one.
1375160	1380340	So it goes back to the highest level of the same inputs are always going to give you the same outputs.
1380340	1382520	And now it's the same inputs for real.
1382520	1387420	It's using all the same Nix package source.
1387900	1390820	And you can pin versions for specific packages.
1390940	1395640	Once I run this, like this is just a super quick example of that hello in there.
1395640	1396260	Super minimal.
1396260	1400280	I'm just pinning it to version 2311 for Nix packages in this example.
1400680	1400760	And
1404000	1408100	it's going to generate me a lock file, which is how they version everything.
1408100	1410800	And it's going to keep track of the version of all the packages.
1410800	1418920	So that if I give you my repo or whatever, and you run it with the Flake in it, you're going to get the exact same output every time.
1419480	1424360	Because the version, the Nix packages version for every package you're using is going to also be the same.
1424360	1426520	There's no more invariability between our systems.
1426520	1430440	What if what if your system is running 2511 and mine's 2505?
1430440	1431480	Now we get a different result.
1431480	1433480	This is not the reproducibility that we actually want.
1434540	1436820	So this is like the highest level.
1436820	1438500	Let's take this to the next level.
1438500	1441620	This is all the previous stuff we talked about.
1441620	1446680	But instead of configuring applications, packages, you're doing it for your system now.
1447000	1452760	And this, you can do this for your bootloader, login manager, blah, blah, blah, all the stuff for your system, which is, it's pretty crazy.
1452760	1456280	When you think about it, you can do your entire system configured declaratively.
1456280	1460820	And you can just share your entire computer configuration with somebody else.
1461080	1463900	And they can just have your whole setup, which is what I did earlier.
1463900	1468580	I put, I put my laptop right here, my whole configuration onto my brother's laptop.
1468580	1469960	I did that two days ago.
1471000	1474500	And just to show this, I'm going to give a quick example.
1476880	1479740	And all that I have here is just a flake.
1479980	1486820	And it is using Astro's micro VMs, which is just a, I'm just going to boot up a micro VM to show you a NixOS system.
1487120	1491520	And I'm sharing my Nix store with it so that the boot up time is really fast.
1491520	1492180	But this is the whole flake.
1492180	1492720	It's really simple.
1492720	1495400	All I'm doing is I'm pulling in Nix packages.
1495400	1496440	I'm using unstable.
1496720	1499540	And I'm using micro VM, which is the thing I just told you about.
1499540	1501500	And this is the configuration for it.
1501500	1506120	The stuff that you care about is this, this configuration.nix file that I made to make it easier to follow.
1506120	1507160	This is what it looks like.
1507160	1509560	I'm setting up my host name for my system.
1509560	1511480	I'm making a user, demo user.
1511500	1514260	I'm giving him a password, a description.
1514420	1517100	He's a normal user and I'm giving him wheel group so he can run sudo.
1517340	1521600	And he's got these packages for the system.
1521600	1524420	He's got the whole system that has Vim on it.
1524420	1529120	And it's going to auto log in for my demo user and I'm hitting the system state version.
1529640	1537660	So if I just run this, you're going to see it's going to boot up a micro VM.
1541040	1545060	And it's going to put that stuff from the configuration on this machine.
1545060	1548140	And you'll see we're going to be logged in as demo user in a second.
1548140	1552100	And we'll see we have the Vim package on here.
1552620	1553600	So we're logged in.
1553600	1554240	Cool.
1554760	1555740	Who am I?
1556960	1557860	User's wheel.
1557860	1558440	Cool.
1558660	1560000	Vim, do I have it?
1560000	1561380	I do have it.
1561400	1564800	And then can I run sudo?
1564800	1566020	Power off.
1566880	1568100	Password was demo.
1568240	1569700	Yeah, I can shut it down.
1569840	1579550	Just to show this like super quick, what I'm just going to do is I'm going to add htop to the packages that are going to go on the system.
1579710	1580970	And I'm going to build it again.
1580970	1586710	And you're going to see that this time I'm going to have, I probably should have shown that I didn't have htop on it before, but trust me, I didn't.
1589650	1593390	I'm running again and you'll see that we have that package on the machine now.
1596150	1604010	And this little micro VM is just a super simplification of a bigger NixOS system that has all the stuff on it.
1604010	1607730	So like this system that I'm showing you this on right now has that.
1610470	1611830	Cool, we have it.
1611830	1619110	So yeah, that's, it's really powerful being able to use Nix for a whole system instead of just packages and configurations.
1619110	1624910	And it lets you be really particular about everything that you have on that given system.
1624910	1630390	And it lets you track it all super easily because like you can just go to that configuration file and see what's on the system.
1630390	1633650	There's no ambiguity about what's installed on there or how things are configured.
1635050	1637870	And just as a quick aside, generations.
1637950	1642710	So I noticed somebody said a question about like versioning systems before.
1643070	1645070	And I added that while I was listening.
1645250	1648050	Generations are really cool for the system.
1648050	1660810	If I were, if I had this on a traditional system and I like rebooted my right now, during my boot menu, I have the option to roll back or use a different generation or version of my NixOS configuration.
1661030	1670570	So every time I make a change to my config and I rebuilt my system to it, it's going to add it as a new generation list.
1670670	1680170	And it keeps a backlog of however many you can specify how many you want to keep, how many you want to like delete after a bad config.
1680170	1687570	Like I do something dangerous, like I change variables for my boot loader, like I'm configuring it with Nix and I do something bad and I bork it.
1687650	1688950	And now my system is broken.
1688950	1689890	I don't even boot.
1690350	1690970	It's fine.
1690970	1693410	I'll just roll back the configuration and I'm saved.
1693410	1695610	You don't have to worry about breaking your system anymore.
1695610	1703330	You can go ham and do all the stupid things you want to do and not have to worry about doing the full fresh install all the way from scratch.
1706250	1707850	So, yeah.
1707850	1708350	Thanks.
1708350	1721390	That was kind of like my super crash course about how I went from not really knowing anything about Nix just back in February to now I have all my machines configured declaratively.
1721390	1723570	I get to hack on Nix for work.
1724990	1726510	And, yeah.
1726510	1738410	And I guess at this point, if I have it, I'm just going to kind of flex my repository that I have for my machines and I share it with Britton over there, so I'll show you.
1742920	1743460	So, yeah.
1743460	1744620	This is ours.
1745540	1755500	And the way, without getting too much into it, just to show not everything for a system configuration has to be all condensed into one file, because most people don't actually do that, because it would end up being really huge.
1755500	1757180	They split it out into multiple things.
1757180	1760340	And just at the end, it all gets merged together back into the same place.
1760600	1775320	But the way that I have things set up that I think is really cool for organizations is, and I'm only going to show this part, I think, the way that I have machines, users, and user environments configured across all my machines, all in one place.
1775320	1781420	So, I have all these machines set up on my on our infrastructure.
1781420	1782700	So, like, AlexDev is a machine.
1782980	1785920	AlexFramework, that's this machine, this laptop that I'm using right now.
1785920	1790480	And I put the name for it, the host, the target host for it.
1790480	1791900	And this is using plan, by the way.
1791900	1793200	I should have mentioned that.
1794260	1801760	And I have this tag system set up so that I don't actually have all the configurations all in one big place, like I mentioned.
1801760	1809700	It's actually kind of like a buffet example, where you go to this inventory and you pick out the things that you want for that machine.
1809700	1811500	So, this is a laptop.
1811500	1812980	I want to be on tail net.
1813080	1814680	And this laptop has Hyperlend on it.
1814680	1815600	That's what I want.
1815760	1822760	And if I go and actually look at those tags, like the Hyperlend one, you can see, like, for this, this is the base stuff that I need to do Hyperlend.
1822760	1831840	So, this, because I added this tag to that machine, this is getting pulled into and essentially added to, as far as that machine's concerned, this is part of its configuration.
1832260	1839500	And the next step is, like, HomeManager, which is configuring dot files for yourself.
1840200	1854800	So, like, for instance, I have... this is my ZSH RC set up with HomeManager, which is basically, HomeManager is Nix set up, but for your dot files to manage all of that declaratively as well.
1854800	1860900	And the end result of this, so, I have all this stuff on here, just, I'll show you, like, we have all these aliases and stuff.
1861020	1868940	And what I'll do is, like, this is the generated ZSH RC.
1868940	1871100	This is, like, some robot generated RC.
1871100	1872400	You probably wouldn't want to read this.
1872400	1874680	Like, it's not meant to be super human readable.
1874680	1879740	But you can see, like, it's taking all the stuff that I'm configuring here and it's putting it all in here.
1879740	1882520	Like, all the aliases are here from everywhere.
1882940	1899620	But, yeah, so, the end game, I guess, that I'm getting at with this is, you can be really modular with system configurations and you can manage all your machines from the same place and choose what you want to be on them with these, like, pre-built little,
1899620	1902040	like, nuggets that you can make for it.
1902040	1910200	And it makes spinning up new machines and managing machines and knowing the exact state of all your machines super easy.
1911160	1914500	So, yeah, I think that's about it.
1915340	1916520	Thanks, guys.
