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

Draft
wants to merge 16 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)

Other system (like Git or IPFS) also store and transfer immutable data, but they don't concern themselves with *how* that data was created.

This is where Nix distinguishes itself.
*Derivations* represent individual build steps, and *deriving paths* are needed to to the *outputs* of those build steps.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
*Derivations* represent individual build steps, and *deriving paths* are needed to to the *outputs* of those build steps.
*Derivations* represent individual build steps, and *deriving paths* are needed to refer to the *outputs* of those build steps.


This is where Nix distinguishes itself.
*Derivations* represent individual build steps, and *deriving paths* are needed to to the *outputs* of those build steps.
The two concepts need to be introduced together because, as described below, each depends on the other.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The two concepts need to be introduced together because, as described below, each depends on the other.
<!-- The two concepts need to be introduced together because, as described below, each depends on the other. -->

Sounds like it's relevant to editors, mostly.


A derivation is a specification for running an executable on precisely defined input files to repeatably produce output files at uniquely determined file system paths.

What is natural Unix analog for a build step *in action*?
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
What is natural Unix analog for a build step *in action*?
What is the natural Unix analog for a build step *in action*?

A derivation is a specification for running an executable on precisely defined input files to repeatably produce output files at uniquely determined file system paths.

What is natural Unix analog for a build step *in action*?
Answer: a process that will eventually exit, leaving behind some output date.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Answer: a process that will eventually exit, leaving behind some output date.
Answer: a process that will eventually exit, leaving behind some output files.

We're talking vague Unix, so everything is a file, and that's good enough, and better than data.

}
```

Now, the `drv` field of `Output` is itself a `DerivingPath` instead of an `StorePath`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Now, the `drv` field of `Output` is itself a `DerivingPath` instead of an `StorePath`.
Now, the `drv` field of `Output` is itself a `DerivingPath` instead of a `StorePath`.


### Encoding {#deriving-path-encoding}

The encoding is adjusted in a very simplest way, merely displaying the same
Copy link
Member

Choose a reason for hiding this comment

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

TODO


### `__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

Comment on lines +283 to +284
However, since derivations can already contain arbitary input sources, the vast majority of `__structuredAttrs` can be handled by upper layers.
We might consider implementing `__structuredAttrs` in higher layers in the future, and simplifying the store layer.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
However, since derivations can already contain arbitary input sources, the vast majority of `__structuredAttrs` can be handled by upper layers.
We might consider implementing `__structuredAttrs` in higher layers in the future, and simplifying the store layer.

This should be an issue, and not docs.

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.

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.

2 participants