WEBVTT

00:00.000 --> 00:10.960
So we're going to really start now this time about Opam's Nick system dependency mechanism.

00:10.960 --> 00:12.440
Ryan, give us going to talk about that.

00:12.440 --> 00:18.960
We already saw a talk by Ryan, and we're curious to see this one, so go ahead, Ryan.

00:18.960 --> 00:21.200
Thank you very much, everyone.

00:21.200 --> 00:26.360
So I'm going to give you a quick talk on Opam's Nick system dependency mechanism.

00:26.360 --> 00:31.680
So if you don't know Opam is the Oklahoma language package manager, and as with many other

00:31.680 --> 00:36.440
languages, you can use Oklahoma packages from Nick's packages or specialized overlay,

00:36.440 --> 00:41.000
but sometimes the packages or package versions you might need might not be included in

00:41.000 --> 00:43.720
that repository or overlay.

00:43.720 --> 00:47.480
You can use a project like Twigs or PAM Nick's to programatically generate Nick's

00:47.480 --> 00:53.560
derivations from an Opam solve for your project and its dependencies.

00:53.560 --> 00:59.360
This is great for deploying a project developed with Opam to a Nick's our system, but it isn't

00:59.360 --> 01:02.120
a great experience for development.

01:02.120 --> 01:06.280
It's quite slow and you need to do an expensive Nick's rebuild every time a dependency

01:06.280 --> 01:10.120
is added or updated.

01:10.120 --> 01:12.160
Can we just use Opam on Nick's systems?

01:12.160 --> 01:17.560
Well, yes, for Oklahoma dependencies, but not trivially for non-Ochemical dependencies.

01:17.560 --> 01:22.680
If you depend on, for example, C libraries, you need to set up a Nick's development environment

01:22.680 --> 01:28.600
using something like Nick's shell or Nick's develop with the system dependencies.

01:28.600 --> 01:33.480
This requires a manual resolution of those dependencies, and the resulting binary will

01:33.480 --> 01:38.760
contain a path in the next store, which isn't part of a garbage collection route.

01:38.760 --> 01:45.960
So the built artifacts will stop working on the next next GC.

01:45.960 --> 01:50.160
I'm saying system dependencies a lot, and what I mean by that is Opam is rather unique for

01:50.160 --> 01:56.280
a language package manager in that supports providing non-Ochemical dependencies as external

01:56.280 --> 02:00.400
dependencies, they're called DepX, DepX.

02:00.400 --> 02:05.080
You can declare, parameterize, by things like an operating system, packages to be installed

02:05.080 --> 02:07.560
by your system package manager.

02:07.560 --> 02:12.120
So this is an example for the GNP project.

02:12.120 --> 02:16.200
This is like a C library for numerical computation.

02:16.200 --> 02:24.160
You can see here, on Nick's sauce, we depend upon the GNP package, but in DepX, for example,

02:24.160 --> 02:27.720
it's named LibGempDev.

02:27.720 --> 02:33.880
So when using a project that depends upon GNP in Oklahoma on a DepX system, Opam will invoke

02:33.880 --> 02:40.640
up-get install LibGempDev, the equivalent in a Nick's system would be a Nick's and

02:40.680 --> 02:46.160
the equivalent in the GNP, but this will only add binaries to the path.

02:46.160 --> 02:53.120
It won't set up flags that we need for development such as linking flags.

02:53.120 --> 03:02.680
So to provide Nick's system dependencies with Opam, we overhauled its system dependency mechanism

03:02.680 --> 03:04.520
in order to support this.

03:04.560 --> 03:12.200
So Opam gets the lists of DepX for the current switch, which is like a virtual environment,

03:12.200 --> 03:18.200
and creates a Nick's derivation file, they'll look something like this.

03:18.200 --> 03:27.320
You can see here we have the inputs to the derivation, which are the DepX from the Opam repository.

03:27.320 --> 03:33.960
And then the build phase, which is the only phase, builds an environment file that Opam

03:33.960 --> 03:40.520
can read, which sets up the environment variables, used inside the derivation.

03:40.520 --> 03:45.320
And you can see there's a list of variables which are excluded or appended to, instead

03:45.320 --> 03:55.520
of a normal export, and this is from the Nick's developer source code actually.

03:55.520 --> 03:59.720
This is basically how Nick's shell next to help work under the hood, but we're using the

03:59.720 --> 04:07.640
Okamil Package Manager to manage the environment.

04:07.640 --> 04:12.040
Can I get rid of that little, yeah, it's all right.

04:12.040 --> 04:21.800
So basically the resultant environment file is actually a RIT in the Nick's store, the

04:21.800 --> 04:27.080
Nick's GC thing, so it won't be garbage collected as long as that file exists.

04:27.080 --> 04:31.160
So that means your build artifacts will continue to work until you actually remove the switch,

04:31.160 --> 04:32.360
which is quite neat.

04:32.360 --> 04:38.520
Another neat aspect is it won't interact with your system environment, like the Opam,

04:38.520 --> 04:42.480
DepX mechanism with on another system, such as Debian, when you do that app install,

04:42.480 --> 04:45.040
blah, that changes your whole system.

04:45.040 --> 04:48.720
So this could be useful even on the next system.

04:48.720 --> 04:54.200
So before if you return install packages that depended upon ConfGMP, like the Let's Encrypts

04:54.200 --> 05:00.560
Library for provisioning till last year to forgets, you would get this linking error.

05:00.560 --> 05:08.400
But now you get prompted, do you want to run the Nick's build, and it will run a Nick's build

05:08.400 --> 05:14.040
upon this m.nix file, which is what I showed you earlier, and it will generate a Nick's

05:14.040 --> 05:15.040
own file.

05:15.040 --> 05:18.760
Those are different names, it's a little confusing, but that's actually the environment

05:18.760 --> 05:25.320
file, the Opam will read, and then you can see the subsequent install works seamlessly.

05:25.320 --> 05:29.480
And without this mechanism, you would have to manually get all the system dependencies

05:29.480 --> 05:31.480
you might need.

05:31.480 --> 05:32.480
Thank you.

05:32.480 --> 05:43.520
Let me know if you have any questions, grab me at the end, or something.

05:43.520 --> 05:44.520
Thank you very much.

