Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Derivations and Deriving Paths #12290

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

Ericson2314
Copy link
Member

Motivation

Continue documenting the store layer

Context

Some material pulled from #6877


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added documentation new-cli Relating to the "nix" command labels Jan 19, 2025
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big one :)

Comment on lines +3 to +4
So far, we have covered "inert" [store objects][store object].
But the point of the Nix store layer is to be a build system.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we? Not sure how the reader lands here. I guess we could make So far a link, but how about:

Suggested change
So far, we have covered "inert" [store objects][store object].
But the point of the Nix store layer is to be a build system.
Besides functioning as a [content addressed store] the Nix store layer works as a [build system].

(my links and link targets need work, sorry)

doc/manual/source/store/drv.md Outdated Show resolved Hide resolved
doc/manual/source/store/drv.md Outdated Show resolved Hide resolved
doc/manual/source/store/drv.md Outdated Show resolved Hide resolved
doc/manual/source/store/drv.md Outdated Show resolved Hide resolved
doc/manual/source/store/drv.md Outdated Show resolved Hide resolved
doc/manual/source/store/drv.md Outdated Show resolved Hide resolved

### `__structuredAttrs`

Historically speaking, most users of Nix made GNU Bash with a script the command run, regardless of what they were doing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the text some work needs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just going to delete this, because it is too explanation-y, and there are langauge docs we can move to store docs for this (in a subsequent PR!).

doc/manual/source/store/drv.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: resume here.

Thanks!!

Co-authored-by: Robert Hensing <[email protected]>
Each input must be [realised] prior to building the derivation in question.
At that point, the derivation can be *normalized*, by replacing each input deriving path with its store path --- which we now know since we've realised it.

## Builder Execution
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is taken from the language derivation docs with no modification but link updates. It is moved here.

More can be written, but this will do for now.
It is too much of an explanation. There are other docs we can move here
later in the language section already.
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-01-20-nix-team-meeting-minutes-209/59119/1

Comment on lines +70 to +97
## Processing outputs

If the builder exited successfully, the following steps happen in order to turn the output directories left behind by the builder into proper store objects:

- **Normalize the file permissions**

Nix sets the last-modified timestamp on all files
in the build result to 1 (00:00:01 1/1/1970 UTC), sets the group to
the default group, and sets the mode of the file to 0444 or 0555
(i.e., read-only, with execute permission enabled if the file was
originally executable). Any possible `setuid` and `setgid`
bits are cleared.

> **Note**
>
> Setuid and setgid programs are not currently supported by Nix.
> This is because the Nix archives used in deployment have no concept of ownership information,
> and because it makes the build result dependent on the user performing the build.

- **Calculate the references**

Nix scans each output path for
references to input paths by looking for the hash parts of the input
paths. Since these are potential runtime dependencies, Nix registers
them as dependencies of the output paths.

Nix also scans for references to other outputs' paths in the same way, because outputs are allowed to refer to each other.
If the outputs' references to each other form a cycle, this is an error, because the references of store objects much be acyclic.
Copy link
Member Author

@Ericson2314 Ericson2314 Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK actually this part was reworked a little bit

  1. Added this heading

  2. Flipped the order of the two bullets

  3. Made part of the first one a Note

  4. Added the second paragraph to the second about output references

@Ericson2314 Ericson2314 marked this pull request as ready for review January 20, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation new-cli Relating to the "nix" command
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants