help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie: What's the importance of *.drv, *.-builder, etc. files in /g


From: Julien Lepiller
Subject: Re: Newbie: What's the importance of *.drv, *.-builder, etc. files in /gnu/store?
Date: Sat, 08 Apr 2023 09:35:10 +0200
User-agent: K-9 Mail for Android

Going step by step, Guix performs the following.

First, it needs to download the original sources of the package. When creating 
a store item, most of the time, the guix daemon is involved.

The daemon's purpose is to take a lower-level representation of a build 
procedure and turn that into an isolated build environment. This is called a 
*derivation* and it is stored in the store as a `drv` file. For downloading a 
file, the derivation simply contains the URL to download and the daemon 
performs the download itself, so no isolated environment is required here.

Then, the package contains a directive that informs Guix there is some sort of 
change to make in the source. There is an issue in the upstream sources, and we 
need to apply a patch. A `.patch` file is a standard file used in many projects 
to represent one or more changes to a file or a directory. It's not specific to 
Guix.

To apply the file, the daemon needs to create an isolated build environment 
where it can apply the patch. Although a derivation can specify how to make a 
build environment (it specifies inputs (dependencies), the type of system, 
expected output, etc), it does not say *what* to do with it.

The guix daemon does not run inside the isolated build environment (the 
"build-side"), but it needs to run something in it to get things done, somehow. 
This is the role of the builder, which is created by Guix and is derived from 
the package definition. It's a standalone Guile script that is executed on the 
build-side.

On the build-side, the builder extracts the original archive, applies the patch 
and archives the result as a new `.tar.xz` file.

Now, Guix is ready to build transmission. To do so, it creates a new derivation 
`.drv` that instructs the daemon how to make the isolated environment for 
building it, and a builder `-builder` that the daemon will execute inside the 
environment. The build results in the transmission outputs.

To summarize, Guix needs to:

- Download original sources, which creates a derivation (drv) and results in 
downloading a tar.xz to the store.
- Put a patch (.patch) in the store from its own sources, which doesn't create 
a derivation. This is because a derivation can only refer to another store item.
- Apply the patch to the sources, which creates a derivation (.drv) and a 
builder (tar.xz-builder) that result in creating a modified tar.xz in the store.
- Build the transmission package, which creates a derivation (drv) and a 
builder (-builder) that result in the transmission outputs you wanted in the 
first place.

HTH!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]