WEBVTT

00:00.000 --> 00:15.200
Good. Wonderful. Okay. So, this is even with a Y. Yeah? Snacker? Yeah, it's actually

00:15.200 --> 00:20.880
pronounced like that. Okay, great. Even Snacker. And he's going to, like, I find, I find the

00:20.880 --> 00:26.040
title of this talk really amazing. The title of this talk is tips and tricks to fix your

00:26.040 --> 00:33.080
nicks, and it's like, so poetic. So, yeah, I was planning to say it one last time to it

00:33.080 --> 00:38.080
for the chemical effect, but yeah. Sorry. No, I'm going to, I'm not going to say anything anymore.

00:38.080 --> 00:47.520
I'm going to leave you the stage. A round of applause, please for Yvonne. And our last talk

00:47.520 --> 00:55.600
for today, go ahead. Yeah. So, hello everyone. And welcome in tips and tricks to fix your nicks.

00:55.600 --> 01:05.840
I say it. So, the truth is, I already gave that talk a couple of months ago in French,

01:05.840 --> 01:13.440
in capital Dileb, in Toulouse, and it was totally semi-improvised. And this is a revised version

01:13.440 --> 01:19.320
of it that was a bit shrink to fit the, the, the Devron schedule, because that's the last

01:19.360 --> 01:28.120
talk of the day. And the motivation behind this talk is, I guess, as true for every technology,

01:28.120 --> 01:34.520
there is stuff that are super obvious for people to use to, to the scene. We're talking

01:34.520 --> 01:44.440
about nicks, that are super cryptic to the newcomers. And in nicks, if you copypaste some

01:44.440 --> 01:48.360
snippet from the official wiki into your configuration, most of the time it works, it

01:48.360 --> 01:54.680
is magic, it's super nice. But sometimes it breaks, and when it breaks, it's terrible. And

01:54.680 --> 02:00.120
I feel that's one of the things where it's true with nicks, that's, there's things that

02:00.120 --> 02:04.680
are obvious for some people that are not for those. So, maybe some of you will not learn

02:04.680 --> 02:10.360
anything new, and maybe some of you will, and that's my hope. And in the end, there are a few links

02:10.360 --> 02:15.320
because it's a bit too short to make a lot of demo. And it's not exhaustive. If you have more

02:15.400 --> 02:20.040
idea, we can discuss, is it always track, or I would try at some point to make that into,

02:20.040 --> 02:28.680
I know a wiki update, a blog post, something like that. Anyway, I'm involved. I urge first

02:28.680 --> 02:34.840
about nicks, I guess, a decade ago, but I really start to use it, like daily driving it,

02:35.880 --> 02:41.720
why it was the pandemic, the last one. Yeah, we were in first them, so that's the best

02:41.800 --> 02:48.760
spot to catch the last cool versus. And anyway, no, nicks is paying my rent every month,

02:50.120 --> 02:58.040
just nicks, so it's a super cool technology. And yeah, what we'll talk about today is

02:58.040 --> 03:03.320
fitting to two different parts that are really the two parts that explain all nicks work,

03:03.320 --> 03:08.920
which is first, you're evaluating a bunch of nicks code to producing the relation file,

03:09.000 --> 03:14.120
and then you're done, you're actually realizing buildings of the derivation

03:14.120 --> 03:20.600
fighting to actual binaries, crypto, whatever it puts. And there's two separated steps,

03:20.600 --> 03:26.920
actually, really present in nicks, in frogs, like licks, in even gicks, all are the same with that.

03:26.920 --> 03:32.360
And depending if your error is happening in the first or second stage of this process,

03:32.360 --> 03:39.720
it's really different experience. So first, the obvious things, the beginning expression,

03:39.720 --> 03:47.160
first part. Yeah, nicks is a really cool language, personally, I like the syntax,

03:47.160 --> 03:51.160
I think it's pretty decent language, there's really weird color case, but it's not the point of

03:51.160 --> 04:00.120
this talk. There is issue with nicks, first, a really dynamic core and language where you can

04:00.200 --> 04:05.480
do a lot of things that will not be possible in more static language, indeed,

04:05.480 --> 04:10.840
and it's functional. And functional language, I have a feature, which I personally find really

04:10.840 --> 04:15.720
cool and that is by default for every function, that is there is partial application,

04:16.600 --> 04:24.440
which means that if you forgot an argument to your function, it would work, it will just

04:24.520 --> 04:29.320
raise a neural way later in your program, in your expression, which is actually bad,

04:29.320 --> 04:35.880
because the stack trace will not show you the place where you made zero, actually, but somewhere

04:35.880 --> 04:45.720
totally different. And six sets, a bit tricky is you to work with, I have, yeah, and so

04:45.720 --> 04:52.760
that what they just say, the stack trace is often bad. My immediate advice for that, advice for that

04:52.920 --> 04:59.080
is if you have the choice to not use several argument for a function, if you're crafting

04:59.080 --> 05:04.200
your nicks piece of code, and you can, rather, make a function that can naturally be set,

05:04.200 --> 05:10.680
rather than several named argument, a positional argument, sorry, to choose that should be set,

05:10.680 --> 05:17.240
at least if you forgot a knitem, you would have a proper error in the right place, use only

05:18.200 --> 05:22.360
a function that takes several argument, which is a function that takes a function, a functional

05:22.360 --> 05:31.800
program, only when you really need it, not just often. And yeah, and I made runtime types,

05:32.600 --> 05:40.200
libraries that catch this problem, and no, that's not, yeah, this is a flying copy of my website.

05:41.160 --> 05:46.280
Yeah, I presented two years ago at first, them, so, not really interesting, but yeah,

05:47.640 --> 05:54.120
self-advertising. A lot of scheme are similar, mechanism built in, so, yeah.

05:55.560 --> 06:00.200
Next thing is, often when you start with nicks, you're like, it's just a configuration language,

06:00.200 --> 06:05.720
so I do not have to really tune my editor, like, it's real programming language,

06:05.800 --> 06:12.040
like that way you should really do that, use a language several protocol, use stuff like

06:12.040 --> 06:18.360
pre-commit, or pre-push, oops, all this kind of things, there's a lot of static analyzer

06:18.360 --> 06:23.480
for nicks, like dead nicks, etc. There really makes your experience way better, because it's

06:23.480 --> 06:31.400
really easy to, I don't know, for good, parenthesis is nicks, and you really have no clue,

06:31.400 --> 06:39.800
and I think a cool editor really helps you, that's abuse, but more saying, and next there is a

06:39.800 --> 06:45.560
really cool REPL in nicks, that's when I start using it to debug my program interactive,

06:45.560 --> 06:52.040
it's really changed my life, and I think everyone should do that, and that will be the point

06:52.040 --> 07:00.040
of the first demo, and the next thing is, when you ask someone of two, or to debug an

07:00.120 --> 07:07.400
nicks script for a while, I mean for more than 20 years, the answer was just traced, which is

07:07.400 --> 07:14.760
a bit bad, and no, it's not that new, but no, we have a debugger, and so I will just demo it,

07:14.760 --> 07:19.960
because I think that's really cool features, that's a lot of people are not where it exists,

07:20.920 --> 07:26.600
and yes, so that's demo time, yeah, so I have two terminal window,

07:28.440 --> 07:33.240
on the top, it's some nicks expression, really simple, or my variable start with a z,

07:33.240 --> 07:39.000
because it will be shown in the end of all variables in my REPL, it's convenient, and I have

07:39.080 --> 07:47.160
the REPL, and there is, I think I can load a nicks expression, it's called nicks REPL,

07:48.520 --> 07:56.200
demo, yeah, I load it, I load only one variable, which is the final variable, the z, zc,

07:57.640 --> 08:04.920
and I can evaluate this value, it's 42, it's super interesting, but no, I can trace

08:05.880 --> 08:12.680
and trace, it's super obvious if you ever used functional programming, and if not, I'm really sorry for you,

08:13.960 --> 08:20.920
within trace takes two argument, of course, the first one is what will be traced, and the second one

08:20.920 --> 08:27.880
will be what built-in trace is written as a value, and so two things could be two different number,

08:28.040 --> 08:36.040
but most of the time, what I do is I do in built-in trace x, and I define x as the

08:36.040 --> 08:43.480
thing, I want both to return and both to evaluate, this is also the only way to do logs,

08:44.280 --> 08:49.480
when you want to do logs, logs up to return value, and you have to ask for this value for the

08:49.480 --> 08:56.200
logs to be printed, I will demonstrate that just in a moment, so I reload my file,

08:58.600 --> 09:07.720
and if I do zc, no, I have a trace, and I was result, but you know, maybe if you're coming from

09:07.720 --> 09:15.160
asker, it's like is there a tank or is there a value that I've been compute, if I re-ask for zc,

09:15.320 --> 09:21.560
I don't have to trace any more, I just have to trace at the time one, I ask for zc, only one tank,

09:21.560 --> 09:26.280
so when you're going to just lazy, it's maybe obvious, it's maybe not, and so early PL is a really

09:26.280 --> 09:34.760
good way to have a good understanding of that, then I want to show off the new things that is called

09:35.160 --> 09:39.960
oops, sorry, the new things that is called, and I have a LSP, it's super convenient,

09:39.960 --> 09:48.120
within Brexit, so I have a breakpoint and I have, yeah, I don't need built in actually,

09:48.120 --> 10:03.240
thank you LSP, so yeah, and if I reload and I do zc, it's just doing new things, maybe I can,

10:03.960 --> 10:10.040
I don't know clothes and relinquish your RAPL, and we try, it's not working, why, because it's

10:10.040 --> 10:17.320
obvious, I have to use the debugger, optional flag, because if you don't use it, the debugger is not

10:17.320 --> 10:23.720
enabled by default, which is great, which is sometimes a bit annoying when your nix command is

10:23.720 --> 10:31.080
called, deep into some strapting or CI, anyway, no, I have a debugger, and if I do, I load my

10:31.160 --> 10:41.560
file, I compute zc, no, I have breakpoint, and if I check, no, I have access to za and b, okay, I've

10:41.560 --> 10:51.080
lost a value, and I have the same thing, first time I have a trace, so if I do continue, I don't know

10:51.080 --> 10:58.920
my command, c, yes, it's continue, I have the result, and no, you see, I add the result, without the

10:58.920 --> 11:05.560
trace, because zd was already compute, so yeah, you get set on this thing, it's really, really,

11:05.560 --> 11:11.960
ended to use RAPL, to use this kind of buildings, to use the debugger, to understand actually,

11:11.960 --> 11:21.080
all an xx% is evaluated, and to not be blind, I really recommend it, and yeah, that was a short

11:21.080 --> 11:27.880
demo about it, and second part is debugging builds, so when your success would be evaluated,

11:27.960 --> 11:32.520
wall nix expression, you produce derivation file, I know your building, there's derivation

11:32.520 --> 11:39.320
file inside the sandbox, those demo are a bit artren without a reliable internet connection,

11:39.320 --> 11:43.240
and I was a bit afraid by it for the internet connection, so it's everything is pre-recorded,

11:44.760 --> 11:51.080
so what is the problem, the problem is this slide is wrong, no, because nix actually is incremental,

11:51.160 --> 11:58.120
there is an atomic measure in nix, which is derivation, if you already build a derivation,

11:58.120 --> 12:04.600
we're not durable exact derivation, so you can make your nix build more incremental by making

12:04.600 --> 12:10.440
more derivation, more derivation, more we're not reviewing everything each time, but inside the

12:10.440 --> 12:16.760
derivation, if you have an issue, you will always rebuild the wall, script inside the derivation,

12:16.840 --> 12:22.360
inside the sandbox from scratch, and that's not interactive at all, if you use to do occur,

12:22.360 --> 12:28.520
you're like, oh, I will spawn a shell in my do occur and just mess everything, you can do that

12:28.520 --> 12:35.160
easily with nix for obvious reason, maybe not so obvious, but yeah, that's something that often

12:35.160 --> 12:44.440
you can also already frustrated with, because your feedback loop is super slow, and also,

12:44.520 --> 12:50.760
then another problem I didn't wrong hit on the slide, but nix is actually when you're running,

12:50.760 --> 12:56.600
building a lot of derivation in parallel, in arbitrary order, so sometimes you have an issue,

12:56.600 --> 13:02.280
you run your command, you don't have the same error message, because it's just fail at another place,

13:02.280 --> 13:08.520
and it will not never, I mean, it's this rigid system, but it don't fail or

13:08.600 --> 13:13.960
really agree when there is more than one thing to fix, and sometimes you really are to see what's

13:14.680 --> 13:19.400
the past between what you're actually trying to do and what's these derivations that are failing,

13:21.800 --> 13:28.760
some of his first advice is to do something else, since default nix would put, which is quite

13:28.760 --> 13:36.040
arbitrary, you have the dash l option, l caps, but anyway nix with monitor is really great,

13:36.200 --> 13:43.640
and there is a modified version of it, that's even used to do things more in parallel, but

13:44.920 --> 13:50.920
it's not the point of his talk, and give you two, I guess, I have some same

13:51.960 --> 14:02.520
next trick, but I will show that later, as Kinima play pre-record nix input monitor,

14:03.400 --> 14:09.720
yeah, so the nix input monitor, it looks like that, you have this kind of

14:11.080 --> 14:18.600
things where you have no more nix l caps, it would put, but you see, at some point it will appear,

14:19.720 --> 14:24.680
some dependency graph where you see what you are actually building, maybe that's not the best example,

14:26.360 --> 14:29.640
it shows some kind of tree when you can see, okay, I'm building this derivation,

14:29.640 --> 14:36.120
because it's in this derivation and starts to, it's really great to, and it's really easy to use,

14:36.120 --> 14:45.800
you just replace nix binomial command 9, please use it, it's not new, but yeah, use that too,

14:47.400 --> 14:56.760
yeah, what's next, it's super easy to inspect the derivation to actually see what's inside,

14:57.160 --> 15:02.280
and it's super nice to understand what's the relationship between two derivations, you have y-dependes,

15:02.280 --> 15:11.240
and you have nix tree for that, sorry, so y-dependent gives you this kind of outputs,

15:11.240 --> 15:23.880
and nix tree too much window, nix tree gives you something like that, yeah, I here, I'm inspecting

15:24.600 --> 15:31.480
the developer shell of my willy-twork, of the environment I used to build this light,

15:32.200 --> 15:40.360
yeah, it's super fast, we are almost there, yeah, and I'm out of time, so just show it

15:40.360 --> 15:46.360
very quickly and then the torque is finished, so yeah, my derivation is to plus more, it's just six

15:46.360 --> 15:53.240
gigabyte to build slides, a pretty reasonable, yeah, I can see, use text live, what's text,

15:53.240 --> 16:00.040
space in text live, and you can see there's maybe stuff you can remove from your derivations,

16:00.040 --> 16:09.240
kind of since, so yeah, blah, blah, blah, blah, and yeah, and yeah, and there's two other things,

16:09.240 --> 16:15.640
I didn't have the time to show, the first one is the nickel, rip on out, and you can basically

16:15.800 --> 16:20.520
go interactively inside your derivation, environment, and test everything, and you can also write

16:20.520 --> 16:26.600
any test for your nix code, yeah, there's two links in the slides, I will be online, this is

16:26.600 --> 16:32.520
this course, I suppose that takes pain off to use, there's also sources of two is big point,

16:32.520 --> 16:38.200
okay, and there's really old, three-block posts, quite old, that takes pain off to write,

16:38.200 --> 16:43.240
you need test for your nix expression, which is something, I don't see a lot of people doing,

16:43.240 --> 16:56.440
but I think it's nice to do, and that's all, thank you, all right, so we are out of time,

16:56.440 --> 17:02.760
so we don't really have time for Q&A anymore, but this was great, great talk, I think it's really

17:02.760 --> 17:07.080
important for people to get to know these tools because it's really hard to get started with nix,

17:07.080 --> 17:13.160
and knowing that stuff really does help, so thank you very much for the talk, thank you very

17:13.480 --> 17:20.600
much for everyone who took part in this in some way, it was a lot of fun, maybe we'll see you

17:20.600 --> 17:27.240
at the Booth tomorrow or something, hopefully people will have good conversations following this,

17:27.240 --> 17:31.720
and have a nice evening, and enjoy the rest of the first, and thank you, bye.

