-
Notifications
You must be signed in to change notification settings - Fork 5
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
tree-sitter issue due to read-only filesystem #7
Comments
Glad you like it! It's been an interesting puzzle making Doom and Nix work together. There are definitely some rough edges but I think it speaks to the strengths of both projects that this entire contraption works at all (without requiring invasive patching of Doom or a ton of custom derivations, there are a few of both but so far they seem manageable).
Interesting! Possibly related:
Building I think you've found the answer: opening a Go file with
That looks like the same error you're getting. And it looks like the same function that was failing at build time, which this time can contact github but can't write its output.
Hm! I'd previously considered something like the hook you're proposing, but hoped I could get away without it because adding Assuming you mean a hook similar to the If you're ok dealing with the CLA (sorry about that...) then I'd be happy to accept a PR. But if I do: diff --git a/default.nix b/default.nix
index 77777a0..09667a7 100644
--- a/default.nix
+++ b/default.nix
@@ -273,7 +273,7 @@ let
# Step 3: Build an emacsWithPackages, pulling all packages from step 1 from
# the set from step 2.
emacsWithPackages = doomEmacsPackages.emacsWithPackages
- (epkgs: (map (p: epkgs.${p}) (builtins.attrNames doomPackageSet)));
+ (epkgs: [(map (p: epkgs.${p}) (builtins.attrNames doomPackageSet))] ++ [epkgs.treesit-grammars.with-all-grammars]);
# Step 4: build a DOOMDIR, Doom profile and profile loader using Emacs from
# step 3 and packages.el from step 1. to force |
https://github.com/marienz/nix-doom-emacs-unstraightened/tree/tree-sitter has a partial fix, but hits a second problem:
I suspect but haven't confirmed yet that the (13 . 13) there is the supported ABI range from tsc-dyn (/nix/store/bx2sx7s4jpnrnbq8qdbgy7dyqg9xrzk5-tsc-dyn-0.18.0/share/emacs/site-lisp/elpa/tsc-0.18.0/tsc-dyn.so, https://github.com/emacs-tree-sitter/elisp-tree-sitter/blob/02fe7b86d92b1aab954045146469b7893f0ab371/core/src/lang.rs#L172), in which case that error translates to "tsc-dyn is too old for the grammar". Not sure how to fix that one yet (it might not be "my" bug, it might be version skew in nixpkgs this time...) |
Yes, I ran into that as well. Seeing as Doom Emacs will be moving to the Emacs built-in treesitter in the future, I then decided to use the package treesit-auto and treesit-grammars.with-all-grammars and unpin eglot after which there is no conflict. I suspect that this is not really satisfactory for you though. I've also put a lot of effort into trying to make the override I mentioned work but I'm not having any luck. The furthest I've gotten is to use mkConfig to create a list of strings and simply doing the same map shenanigans as you're doing in the diff above. That works for simple package names like "vterm" but not for "treesit-grammars.with-all-grammars" I've since ventured deep into pkgs.override and It all boils down to me wanting to have an
But I've been unable to use that directly in the Do you have a good idea/proposal for how to extend an already defined set of "emacs-packages"? |
I've finally arrived at a solution that works and I will submit a pull request (with CLA) sometime next week. In summary: Add an programs.doom-emacs = {
enable = true;
doomDir = inputs.doom-config;
emacs = my-emacs-unstable;
extraPackages = epkgs: [ epkgs.vterm epkgs.treesit-grammars.with-all-grammars ];
provideEmacs = false;
}; The way the function is used is like so in emacsWithPackages = doomEmacsPackages.emacsWithPackages
(epkgs: (map (p: epkgs.${p}) (builtins.attrNames doomPackageSet)) ++ (extraPackages doomEmacsPackages)); What do you think? |
Looks good to me! (I do want to dig into what's going wrong with tree-sitter, but I'm a little sidetracked with CI and other improvements...) |
Looking more closely...
So it does look like our go.so (from tree-sitter-grammars / tree-sitter-go-grammar) is too new. But I don't really want to pull in the pre-compiled bundle that makes this work with vanilla Doom... emacs-tree-sitter/elisp-tree-sitter#247 looks related, and says to use Emacs 29's built-in tree-sitter support instead. That should load libraries from
But I suspect Doom won't then automatically use the built-in support, though... That looks like it'd be doomemacs/doomemacs#7623. The other option would be "build grammars for the old ABI". But assuming https://github.com/tree-sitter/tree-sitter-go/blob/master/src/parser.c is typical, those are generated c source with the language version hardcoded into them: that approach doesn't look practical. So I don't think I can really reasonably fix this until Doom switches to built-in treesitter... |
I believe you are right. Perhaps we should close this issue? If you'd like, I can detail the workaround I'm using in the readme as part of the PR together with a link to this issue. The nifty thing about the workaround is that it is both nix and non-nix compatible due to treesit-auto implements automatic download at runtime. For nix I prefer to provide it with the deps up front. |
There are other options I intend to look into:
If I understand the problem correctly, it boils down to unfortunate timing: tree-sitter going through an ABI change around the same time Emacs transitions to built-in tree-sitter support. So this will eventually get fixed, but depending on what Doom decides to do about Emacs 28 support it may take a while (and if it does I'd really prefer not to declare all of tree-sitter unsupported until then...) |
Keeping this open as I think it's doable to build tree-sitter-langs with old ABI (which I'll try to land in nixpkgs upstream but may carry locally). For anyone running into this until then: please try the workaround schwanberger@ just added (thanks!) |
Hi. Have you seen the recent commits to doom emacs? This just might have been solved upstream. (Haven't tested) |
tree-sitter-langs has special handling in nixpkgs, and our pinning breaks assumptions it makes about version numbers. This causes tree-sitter-langs to attempt to download and write a grammar bundle both at build time (where the network request fails) and runtime (where it causes an error on visiting a file supposed to be handled by tree-sitter). Fix up our derivation so it loads the Nix-provided grammar bundle. This only partially fixes the problem: at least for Go, the tree-sitter-langs package now loads, but visiting a Go file causes `tsc-lang-abi-too-new 14 (13 . 13)`. The included test fails without the fix in this commit, but does not trigger this new failure. Commit this partial fix because after NixOS/nixpkgs@2421239 the build-time failure became an error. This should fix CI and leave us no worse off than before.
Hi!
First off, I would also like to say thank you very much - and wow - well done. I love emacs and nix and I really appreciate this project as I can deepen my understanding of both (especially where they intersect).
Using my config that includes the tree-sitter module I encounter this error when first opening a
.go
file. I suspect the issue appear in general for all languages. It tries to download the grammar.I believe (am unsure) that the download does not happen in my non-unstraightened setup since I'm including the emacs pkg
treesit-grammars.with-all-grammars
in aemacsWithPackagesFromUsePackage
function. I expect this includes all the grammers available so no download is required at runtime.Would it make sense to include an "extraEmacsPackages" configuration option for unstraightened? It could be a merge (with "extraEmacsPackages" being right side) into the set containing the packages deduced/included from doom config.
If you agree I would like to take a stab at it and submit a pull request (Will remember to include the CLA).
Any other suggestion is also welcome of course.
The text was updated successfully, but these errors were encountered: