Skip to content

shellgen: replace builtins.fetchClosure with builtins.appendContext for Lix ≥2.95 compat - #2997

Open
dajiaohuang wants to merge 1 commit into
jetify-com:mainfrom
dajiaohuang:fix/lix-fetchclosure-appendcontext
Open

dajiaohuang wants to merge 1 commit into
jetify-com:mainfrom
dajiaohuang:fix/lix-fetchclosure-appendcontext

Conversation

@dajiaohuang

Copy link
Copy Markdown

Summary

This PR fixes #2983 by replacing the experimental builtins.fetchClosure in the generated flake.nix with builtins.appendContext, restoring compatibility with Lix ≥ 2.95 which removed builtins.fetchClosure.

builtins.appendContext has existed since Nix 2.0, requires no experimental feature, and calls store->ensurePath() during eval — same substitution behavior as fetchClosure. Verified in the issue to work on both Nix 2.30.2 (pure eval, no extra experimental features beyond nix-command flakes) and Lix 2.95.2.

Changes

  • internal/shellgen/tmpl/flake.nix.tmpl: replace the builtins.fetchClosure block with builtins.appendContext. Kept the builtins.trace "downloading …" wrapper. Updated the HACK comment to explain the appendContext trick.
  • internal/shellgen/flake_plan.go: delete dead fetchClosureExpr method and the IsInBinaryCache branch in glibcPatchFlake.addOutput (Patch packages have IsInBinaryCache == false, so this branch was unreachable; as noted in the issue, patchGlibc also accesses pkg.name / pkg.buildInputs which would break if it were ever reached).
  • internal/nix/command.go and internal/nix/nix.go (ExperimentalFlags): drop fetch-closure from the experimental-features list — no code path uses it anymore.
  • internal/nix/install.go: remove the Lix ≥ 2.95 compatibility gate added in fix(nix): detect incompatible Lix and print a clear hint (#2946) #2949; it's no longer needed since we no longer call builtins.fetchClosure.
  • nix/nix.go: remove the LixVersionWithoutFetchClosure constant and the SupportsFetchClosure() method. Kept Info.IsLix() and the Nix version parsing — useful for future diagnostics.
  • nix/nix_test.go: remove TestInfoSupportsFetchClosure.
  • internal/shellgen/flake_input.go, internal/devpkg/narinfo_cache.go: update stale comments referencing fetchClosure.

Verification

  • go build ./... ✅
  • go vet ./... ✅
  • go test ./nix/... ./internal/shellgen/... ./internal/devpkg/... ✅ (the internal/nix TestConfigIsUserTrusted failures are pre-existing and caused by no Nix binary on this build machine, unrelated to this change).

Note: CI workflow/test Dockerfile changes to drop fetch-closure from nix.conf are intentionally omitted from this PR because they require workflow scope on the token used here. Leaving the feature enabled in nix.conf is harmless — it just enables the experimental feature server-side; Devbox simply stops using it. Maintainers can clean those up in a follow-up.

Fixes #2983.

…or Lix >=2.95 compat

Replaces the experimental builtins.fetchClosure in the generated flake.nix
with builtins.appendContext, which has existed since Nix 2.0 and requires no
experimental feature. This restores compatibility with Lix >= 2.95, which
removed builtins.fetchClosure.

Changes:
- flake.nix.tmpl: use builtins.appendContext with path context instead of
  builtins.fetchClosure. The trace wrapper is preserved.
- flake_plan.go: delete dead fetchClosureExpr and the IsInBinaryCache branch
  in glibcPatchFlake.addOutput (Patch packages are never in binary cache).
- nix/command.go, internal/nix/nix.go (ExperimentalFlags): drop 'fetch-closure'
  from the experimental-features flag.
- internal/nix/install.go: remove the Lix >=2.95 compatibility gate (no longer
  needed since we no longer use fetchClosure).
- nix/nix.go: remove LixVersionWithoutFetchClosure const and
  SupportsFetchClosure(); keep IsLix() for future diagnostics.
- nix/nix_test.go: remove TestInfoSupportsFetchClosure.
- flake_input.go, narinfo_cache.go: update stale comments.

Fixes jetify-com#2983.

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

None yet

Development

Successfully merging this pull request may close these issues.

Restore Lix ≥ 2.95 compatibility by replacing builtins.fetchClosure with builtins.appendContext

1 participant