Latest / Full Time Nix / Nix 2.23.0 release with Jacek Galowicz
Transcript
- 0:03Hello and welcome to Full Time Nix.
- 0:06This is an episode about release notes of Nix 2.23.0 with Jacek Galowicz.
- 0:18Hi, Jacek.
- 0:20Hey, Shahar how are you?
- 0:23Pretty good, pretty good.
- 0:25Well, let's talk about it.
- 0:29Yes, let's go.
- 0:35There are two new features.
- 0:40One is a new built-in.
- 0:43and as all built-ins it can be found under the global scope `builtins` attrset and
- 0:53it's called warn.
- 0:54So it'll be `builtins.warn`.
- 0:57What does it do?
- 1:00Yeah, so when you use `builtins.warn`, it has a very similar semantics to
- 1:06`builtins.trace`.
- 1:07Basically, `builtins.trace` is a function that takes two parameters.
- 1:11The first one is a string that will be printed on the user's shell.
- 1:16It will not go into the program itself.
- 1:19It will not change how your program behaves.
- 1:23and the second parameter to it will be some kind of value that goes from
- 1:27somewhere somewhere else and will just be forwarded while your message is printed on
- 1:32the terminal only visible to the user.
- 1:37Developers use this for deprecation warnings or just printf style debugging or
- 1:43whatever else.
- 1:46Generally, traces don't really do anything and it's
- 1:50relatively difficult for the end user if you are triggering a warning somewhere
- 1:55that is disguised as a trace kind of to find out where it comes from and we kind
- 2:05of lately got this new debugging features in Nix and you can start a debugger on
- 2:12traces but then the problem is if you're
- 2:15.
- 2:17you just want to catch the one specific trace that is a warning about something
- 2:22that you're doing wrong because of deprecation or whatever.
- 2:27Yeah, you get in trouble distinguishing that.
- 2:30So they introduced `builtins.warn`, which is kind of a special trace, which is meant
- 2:36to be only used for actual warnings, warnings that users ought to fix.
- 2:44it is now possible to tell the debugger that it should only trigger not on traces
- 2:49but only on warnings or even abort on warnings.
- 2:53So you could either as a developer say, OK, you activate the option debugger on
- 3:00warn and then your debugger will jump into the code and give you the context as soon
- 3:06as it sees a warning being triggered.
- 3:09You could also in your CI,
- 3:11or whatever else, set your Nix builds with the option `--abort-on-warn` and then it
- 3:19will go red in front of your face when your code triggers a warning.
- 3:23So this is very nice because all the traces could still be in there.
- 3:27They wouldn't produce any noise because you can already distinguish between
- 3:32tracing and warning, right?
- 3:35Also, the warning messages have a little bit of a different
- 3:41route of character.
- 3:44it's easier to grab for warnings or whatever because of their fixed format.
- 3:50So this is in general useful for the debugging mix developer and also for
- 3:55people who simply want to get rid of all warnings for example after an update or
- 4:02similar.
- 4:04That is great.
- 4:04Sorry, what is output character?
- 4:09Mean.
- 4:09I mean, not output character as a character, but the general character of
- 4:14the outputs being printed.
- 4:18Before that, you had `builtins.trace` with maybe a warning prefix, maybe not.
- 4:24So there was no real guarantee that all the warning output that comes from faces
- 4:32being used would look similar.
- 4:35There was no guarantee, right?
- 4:36Now...
- 4:37with `builtins.warn` being a built-in primitive, they will have exactly the same
- 4:45output formatting.
- 4:47So you will have a nicer time simply distinguishing that.
- 5:26from.
- 5:28This feature certainly makes it even easier because you don't get false
- 5:33positives.
- 5:34Everything that is not a warning is not being triggered any longer as long as
- 5:38developers use this warn feature.
- 5:53I asked for this on this course.
- 5:57nice.
- 6:06Anyway, thank you, who did this?
- 6:17Robert H.
- 6:21Hensing.
- 6:23Thank you Robert.
- 6:28new command nix env shell as the new nix shell so what is a nix space shell what is
- 6:41that the existing command
- 6:45generally want to start a new shell with specific packages installed, you could
- 6:52write like, Nix space, shell space, and then nixpkgs, hashtag, some package name.
- 7:00Then you would be launched into a new shell that seems like this package is
- 7:05installed there.
- 7:06And when you exit that shell, it's gone again.
- 7:08It's one of the very nice killer features of Nix, right?
- 7:12I mean, people who don't use Nix, they do Docker run something, something, and then
- 7:19they simply start Docker images where one or multiple tools are installed in.
- 7:24If you want to customize that, you have to write your own Docker image.
- 7:30And that is not really composable.
- 7:32You cannot combine two Docker images easily that have all the tools that you
- 7:36like.
- 7:37With the Nix shell, this is different.
- 7:39You simply line up all the...
- 7:41packages that you would like to have in your shell.
- 7:44Launch the command.
- 7:45Boom, you're in a shell now that has all these packages installed, right?
- 7:50Also, not to underestimate that or not to forget, Nix.
- 7:56I mean, you could do this from any Linux distro, right?
- 7:59Many people are on Fedora or Ubuntu or whatever.
- 8:01Maybe they don't have this package, but Nix gives you access to the biggest and
- 8:06freshest open source package repository in the world, right?
- 8:09This is two features at the same time.
- 8:11One is these ephemeral shells.
- 8:15You go into this shell, have this package, you exit the shell and it's gone again,
- 8:19right?
- 8:19At least it looks like this.
- 8:21And access to this huge package collection, right?
- 8:25So that is what nix shell generally does.
- 8:29And it's not only for ad hoc invocations,
- 8:43Right?
- 8:45Generally, when we look at the old commands, nix-shell, not nix -space
- 8:52-shell, but nix-shell, it was kind of meant to be used in two different
- 8:56scenarios.
- 8:57One is with the list of packages on the command line, so you get an ad hoc shell
- 9:02that you just define on the command line.
- 9:05The other was to source a shell.nix file or similar.
- 9:11where someone already prepared all the projects packages that you want to work
- 9:15on, then you wouldn't have any other command -line parameters.
- 9:20With Flakes, this developed a little bit in a different direction.
- 9:24So we have two different commands for doing these two things.
- 9:28One is for an ad hoc shell, where you simply line up all the package names on
- 9:33the command line, you use `nix shell` for that.
- 9:37If you want to start a development environment from a Flake project, you
- 9:41would go with the next develop command.
- 9:46So, Nix Develop will look into the Dev Shells section of your Flake and without
- 9:53any parameters, select the default one.
- 9:56Otherwise, you could also select a specific one on the command line so that
- 10:00you can have different developer environments per project if that is
- 10:04useful.
- 10:05And then it would simply launch that.
- 10:07And that's two separate commands now, right?
- 10:12Correct, I wonder why it was renamed, but I also, right, but there is a Nix, so
- 10:20there's the old Nix hyphen shell command, which does not work with Flakes, and it
- 10:28works with ad hoc invocations, and otherwise it looks for, by default, a
- 10:33shell.nix, but it can be arbitrary file.
- 10:38And with Flakes or,
- 10:42Flakes and nix-command experimental features.
- 10:45There is Nix space shell, which is only equivalent to the Nix hyphen shell ad hoc
- 10:59invocation.
- 11:01Accepted.
- 11:03The equivalent to the shell.nix usage of the classic nix-shell is nix develop.
- 11:16Yeah, so when you look at how `nix-shell`'s feature with ad -hoc shells
- 11:24was implemented, I mean, you use the nix-shell command and then dash p and then
- 11:30list of packages.
- 11:31It would kind of take all your package names, put them into a bigger Nix
- 11:35expression and launch that as it's kind of ad -hoc Nix shell or shell.nix.
- 11:40So it would kind of create one on the fly and then simulate this behavior.
- 11:46The problem was there that it selects the nixpkgs for you where the packages come
- 11:56from.
- 11:57You could not really easily change that without tampering with environment
- 12:02variables.
- 12:04And the new Nix shell, Nix space shell, it waits for Flake input and then the package
- 12:13input from the Flake.
- 12:14You write Nix shell.
- 12:17nixpkgs, hashtag, some package name.
- 12:20And then this command line defines not only the package that you want, but also
- 12:25the policy decision, where should this package come from?
- 12:28So you could mix up different nixpkgs commits on the command line.
- 12:33You want package A in very new and package B in very old.
- 12:37Or you could simply access completely
- 12:41different third -party flakes.
- 12:43So you have some hobby repository somewhere and tell someone, hey, you can
- 12:46simply run my package from the command line without cloning my flake.
- 12:51So you would write nix shell github colon shahar slash saharsproject hashtag
- 13:00shahar's package name.
- 13:02And boom, that's it, right?
- 13:03So the old nix shell command couldn't do this.
- 13:08Or not without a lot of hassle.
- 13:11It was trying to do this wouldn't be a nice user experience with the old command.
- 13:16And with the new command, it's really easy, right?
- 13:19So it's more powerful, actually, much more powerful.
- 13:26Yes.
- 13:27And what is this `nix env shell`?
- 13:32Is it supposed to replace nix space shell?
- 13:36So it's nix space env space shell.
- 13:41Exactly.
- 13:41So if you look at this alone in isolation, it looks like a completely random rename,
- 13:48but that's not what it is.
- 13:50There's a concept behind that.
- 13:52And the whole idea is that we have so many different Nix commands, right?
- 13:57Nix shell this, sorry, Nix space this, Nix space that.
- 14:02The developers tried to make it more intuitive by...
- 14:08giving these subcommands a common scheme where you know, okay, I want to do
- 14:13something with development environments.
- 14:16So there are multiple Nix, space, dev, space, something commands, or I want to do
- 14:21something with package installations or building or running.
- 14:25Then there's a Nix space, package space, something, something subcategory.
- 14:31So they are kind of subdividing the commands which kind of randomly piled up
- 14:37over the years.
- 14:38into new categories that make more sense because they're more coherent.
- 14:42So for example, there will be `nix dev shell` and `nix dev run` and `nix dev
- 14:52print-env`.
- 14:53So these things all have to do something with development shells that are from a
- 14:59flake.
- 15:02But you can also run `nix env shell` in contrast to `nix dev shell`.
- 15:10That's better
- 15:12shell` will be kind of ad hoc shells.
- 15:15Everything with `nix env` will be something like an ad hoc thingy.
- 15:19Everything with `nix dev` will be something with prepared development
- 15:22environments from Flakes, right?
- 15:24So this totally makes sense.
- 15:27And the other commands will be like NixPackageBuild, NixPackageRun,
- 15:31NixPackageInfo, NixPackageEdit.
- 15:35And that will be something that will be like per package do something with one
- 15:39specific package.
- 15:41And yeah, so they're kind of there's a lot of discussion going on.
- 15:45So I went through all the GitHub issues where they were discussing how stuff
- 15:50should be named.
- 15:51Of course, naming is one of the hard problems in IT.
- 15:56People put like five people in a room to discuss how something should be named and
- 16:02you get 10 different opinions out of it.
- 16:05So I think we will.
- 16:09have more discussion about that in the GitHub issues and forums, how this should
- 16:13be.
- 16:13Some people will like it, some people won't, but in general, I'm looking forward
- 16:17to this improved structure, right?
- 16:27Yes, it sounds right.
- 16:30It sounds right to me and I also trust that the intelligent beings who tend to
- 16:39this project are making reasonable decisions.
- 16:47Alright, so that's a small and yet part of a greater improvement change.
- 16:55absolutely.
- 16:56So one other note.
- 16:58They will not remove the `nix shell` command because of `nix env shell`.
- 17:03So both will coexist for a while, I guess.
- 17:07So this is not a breaking change where everyone who updates to Nix 23.0 will have
- 17:15to rewrite all their commands.
- 17:17That is not the case.
- 17:20They are simply added at this point.
- 17:26and I hope that it will eventually be removed because this is the time to do
- 17:32this all of these are supposed to be experimental it's just that we're we took
- 17:41our time
- 17:42Yeah, of course.
- 17:43But I mean, commands like nix develop, nix shell, nix build with the spaces in
- 17:48between and not the dashes.
- 17:51Yeah, so many people use it already.
- 17:53And of course, this is officially experimental, but it's experimental for so
- 17:59long already that people ignore that.
- 18:02So our experimental semantics are not really not equally useful everywhere right
- 18:09now.
- 18:11Mm -hmm.
- 18:12It totally makes sense that they are not deprecating the nix shell, nix develop,
- 18:17nix build and nix run commands too quickly.
- 18:21But eventually you are right, eventually the whole interface will look chaotic and
- 18:27noisy if you keep all of this, right?
- 18:32Yeah, I'll leave it up to the Nix team.
- 18:38Absolutely.
- 18:39Yeah, they will figure it out and do it well.
- 18:46So there are some more improvements.
- 18:48One is to the consistency.
- 18:55It's about making a nix build with the keep going flag consistent with the
- 19:03nix-build with the keep going flag.
- 19:08How is it not consistent?
- 19:11So first, the use case for the keep going flag is usually when you're building
- 19:19something on your laptop and that rebuilds many, many different derivations at the
- 19:25same time.
- 19:26For example, if you updated your inputs and then rebuilt, of course, everything is
- 19:31going to be rebuilt usually.
- 19:33And then without the keep going flag, the whole build will simply abort on the first
- 19:39error.
- 19:41Mm -hmm.
- 19:41And maybe there are 10 errors and you want different packages and you want to see
- 19:46them all.
- 19:48Typically what's also the case when you are, let's say you have like two packages
- 19:52building at the same time and one builds for an hour and will be completely fine.
- 20:00And the other one builds for like 10 minutes until it breaks.
- 20:06And without keep going the
- 20:09whole build will break after 10 minutes after the first error, while the other
- 20:13package, which you could simply let continue, is aborted too.
- 20:18So on the next nix build, the longer package build will be completely
- 20:23restarted, and that might not be necessary.
- 20:27So if you run Nix build with the keep going parameter, it will simply print all
- 20:32the errors that it finds on the way, so you can on your other screen start to
- 20:37fix problems and bugs and at the same time all the builds that are completely fine
- 20:43will continue to build, right?
- 20:44So you're kind of not wasting time.
- 20:48While you're waiting anyway, you can fix the bugs of the builds that don't work,
- 20:52right?
- 20:52So that's very useful of a feature.
- 20:55Typically, I don't enable it in CIs because I want CIs to get red pretty
- 21:00quickly and then abort so they have the resources for other builds that are not
- 21:04going red.
- 21:05while at home while debugging stuff, I'm using the keep going flag to just keep the
- 21:11builds that work building while I fix the problems, right?
- 21:15But now it was like this feature existed in old times already with the old
- 21:19`nix-build` command and with the new `nix build` command, they still have it, but
- 21:26they are slightly, slightly different.
- 21:28So for example, if you have like a...
- 21:34output derivations that fail to build.
- 21:38Nix is basically comparing hashes and hash mismatches are displayed in terms of the
- 21:45error message.
- 21:47And maybe you have like three, four, five different hash mismatches that you want to
- 21:52fix quickly.
- 21:55But then you can't because it's already aborting after the first one.
- 21:59So the...
- 22:02old `nix-build` command showed you all of them, the new one didn't and now this is
- 22:08fixed so this will be as useful as the old one.
- 22:16Sorry, so what was the difference?
- 22:19There was a difference in what it keeps going and what it fails on with regards to
- 22:26this particular hash mismatch?
- 22:30In case of hash mismatches, there were cases where not all of them are displayed
- 22:34that were found.
- 22:36It's only with regards to what is displayed, you say.
- 22:43Yeah, kind of.
- 22:46In general, the whole idea of keep going is simply print all the errors that you
- 22:54see, but also keep going with everything else.
- 22:57And this promise of really keep going during a build was, so to say, not
- 23:04completely followed by the new nix build command.
- 23:08So sometimes it was the case that you run nix space build keep going, then it
- 23:12displays you some kind of hash mismatch.
- 23:15And then, okay, then you fix it.
- 23:17Then you run it again, and then it will come up with a new hash mismatch that
- 23:21could have been shown on the first run already, but didn't.
- 23:24Of course, that's irritating, that's stupid, but now they fixed that.
- 23:30so some things were...
- 23:37triggering a complete failure short -circuiting everything in spite of the
- 23:46flag keep going and now it's fixed now they will not cause the whole build to
- 23:53fail it will keep going
- 23:55say keep going now, like really keep going.
- 23:59The promise wasn't met completely right now it is.
- 24:03And it's kind of, it's not forgetting to print all of the errors that I've seen.
- 24:11There were simply corner cases in which this was the case and some cases in which
- 24:15it wasn't.
- 24:17I didn't really experience this myself, so I'm just reading from the issue
- 24:25description on GitHub and the pull requests what was the case.
- 24:28And it really seems like there were simply a few special cases, like with fixed
- 24:34output derivations, where it didn't keep up the promise.
- 24:41It's good to know.
- 24:47I mean, if you don't know, then you can already forget.
- 24:52Because it's now in parity now, right?
- 24:57I just would like to thank the author of this fix.
- 25:04And so whoever you are, thank you.
- 26:00Okay, by the way with this feature flag keep going, this keep going flag, errors
- 26:11are being printed, there is no summary, right?
- 26:15It's not like you get a summary of errors at the end, right?
- 26:20Yeah, that's true.
- 26:21I mean you get a summary of all the, I mean a list of packages that failed
- 26:26obviously.
- 26:29And for each of them you can run the show log command and then it will give you the
- 26:36whole log of this specific package built in isolation, which is very useful because
- 26:41typically they are just mixed on the terminal, right?
- 26:45But if you really want to understand a more complex error
- 26:49then you want to see the package build log in isolation which you always could.
- 26:55It's just another command.
- 26:57okay great JSON format update modify `nix derivation add` and `show` `nix derivation
- 27:09add`, `nix derivation show` JSON format.
- 27:13What is `nix derivation add` and `nix derivation show`?
- 27:19So, `nix derivation show` is a command which allows you to get a more human
- 27:28readable form of a Nix Derivation, right?
- 27:31When you evaluate a Nix expression, it will kind of, yeah, interpret your Nix
- 27:37script and create a data structure.
- 27:41This data structure is called a Derivation.
- 27:44And when you build a package, this Derivation is actually
- 27:49the thing that is being built, right?
- 27:51Your Nix expression is full of variables and whatever, you can update the nixpkgs
- 27:55inputs and whatnot, but the derivation is completely fixed, completely static,
- 28:00contains no variables any longer whatsoever.
- 28:05All the Nix paths are set there.
- 28:07And this is the format that kind of doesn't know about the Nix language any
- 28:13longer.
- 28:14It's just the pure static data structure.
- 28:16And this data structure can be sent to other remote builders, for example, and
- 28:21they will be able to build stuff.
- 28:24So you could, in theory, even create different programming, use different
- 28:32programming languages to create a derivation structure, right?
- 28:35You wouldn't completely have to use Nix.
- 28:37So this is a useful abstraction layer.
- 28:43Now the question is in what format are these derivations defined?
- 28:48How to read them, how to create them and so on, right?
- 28:52And below the code, when you look at the derivation file, it is implemented in so
- 29:00-called ATerm format.
- 29:01ATerm is a very old serialization format.
- 29:06It is halfway human readable.
- 29:09So it's not really binary, it's ASCII.
- 29:13But nowadays people use JSON to describe all kinds of data structures because
- 29:19that's a very nice language agnostic thing.
- 29:22All the programming languages have JSON serialization and deserialization
- 29:25libraries and so on.
- 29:26So the `nix derivation show` command gives you a very nice JSON object from a
- 29:33derivation.
- 29:35The thing is that this
- 29:37feature has been used in the past by humans to simply read format and search
- 29:43derivation structures.
- 29:45So it was fine if this was not completely valid JSON.
- 29:51But they are going to change this.
- 29:53So they want to have it like real JSON by following the spec.
- 29:59And in this case, what they did is they revised the output
- 30:07to better conform their own JSON guidelines.
- 30:11For example, when you have content address derivations, the content address
- 30:19derivations specify the output hash that comes there and the used hash algorithm
- 30:27and also the kind of serialization that they did.
- 30:32So that's very much content addressable.
- 30:36storage details here.
- 30:39The thing is that they had like their own format of describing a content addressable
- 30:44derivation and they're kind of pulling this apart to be more composed.
- 30:51In the past they put multiple different kinds of information into the same string
- 30:56and separated them by columns and now they are trying to make this individual JSON
- 31:01fields.
- 31:02So it becomes easier to programmatically
- 31:05do something with the derivation files.
- 31:08This is a pretty much deep below the hood change.
- 31:14So normal users who don't really play around with derivation files will not
- 31:19notice this.
- 31:21But it will enable tooling that reads derivation files to do something else with
- 31:28that to have easier implementations because of this improved format, right?
- 31:37Sounds like it.
- 31:40So thank you.
- 31:47John Ericson.
- 31:52for this change.
- 31:55Warnings, warn on unknown settings anywhere in the command line.
- 32:06Right, so this is extremely useful.
- 32:12With Flakes this is not really relevant because Flakes don't really take command
- 32:18line like options on the command line.
- 32:21Flakes are so hermetic that you cannot really change the output by something on
- 32:27the command line.
- 32:28But this is relevant for the old non -flakes commands.
- 32:32So for example when you run nix-build or nix-instantiate on something
- 32:41on a Nix expression that takes a parameter on the top level, you could provide this
- 32:48parameter on the command line, like a flag, a string, or whatever.
- 32:54And you could simply run nix-build and then your Nix expression file, and then
- 33:00`--option`, and parameter name and parameter value, right?
- 33:06And it would simply inject that into your Nix script.
- 33:09and then evaluate it and that's a very useful feature in general that kind of got
- 33:14lost with Flakes.
- 33:15I hope Flakes will have this in the future too.
- 33:19However, if your option has a typo in it, Nix would simply do nothing with that,
- 33:30right?
- 33:31So it's like with JavaScript or similar stuff when you have a typo in a variable
- 33:35name, it will simply invent a new one.
- 33:38and you have like undefined values and so on.
- 33:41And with this change, Nix actually warns you.
- 33:44So it sees, sorry, I only have parameters A and B and C.
- 33:49And the one that you provided is unknown to this set.
- 33:53So this is an error now.
- 33:55And this way you will never ever struggle any longer with expressions that for some
- 34:01magic reasons don't work while you for hours just had a typo somewhere and didn't
- 34:06notice it.
- 34:10nice i guess Cole had such an incident enough something to make this PR so thank
- 34:22you Cole Helbling for fixing this for us.
- 34:39Hehehehe
- 34:44What does that mean?
- 34:45Right, so for example in flakes, flakes have a very specific format, right?
- 34:53You have output categories like packages, devShells, nixosConfigurations,
- 34:58nixosModules, overlays, blah blah blah.
- 35:02That list will get longer over time, I guess.
- 35:06However, for example, if you run...
- 35:11yeah, so schema will make them even user -definable.
- 35:14So the list will grow longer.
- 35:17However, for example, let's stay on the basic case when you run nix build
- 35:21myPackageName.
- 35:25And your package is on the nix level, not really a derivation.
- 35:31Then, yeah, it won't work.
- 35:33Nix will tell you, sorry, this is not a derivation.
- 35:37And if you ask, OK, what is it else?
- 35:42Because you're
- 35:43Of course, you didn't do this on purpose.
- 35:45It's kind of a mistake, right?
- 35:47Then it wasn't really easy to find out what it was.
- 35:50Maybe you are like pointing at an attribute set and forgot to add the sub
- 35:57attribute or something like this.
- 35:59Then nix won't really tell you.
- 36:01Even if you open your flake in the REPL just to browse on the command line to your
- 36:07package path, then it will tell you, sorry, this is not a derivation.
- 36:10And you're like, okay.
- 36:12How the hell am I supposed to debug this now?
- 36:15Well, you have to put it outside of the packages into some undefined, unspecified,
- 36:24and then it'll tell you.
- 36:25Of course, that's an idea.
- 36:29However, even without doing that, the flake command will now print you that this
- 36:38is not a derivation, but it will also print you what it found otherwise.
- 36:44So you will see, this is not a path, but for example, a set or a list or whatever.
- 36:50And then you will most probably recognize what you did wrong when you see this
- 36:55output.
- 36:55So this is another improvement that will make the next programmer's life easier.
- 37:02Mm -hmm.
- 37:05That's very nice.
- 39:30So thank you to whomever fixed this quality of life improvement.
- 39:39Thank you.
- 39:42fetchTree now fetches git repositories shallowly by default.
- 39:51I'm not familiar with fetchTree.
- 39:53What is fetchTree?
- 39:56Yeah, so fetchTree basically is able to clone Git repositories.
- 40:03The thing is that Git repositories can be regarded as a tree of Git repositories
- 40:12again, but then also as a tree of commits.
- 40:14So this deep or shallow cloning of Git repositories can have two different
- 40:20meanings on two different axes.
- 40:23Mm -hmm.
- 40:23is, if you check out a Git repository that, for example, has sub -modules, then
- 40:28you maybe want to check out the sub -modules too.
- 40:31So this is a yes -no decision.
- 40:35And that's useful in different scenarios.
- 40:38The other thing is, when you check out a Git repository, you may want to check it
- 40:44out with all its branches and all its history, which is typically the case when
- 40:48you Git clone something, like without Nix even.
- 40:50If you just use Git.
- 40:52And do `git clone `, it will download the whole history.
- 40:55For example, on nixpkgs, this takes a very long time because it's such a huge
- 41:00repository.
- 41:01Same with the Linux kernel, for example.
- 41:05And the thing is, you can tell Nix to please check out all the sub -modules, yes
- 41:11or no.
- 41:13But you weren't really able to tell Nix or...
- 41:17it was was wasn't told by default to check out the whole history yes or not it was
- 41:22checking out the whole history so typically all the nix nixpkgs and so on
- 41:30which reference some github repository they wouldn't even use the git protocol
- 41:38but download via HTTPS
- 41:42And GitHub has this nice feature that when you provide a certain URL to a repository
- 41:48and a commit, it will give you a tarball which doesn't even contain all the Git
- 41:54information any longer.
- 41:55So they basically used this GitHub feature as an easy way to have a shallow clone of
- 42:02just the latest commit of a Git repository.
- 42:05And the whole idea of
- 42:08this change in fetchTree is now that you basically get the same very quick checkout
- 42:13of just the latest commit with Git by default, which will accelerate many
- 42:22derivations that already reference Git repositories because all the history that
- 42:31happened before the latest commit is most of the time not relevant to the build,
- 42:36right?
- 42:40That's correct.
- 42:45for this podcast, FullTimeNix for a different format episode.
- 42:58In fact, it's very similar.
- 43:00It's news, but it's news for nixpkgs instead of Nix.
- 43:08We have been working on a program that will generate the script, or at least a
- 43:18list of packages that are new since last week in nixpkgs and their descriptions and
- 43:25their maintainers.
- 43:30And for that, we want indeed to, well, we want to test the, both in testing and in
- 43:38implementation, we want to clone nixpkgs.
- 43:48and we don't want to clone the entire history.
- 43:53But also we don't want only a depth of one latest commit.
- 43:59We want a depth that is possibly by date because we know the date, but that would
- 44:08have to kind of be resolved.
- 44:10You just can't know that.
- 44:12It's not exposed.
- 44:13You have to get the commits and then examine them.
- 44:17But details aside, we would need an arbitrary
- 44:23depth.
- 45:04So it's just that this little change in the default can have a huge impact on the
- 45:09checkout performance of your repositories or your Nix builds.
- 45:14But it's actually not really a revolution going on.
- 45:19Yes.
- 45:20And my point is only adjacent and not really related, but I thought it would be
- 45:28interesting.
- 45:30So thank you.
- 45:33David Hauer
- 45:36David Hauer for optimizing this for us.
- 45:46should save AWS a lot of money.
- 45:50Mm -hmm.
- 45:58Store Object Info JSON Format now uses null rather than omitting fields.
- 46:09Yeah, so this is a general thing in JSON parsing or deserializing JSON into your
- 46:17data structures.
- 46:19Generally, when you have some kind of optional field that is set, yes or no, for
- 46:24example, I don't know, some extra information in your JSON object, there are
- 46:29two ways to provide this when there is no information.
- 46:33So if you have some field that is called, for example, extraField,
- 46:36and it contains a string.
- 46:39You can either, when you don't have this information and you create a JSON object,
- 46:43say extraField, colon, null.
- 46:46Then you say, okay, this field has no content.
- 46:50Or you simply don't provide the extra fields.
- 46:55So that's from, if your JSON structure generally has like 10 fields, you leave
- 47:01one of them empty, then you have just nine fields and you don't provide this field at
- 47:06all.
- 47:07This is an annoyance for the programmer who is going to deserialize your JSON.
- 47:14Because the question is, when this extra field is not there, is this an error
- 47:19because someone provided a different kind of JSON object?
- 47:23Or would you just say, okay, because this field is optional, we ignore the missing
- 47:30existence of this field?
- 47:32And the next team decided that wherever they create JSON objects, every field that
- 47:40has no value will exist as a field and its value will be null.
- 47:48This is not a huge change, but it will make all the code that will later
- 47:53deserialize JSON again simpler to deal with because you can assume that all the
- 47:59fields will be there.
- 48:00It's just that their value will be distinguished if it's usefully set or not.
- 48:08So this is something that the users will not really find relevant most of the time,
- 48:13but everyone who is programmatically involved with dealing with JSON objects
- 48:18from Nix tooling, they will experience a quality of life improvement.
- 48:28This PR is by John Ericson.
- 48:30Thank you, John Ericson
- 48:36And the last one is large path warnings.
- 48:40Introduce warnings for large paths.
- 48:43What are large paths?
- 48:54Yeah, so generally this feature is also useful, especially for beginners.
- 48:59For example, something that I experience a lot when I'm helping organizations to
- 49:06adopt Nix is that many people will try to Nixify huge projects and then many
- 49:12projects are, I don't know, I mean, one gigabyte of source code is something that
- 49:18happens in real life.
- 49:20And then, of course, in 1 gigabyte of source code, you will have multiple
- 49:24packages that simply live in the same repository.
- 49:29And then when you want to build these packages, what happens very often is
- 49:33people use the src attribute and make derivation and just put in huge folders
- 49:40that contain much, much more than the actual package source code.
- 49:47Imagine you have a Nix package whose source attribute points to 1GB source
- 49:53folder and you change the readme for example.
- 49:58Then you have one gigabyte of changed source folder.
- 50:01And if you rebuild this Nix derivation, it will copy the whole one gigabyte of source
- 50:07code into your Nix store again and rebuild it all due to relevant or irrelevant
- 50:14changes.
- 50:15So this is generally a code smell in projects where the answer is better
- 50:21project structure with subfolders and or source filtering.
- 50:27But generally, what you see as a user is your builds are extremely slow.
- 50:34And then the question is, why are they so slow?
- 50:36Even without knowing the project structure, you want to know why they are
- 50:39so slow.
- 50:41And what you can do now is there's a new option.
- 50:44It's called `--warn-large-path-threshold`.
- 50:50And it takes one parameter, the size of the...
- 50:53megabytes to warn after and if you say for example warn large path threshold 100m, it
- 51:01Nix will warn you whenever it copies more than 100 megabytes of folder content into
- 51:08the Nix store and then you can see I didn't intend to copy so much.
- 51:13Thank you for this warning line right now and then you will see which derivation
- 51:19copies so much stuff into the store.
- 51:22So this is
- 51:23Imagine for example you have a repository with, I don't know, for example a video
- 51:28folder with 10 gigabytes of videos and somehow you are accidentally copying this
- 51:34all to the store, right?
- 51:35There was...
- 51:37You could look into your nix store paths if they contain stuff that you wouldn't
- 51:42suspect to be useful but that would be very laborious and with this new warning
- 51:47it will become very easy to check if you are accidentally copying too much stuff,
- 51:52right?
- 51:54Yes, is there a default for this or is it off?
- 52:00It's off by default.
- 52:02Hmm.
- 52:03I mean, if you really intend to copy so much stuff into the nix store, then it's
- 52:08perfectly fine to do that, right?
- 52:12Rarely.
- 52:14Rarely is.
- 52:15but legitimate and it's completely thinkable that this is legitimate in
- 52:21specific cases, right?
- 52:23Most of the time, of course, it's not and now it's I mean, it's easy to simply add
- 52:28this warning flag, get a few warnings printed and then you tell people like look
- 52:34We are not filtering in this package now is copying 500 megabytes of source code
- 52:39into the nix store and after 10 rebuilds with
- 52:44little irrelevant changes you have five gigabytes of wasted space on your disk and
- 52:51that's unnecessary let's fix that right so it's easier to find out which is the
- 52:58package that actually does that
- 53:01I kind of am like fantasizing at the moment that Nix would...
- 53:13read somehow read all the files
- 53:22and try to somehow intelligently figure out that they're all source code or maybe
- 53:34otherwise tiny.
- 53:41To help with preventing this, I know that we're supposed to be engineers and we're
- 53:49supposed to be careful about this.
- 53:51But...
- 53:54Sometimes you don't even know what exactly you have in your tree because projects are
- 54:00so big.
- 54:01Mm.
- 54:03Maybe there are assets hidden where you didn't know that they are.
- 54:09Maybe Nix can help you and say, you know what?
- 54:14I noticed you have videos in your source.
- 54:23and warn you for that.
- 54:25So that would be a warning by file type instead.
- 54:29That would be most probably very useful to many, but I'm not sure if this is the
- 54:34right layer to do this.
- 54:35I mean, if you are not filtering your source code at all, Nix will simply take
- 54:43it all and use it.
- 54:44And if you would add intelligence to Nix, that actually looks through the whole
- 54:49folder to inspect content of each file.
- 54:52This could be extremely slow then, because this would be a very file system
- 54:58intensive.
- 54:58workload.
- 55:01Of course, you could have extra tooling that simply evaluates all your Nix
- 55:05expressions and then goes through the list of derivations which lists up all the
- 55:10paths that they're going to use.
- 55:13And then it could kind of scan these paths and see what they contain and then warn
- 55:22you in specific cases.
- 55:24But I guess even this
- 55:26I mean, you would need some kind of heuristic, right?
- 55:28Because if you are not the build system which actually uses this, it will be hard
- 55:34to distinguish what will be useful and what not.
- 55:37Of course, the build system could tell you, hey, look, I used the following 100
- 55:42files and the rest of the 1 ,000 files in this repository hasn't been touched by
- 55:47anyone.
- 55:48But that would also not be trivial.
- 55:50You would have to kind of trace every processes.
- 55:55file system operations to see what's actually used.
- 55:59So something like this exists, but this is very invasive tooling.
- 56:05I think it's a...
- 56:07Okay.
- 56:08track, read the whole tree after the build is done and say, well, because file
- 56:17systems can keep track of what file has been read, when's the last time it's been
- 56:23read.
- 56:25I see.
- 56:26Yeah.
- 56:26Okay.
- 56:26True.
- 56:28However, just because something hasn't really been used already, the question is,
- 56:34if you change some kind of build flag, will the file then be used or not?
- 56:43So this is something that is, they're like, from the outside domain, what the
- 56:50build system does with which file could look like completely random.
- 56:55And then the question is, if the tooling has too many false positives, then it will
- 57:02be annoying to use, right?
- 57:06And then all the nice ideas and intentions don't lead to a nice user experience,
- 57:11while maybe potentially making all the builds slower, right?
- 57:15So that's not too easy to solve.
- 57:21Yes, so this PR adds a simple tool that we can explicitly choose to use and this is
- 57:35by Elco Dolstra.
- 57:37Thank you, Elco.
- 57:41Yeah, this is nice and easy to use, right?
- 57:42You can say, OK, 6 megabytes are too much, 600 megabytes are too much, 6 gigabytes
- 57:49are too much.
- 57:52For example, when you work with VirtualBox, VirtualBox has a huge source
- 57:56code folder.
- 57:58And the build system doesn't make it easy to just build portions of that.
- 58:04So you typically end up building the whole thing.
- 58:08And it simply has huge source closures that you're going to live with.
- 58:15With other projects, you could define completely different thresholds.
- 58:20And you as the developer typically know what threshold you want to use on which
- 58:25project.
- 58:25And that's simply easy to do.
- 58:29So they are only providing the mechanics of warning after a specific threshold.
- 58:35But this policy has to be defined by you ad hoc on each project, which is
- 58:41completely fine, right?
- 58:46Yeah, well, Nix is very useful and there are always ways to make it more useful and
- 58:52more pleasant to use.
- 58:57Right.
- 59:03That's all, isn't it?
- 59:05Yes, that's all.
- 59:10So I'd like to thank all the Nix developers and you, Jacek, for sharing
- 59:20these updates and explaining them to us.
- 59:24And I'm looking forward to the next Nix release.
- 59:30Yes, thank you for having me.
- 59:32It was a pleasure again.
- 59:35Be well, Jacek.
- 59:36Everyone, thank you for listening.
- 59:38Have a nice day.