Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nix): Unable to Compile quantm with Go 1.23 due to gomod2nix and libgit2 version issues #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

debuggerpk
Copy link
Collaborator

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 between gomod2nix, the requirement of vendor/modules.txt and libgit2 version constraints.

The core issue is as follows:

  • Go 1.23 and modules.txt: Go 1.23 introduced a requirement for a vendor/modules.txt file when using go build -mod=vendor. This file tracks explicit dependencies and sub-modules. The current gomod2nix 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 on libgit2 version 1.7.2. The current version of libgit2 in nixpkgs unstable/24.11 is 1.8, which is not compatible.

Root Cause

  1. gomod2nix and Go 1.23: gomod2nix needs to generate vendor/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 generated vendor/modules.txt file.

  2. libgit2 Version: The libgit2 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:

  1. Update Nixpkgs: Upgrade our nixpkgs to the latest 24.11. (this has been done already)
  2. Pin libgit2: Import the libgit2 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.
  3. Incorporate gomod2nix Fix: Apply the changes from gomod2nix PR #168 which uses a go mod vendor command to generate the necessary modules.txt file.
  4. Apply go toolchain patch: Apply the patch that disables checking for vendored dependencies which is part of buildGoModule: fix GO_NO_VENDOR_CHECKS for v1.23+ NixOS/nixpkgs#372367. This patch ensures that go build -mod=vendor works with the generated vendor/modules.txt file.

Additional Notes

  • This issue only impacts the flake build and not nix develop.
  • The fix to the gomod2nix requires patching the go toolchain to disable checking for vendored dependencies which was introduced in go 1.23.
  • We'll need to carefully integrate these changes to maintain a stable and reproducible build environment.

Next Steps

  1. Verify the go toolchain patch fixes the gomod2nix issue.
  2. Implement the proposed solution and test the quantm build process.
  3. Verify the 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant