12 Commits

Author SHA1 Message Date
Yueh-Shun Li ed96bfd307 buildEnv: construct with structured attributes and pass chosenOutputs directly 2026-04-02 07:31:12 -07:00
Yueh-Shun Li 0efccf1dd9 buildEnv: remove redundant pname-version-name assertion
Delegate such a check to stdenv.mkDerivation.
2026-04-02 07:30:35 -07:00
Philip Taron 1b0981b3cb buildEnv: explicitly set __structuredAttrs = false
builder.pl reads all configuration from %ENV, which is fundamentally
incompatible with __structuredAttrs = true (values go into a JSON file
instead). Explicitly opt out so buildEnv doesn't break when
structuredAttrsByDefault is enabled.

The override is placed in the final merge block so it cannot be
circumvented via derivationArgs.

Update the structuredAttrs test from asserting build failure to
verifying that the override works: the build succeeds even when
derivationArgs.__structuredAttrs = true, and eval tests confirm the
attribute is always false.

Suggested-by: Sietse Ringers <SFrijters>
2026-03-24 20:54:58 -07:00
Philip Taron 61eaaf6184 tests.buildenv: assert that structuredAttrs is broken
buildEnv's builder.pl reads all inputs from environment variables,
which is incompatible with structuredAttrs (values go into a JSON file
instead). Document this known failure as a test.
2026-03-19 13:43:18 -07:00
Philip Taron 42a88a9634 tests.buildenv: add build tests for output verification
Add derivations that actually build a buildEnv and verify the output tree.
Exposed as passthru.buildTests so they can be built individually or all at once.

- basic-symlinking: single package produces correct symlink structure
- pathsToLink: only specified subdirectories appear in output
- extraPrefix: output is rooted under the specified prefix
- postBuild: shell commands execute after the symlink tree
- ignoreCollisions: duplicate paths succeed when ignoreCollisions=true
2026-03-19 13:17:21 -07:00
Philip Taron 83669e31a2 tests.buildenv: test derivationArgs forwarding
Verify that:
- derivationArgs attributes reach the underlying mkDerivation (tested via allowSubstitutes overriding the default false)
- The backward-compat layer for top-level nativeBuildInputs still works (these are forwarded through compatArgs)
2026-03-19 13:17:21 -07:00
Philip Taron dbf1fa96d8 tests.buildenv: test passthru merging
buildEnv merges passthru from three sources:
  `{ inherit paths; } // derivationArgs.passthru // passthru`

Verify that:
- Auto-injected paths are present in passthru
- derivationArgs.passthru attributes are preserved
- Direct passthru attributes are preserved
- Direct passthru takes precedence over derivationArgs.passthru
2026-03-19 13:17:21 -07:00
Philip Taron fc93a90563 tests.buildenv: test overrideAttrs
Verify that overrideAttrs on a buildEnv result:

- Can modify passthru attributes
- Preserves the derivation name
- Produces a different derivation when a build-affecting attribute (postBuild) is changed
2026-03-19 13:17:20 -07:00
Philip Taron effd58ab3e tests.buildenv: test finalAttrs self-reference
This is the core new capability of the PR: `buildEnv` now accepts a function `(finalAttrs: { ... })` enabling self-referencing attributes.

Verify that finalAttrs.name is accessible from within the argument function.
2026-03-19 13:17:20 -07:00
Philip Taron 150cd2ae32 tests.buildenv: test passthru.paths injection
buildEnv stashes `paths` into `passthru.paths` (rather than passing it directly as a derivation attribute) to prevent unexpected string context pollution. Verify that:
- paths are accessible via passthru.paths
- passthru.paths can be overridden with overrideAttrs
2026-03-19 13:17:20 -07:00
Philip Taron cf7ebfa6ae tests.buildenv: test name/pname/version handling
Verify that:
- `name` argument is used directly as the derivation name
- `pname` + `version` composes into the derivation name
- Omitting all three triggers the buildEnv-specific assertion

The assertion test uses `builtins.tryEval` + `builtins.seq` to force evaluation of .drvPath and confirm it throws.
2026-03-19 13:17:18 -07:00
Philip Taron d63fab02b0 tests.buildenv: init test harness
Add an eval-time test harness for buildEnv following the pattern established by `tests.overriding`.
Uses `lib.runTests` to compare expr/expected pairs, and the buildCommand reports pass/fail.

No tests yet; subsequent commits add them individually.
2026-03-19 13:17:18 -07:00