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

build(nix): Fix Nix grammars build due to breaking changes in fetchTree #9867

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

Conversation

mstrangfeld
Copy link

Due to NixOS/nix@09d76e5
Fixes issue #9866

This is the easiest fix for now. We maybe should consider prefetching the GitHub repos and calculate the NAR hashes but this would be an extra step that cannot be integrated into the pure build evaluation.

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

IIRC we special-cased github grammars because the github fetcher was much much faster than the git fetcher. (I believe it's getting a tarball of the exact revision rather than cloning, or something like that.) So this is an unfortunate breakage from Nix. Hopefully the caching from cachix will make the build fast enough.

I left a comment about refs but otherwise this looks good

@@ -40,24 +33,13 @@
grammarsToUse = builtins.filter useGrammar languagesConfig.grammar;
gitGrammars = builtins.filter isGitGrammar grammarsToUse;
buildGrammar = grammar: let
gh = toGitHubFetcher grammar.source.git;
sourceGit = builtins.fetchTree {
source = builtins.fetchTree {
type = "git";
url = grammar.source.git;
rev = grammar.source.rev;
ref = grammar.source.ref or "HEAD";
Copy link
Member

Choose a reason for hiding this comment

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

The nix build fails for me on this branch with Nix 2.18.1. A few grammars in languages.toml use commits that aren't from their HEAD, for example tree-sitter-groovy is from the gh-pages branch:

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'helix-term-23.10.0'
         whose name attribute is located at /nix/store/bjvqq8c79dbi59g7xzcc6lhl0f19m3d7-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'buildCommand' of derivation 'helix-term-23.10.0'

         at /nix/store/bjvqq8c79dbi59g7xzcc6lhl0f19m3d7-source/pkgs/build-support/trivial-builders/default.nix:98:16:

           97|         enableParallelBuilding = true;
           98|         inherit buildCommand name;
             |                ^
           99|         passAsFile = [ "buildCommand" ]

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Cannot find Git revision '7e023227f46fee428b16a0288eeb0f65ee2523ec' in ref 'HEAD' of repository 'https://github.com/Decodetalkers/tree-sitter-groovy'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

I believe this needs to be

Suggested change
ref = grammar.source.ref or "HEAD";
allRefs = true;

instead, or we need to add ref to all grammars that don't use their main branch for committing tree-sitter outputs. (We should use allRefs instead because not all language-support contributors use Nix so they won't know to update the ref.)

@the-mikedavis the-mikedavis added A-packaging Area: Packaging and bundling S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 15, 2024
@archseer
Copy link
Member

Could we add the NAR hashes in a separate lock file? Seems like a big regression if we switch over to fetchGit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-packaging Area: Packaging and bundling S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants