fix(nix): detect incompatible Lix and print a clear hint (#2946) - #2949
Open
mikeland73 wants to merge 1 commit into
Open
fix(nix): detect incompatible Lix and print a clear hint (#2946)#2949mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #2946.
Lix 2.95 removed
builtins.fetchClosure, which Devbox relies on to install packages from a binary cache (seeinternal/shellgen/tmpl/flake.nix.tmplandinternal/shellgen/flake_plan.go). On a Lix ≥ 2.95 installation, Devbox failed later during flake evaluation with an opaque error:The issue reporter asked for a compatibility check/hint instead of that cryptic message. This PR adds one:
nix --versionoutput 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 newInfo.Implementationfield.Info.IsLix()andInfo.SupportsFetchClosure()helpers.SupportsFetchClosure()returnsfalseonly for Lix ≥ 2.95 (LixVersionWithoutFetchClosure), and defaults totruewhen the version can't be determined to avoid false positives.EnsureNixInstallednow performs this check up front (right after the existing minimum-version check) and returns a friendlyusererrpointing 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?
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.TestParseVersionInfo/TestParseLixVersionInfoto assert the newImplementationfield.go build ./...,go vet ./nix/ ./internal/nix/, andgofmtare clean.go test ./nix/passes. (The unrelatedinternal/nixTestConfigIsUserTrustedfailures in the sandbox are pre-existing and only occur because no realnixbinary 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