Skip to content

fix(nix): detect incompatible Lix and print a clear hint (#2946) - #2949

Open
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-snh6zf
Open

fix(nix): detect incompatible Lix and print a clear hint (#2946)#2949
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-snh6zf

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2946.

Lix 2.95 removed builtins.fetchClosure, which Devbox relies on to install packages from a binary cache (see internal/shellgen/tmpl/flake.nix.tmpl and internal/shellgen/flake_plan.go). On a Lix ≥ 2.95 installation, Devbox failed later during flake evaluation with an opaque error:

attribute 'fetchClosure' missing: exit code 1

The issue reporter asked for a compatibility check/hint instead of that cryptic message. This PR adds one:

  • The first line of nix --version output includes a parenthetical descriptor — (Nix) for upstream Nix and (Lix, like Nix) for the Lix fork. That descriptor was previously discarded by the version regexp. It's now captured into a new Info.Implementation field.
  • Added Info.IsLix() and Info.SupportsFetchClosure() helpers. SupportsFetchClosure() returns false only for Lix ≥ 2.95 (LixVersionWithoutFetchClosure), and defaults to true when the version can't be determined to avoid false positives.
  • EnsureNixInstalled now performs this check up front (right after the existing minimum-version check) and returns a friendly usererr pointing the user to Nix or a Lix version < 2.95, instead of letting the flake evaluation fail later with the opaque message.

cc @acuteaura (issue reporter)

How was it tested?

  • Added unit tests in nix/nix_test.go:
    • TestInfoIsLix — Lix vs. Nix detection from the implementation descriptor.
    • TestInfoSupportsFetchClosure — Nix, Lix < 2.95, Lix prerelease, Lix 2.95, Lix > 2.95, and unknown-version cases.
    • Extended TestParseVersionInfo / TestParseLixVersionInfo to assert the new Implementation field.
  • go build ./..., go vet ./nix/ ./internal/nix/, and gofmt are clean.
  • go test ./nix/ passes. (The unrelated internal/nix TestConfigIsUserTrusted failures in the sandbox are pre-existing and only occur because no real nix binary is available in the CI-less environment used here.)

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.


Generated by Claude Code

Lix 2.95 removed `builtins.fetchClosure`, which Devbox relies on to
install packages from a binary cache. On such an installation Devbox
failed with a cryptic `attribute 'fetchClosure' missing` error.

Capture the implementation descriptor from `nix --version` output (e.g.
"Lix, like Nix") so we can identify the Lix fork, and add `Info.IsLix`
and `Info.SupportsFetchClosure` helpers. `EnsureNixInstalled` now checks
this up front and returns a friendly compatibility hint pointing users to
Nix or a Lix version < 2.95, instead of letting the flake evaluation fail
later with an opaque message.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PfDiNJ4vhy94wszC6vRR8d
Copilot AI lite review requested due to automatic review settings August 15, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

incompatible with Lix 2.95

3 participants