fix(nix): Unable to Compile quantm
with Go 1.23 due to gomod2nix
and libgit2
version issues
#206
+434
−345
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.
Problem
Currently, the
quantm
application fails to compile within our Nix environment when using Go 1.23. This is primarily due to incompatibilities arising from the interaction betweengomod2nix
, the requirement ofvendor/modules.txt
andlibgit2
version constraints.The core issue is as follows:
Go 1.23 and
modules.txt
: Go 1.23 introduced a requirement for avendor/modules.txt
file when usinggo build -mod=vendor
. This file tracks explicit dependencies and sub-modules. The currentgomod2nix
version doesn't properly handle this requirement out of the box, and this is addressed in gomod2nix PR #168, however, that PR requires a patch to the go toolchain in nixpkgs.libgit2
Version: The current build process depends onlibgit2
version 1.7.2. The current version oflibgit2
in nixpkgs unstable/24.11 is 1.8, which is not compatible.Root Cause
gomod2nix
and Go 1.23:gomod2nix
needs to generatevendor/modules.txt
which was introduced in go 1.23 which is not the default behavior. This is addressed in the above mentioned PR. This requires a go toolchain patch in nixpkgs to work with this generatedvendor/modules.txt
file.libgit2
Version: Thelibgit2
version 1.7.2 is required for a build however nixpkgs 24.11 has version 1.8, which causes compatibility issues.Proposed Solution
To resolve this issue, we need to:
libgit2
: Import thelibgit2
package version 1.7.2 from the nixpkgs 24.05 using the following instruction found here. This ensures that the correct version is used during the build.gomod2nix
Fix: Apply the changes from gomod2nix PR #168 which uses ago mod vendor
command to generate the necessarymodules.txt
file.go build -mod=vendor
works with the generatedvendor/modules.txt
file.Additional Notes
nix develop
.Next Steps
quantm
build process.quantm
binary works as intended.This detailed issue should help us track the problem, understand its causes, and collaborate effectively to implement the necessary fixes.