-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
buildEnv: support fixed-point arguments #432957
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d63fab0
tests.buildenv: init test harness
philiptaron cf7ebfa
tests.buildenv: test name/pname/version handling
philiptaron c427577
buildEnv: specify extraPathsFrom a string as expected by the builder
ShamrockLee 7269993
buildEnv: construct with extendMkDerivation and stdenvNoCC.mkDerivation
ShamrockLee ae8cb8c
buildEnv: reference attributes from finalAttrs
ShamrockLee 7e851e1
buildEnv: take derivationArgs
ShamrockLee 3182567
doc: buildenv.section.md: init
ShamrockLee 3b82db1
rl-2511.section.md: document buildEnv's supporting finalAttrs and <pk…
ShamrockLee 7269072
buildEnv: fix passthru merging
philiptaron 179ca98
doc: buildenv.section.md: fix argument name, default, and grammar
philiptaron 150cd2a
tests.buildenv: test passthru.paths injection
philiptaron effd58a
tests.buildenv: test finalAttrs self-reference
philiptaron fc93a90
tests.buildenv: test overrideAttrs
philiptaron dbf1fa9
tests.buildenv: test passthru merging
philiptaron 83669e3
tests.buildenv: test derivationArgs forwarding
philiptaron 42a88a9
tests.buildenv: add build tests for output verification
philiptaron 61eaaf6
tests.buildenv: assert that structuredAttrs is broken
philiptaron d206494
texlive: buildTeXEnv: use buildEnv with derivationArgs instead of cus…
ShamrockLee 6432891
texlive: buildTeXEnv: format expression
ShamrockLee 1b0981b
buildEnv: explicitly set __structuredAttrs = false
philiptaron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # buildEnv {#sec-buildEnv} | ||
|
|
||
| `buildEnv` constructs a derivation containing directories and symbolic links, which resembles the profile layout where a list of derivations or store paths are installed. | ||
|
|
||
| Unlike [`symlinkJoin`](#trivial-builder-symlinkJoin), `buildEnv` takes special care of the outputs to link and checks for content collisions across the paths by default. | ||
| A common use case for `buildEnv` is constructing environment wrappers, such as an interpreter with modules or a program with extensions. | ||
| For example, [`python.withPackage`](#attributes-on-interpreters-packages) is based on `buildEnv`. | ||
|
|
||
| ## Arguments {#sec-buildEnv-arguments} | ||
|
|
||
| `buildEnv` takes [fixed-point arguments (`buildEnv (finalAttrs: { })`)](#chap-build-helpers-finalAttrs) as well as a plain attribute set. | ||
|
|
||
| Unless otherwise noted, arguments can be overridden directly using [`<pkg>.overrideAttrs`](#sec-pkg-overrideAttrs). | ||
|
|
||
| - `name` or `pname` and `version` (required): | ||
| The name of the environment. | ||
|
|
||
| - `paths` (required): | ||
| The derivations or store paths to symlink ("install"). | ||
|
|
||
| The elements can be any path-like object that string-interpolates to a store path. | ||
| The priority of each path is taken from `<path>.meta.priority` and falls back to `lib.meta.defaultPriority` if not set. | ||
|
|
||
| The argument `paths` is passed as attribute `passthru.paths` to prevent unexpected context pollution. | ||
| `passthru.paths` can be overridden with `<pkg>.overrideAttrs`. | ||
|
|
||
| - `extraOutputsToInstall` (default to `[ ]`): | ||
| Package outputs to include in addition to what `meta.outputsToInstall` specifies. | ||
|
|
||
| - `includeClosure` (default to `false`): | ||
| Whether to include closures of all input paths. | ||
| The list of the closure paths are constructed with `writeClosure`. | ||
| They are installed with lower priority and with build-time exceptions silenced. | ||
|
|
||
| - `extraPrefix` (default to `[ ]`): | ||
| Root the result in directory `"$out${extraPrefix}"`, e.g. `"/share"`. | ||
|
|
||
| - `ignoreCollisions` (default: `false`): | ||
| Don't fail the build upon content collisions. | ||
|
|
||
| - `checkCollisionContents` (default: `true`): | ||
|
philiptaron marked this conversation as resolved.
|
||
| If there is a collision, check whether the contents and permissions match; and only if not, throw a collision error. | ||
|
|
||
| - `ignoreSingleFileOutputs` (default: `false`): | ||
| Don't fail the build upon single-file outputs. | ||
|
|
||
| - `manifest` (default: `""`): | ||
| The manifest file (if any). A symlink `$out/manifest` will be created to it. | ||
|
|
||
| - `pathsToLink` (default: `[ "/" ]`): | ||
| The paths (relative to each element of `paths`) that we want to symlink (e.g., `["/bin"]`). | ||
| Any file outside the directories in this list won't be symlinked into the produced environment. | ||
|
|
||
| - `postBuild` (default: `""`): | ||
| Shell commands to run after building the symlink tree. | ||
|
|
||
| - `passthru` and `meta` (default: `{ }`): | ||
| `stdenv.mkDerivation`-supported attributes not passing down to `builtins.derivation`. | ||
|
|
||
| - `derivationArgs` (default: `{ }`): | ||
| Additional `stdenv.mkDerivation` arguments, such as `nativeBuildInputs`/`buildInputs` for `postBuild` dependencies and setup hooks. | ||
|
|
||
| `derivationArgs` is not passed down to `stdenv.mkDerivation`. | ||
| Override its attributes directly via `<pkg>.overrideAttrs` and reference directly via `finalAttrs`. | ||
|
|
||
| ## Build-time exceptions {#sec-buildEnv-exceptions} | ||
|
|
||
| There are situations where the specified `paths` might not produce sensible profile layout. | ||
| By default, the builder fails early upon detecting these exceptions. | ||
| `buildEnv` provides arguments to fine-tune or ignore certain exceptions. | ||
|
|
||
| ### Path collisions {#ssec-buildEnv-collisions} | ||
|
|
||
| Path collisions occur when files provided by two more output paths with the same priority overlap with each other, making the result profile layout potentially affected by the order of elements of `paths`. | ||
| This is undesirable in several use cases, such as when `paths` are determined by merging Nix modules. | ||
|
|
||
| If the argument `checkCollisionContents` is `true`, the builder checks whether the overlapping paths share the same content and mode, and fails only if not. | ||
|
|
||
| The argument `ignoreCollisions` silence the collision checks and allow the files to be overwritten based on the order of chosen output paths. | ||
|
|
||
| In addition to silencing this exception with `ignoreCollisions`, one can also adjust the priority of colliding packages and store paths. | ||
| Store paths can specify priority in the form | ||
|
|
||
| ```nix | ||
| { | ||
| outPath = <path>; | ||
| meta.priority = <priority>; | ||
| } | ||
| ``` | ||
|
|
||
| And [`lib.meta.setPrio`](#function-library-lib.meta.setPrio)-related Nixpkgs Library functions also apply to a string-like attribute set (`{ outPath = <path>; }`). | ||
|
|
||
| ### Single-file outputs {#ssec-buildEnv-singleFileOutputs} | ||
|
|
||
| When an output path provides a single file instead of a directory, it inherently cannot merge into the result layout. | ||
| All discoverable packages should configure their `meta.outputsToInstall` correctly, so that single-file outputs won't be installed into a profile. | ||
|
|
||
| The `ignoreSingleFileOutputs` To drop all single-file output paths silently. | ||
| This option is useful when the specified paths contain the output paths of package tests. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.