Visitar URL original
nix develop: drop outputChecks from structured-attrs derivations again by Lillecarl · Pull Request #16742 · NixOS/nix · GitHub
Skip to content

nix develop: drop outputChecks from structured-attrs derivations again - #16742

Open
Lillecarl wants to merge 1 commit into
NixOS:masterfrom
Lillecarl:develop-drops-output-checks
Open

Lillecarl wants to merge 1 commit into
NixOS:masterfrom
Lillecarl:develop-drops-output-checks

Conversation

@Lillecarl

Copy link
Copy Markdown
Contributor

Motivation

nix develop and nix print-dev-env keep the outputChecks of a structured-attrs derivation in the environment derivation, so a check such as maxSize fails the environment build:

error: path '/nix/store/…-hello-env' is too large at 112 bytes; limit is 1 bytes

develop.cc erases outputChecks from the parsed __json object (#14306). Since 6b92dd2 (#16374, "No warn on non-canonical structured attrs"), parsing always keeps the original encoding in StructuredAttrs::verbatim, and unparse writes that encoding when it is set, so the erase has no effect. No release has 6b92dd2 yet.

Implementation

Reset verbatim after the erase.

The existing test (#14312) did not catch this: it ran [[ -z "$(nix develop …)" ]], and a failing nix develop prints nothing, so the test passed. The test now assigns the output first, and the fixture adds maxSize = 1, which the environment cannot meet. Without the fix, flakes/develop fails with the error above; with it, it passes.

Checks, run locally on this change over master 8c8e8b8: pre-commit, rl-next, the util, store, expr, fetchers and flake unit tests, nix-functional-tests, daemonCompat, hydraJobs.clangTidy, componentTests with clangStdenv and sanitizers, the Windows cross-build of nix-util-tests, nix flake show --all-systems, and vmTests plain and instrumented. hydraJobs.tests.cgroups fails, as it does on master: since 31cca91, daemon build cgroups are created inside nix-daemon (a separate fix).

For reviewing agents
  • Root cause traced. 69b449f (Reject derivations not in canonical form #16284) added verbatim only for non-canonical encodings. 6b92dd2 (No warn on non-canonical structured attrs #16374) made it unconditional, which reached every derivation that nix develop reads from the store.
  • Fix in develop.cc, not in StructuredAttrs. develop.cc is the only code that mutates a parsed StructuredAttrs (primops.cc builds fresh ones without verbatim). A setter that clears verbatim would be a larger API change for one caller.
  • Reproduced outside the test suite. With master's nix print-dev-env, the env .drv contains "outputChecks":{"out":{"maxSize":1}}.
  • Nothing else in develop.cc needs the same reset. outputChecks is the only change it makes to structuredAttrs; the other verbatim users are the parser, operator== and unparse.
  • Fail-before / pass-after. The fixed test fails on master ("too large at 112 bytes; limit is 1 bytes") and passes with the fix.
  • No release note. 6b92dd2 is not on 2.35-maintenance, so no release has the regression.
  • Attribution. The commit carries Assisted-by: Claude Code (claude-opus-5-5).

Made by Lillecarl and Claude Code together. The commit carries an Assisted-by: trailer, as CONTRIBUTING.md requires.

Add 👍 to pull requests you find important.

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

`nix develop` builds an environment derivation from the user's
derivation and removes the output checks, which do not apply to the
environment (NixOS#14306). With structured attrs it erases `outputChecks`
from the parsed `__json` object.

Since 6b92dd2 (NixOS#16374), parsing always keeps the original encoding in
`StructuredAttrs::verbatim`, and `unparse` writes that encoding when it
is set. So the erase has no effect, and the environment derivation keeps
the checks of the original. A check such as `maxSize` then fails the
environment build:

    error: path '/nix/store/…-hello-env' is too large at 112 bytes; limit is 1 bytes

Reset `verbatim` after the erase, so that `unparse` encodes the
modified object.

The existing test did not catch this. It ran `nix develop` inside
`[[ -z "$(...)" ]]`, and a failing command prints nothing, which
passes. Assign the output first, and add a `maxSize` check that the
environment cannot meet.

Assisted-by: Claude Code (claude-opus-5-5)
@Lillecarl
Lillecarl requested a review from edolstra as a code owner November 1, 2026 21:40
@github-actions github-actions Bot added new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority labels Nov 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant