Code change:
Describe the bug The Emacs packages for don't successfully load. To Reproduce Run a from the following : After opening Emacs from inside the and running , we get the following: Expected behavior The packages should be properly loaded, and they should offer syntax-highlighting for select languages. Notify maintainers No one has any particular responsibility for this package. But might be interested in this. Metadata Please run and paste the result.
I'm currently using this, but it stills need some work. Languages grammar are downloaded instead of being built (each language should have it's own separate nix package), and I'm not happy about the but if the grammar bins are in directory will put them in the .
I marked this as stale due to inactivity. &rarr;
Unstale
facing the same issue
Same. What's going on with this issue?
So, I've been looking into this a bit and kind of understand what should be done, but haven't been able to create enough code for a working PR yet. So, basically what you want is to build a rust package from here: The result of the build is and this needs to be built as a dependency for so the file is available for it as . I think it should be enough to link whatever file gets compiled from to the if I read the code correctly. Then, the next is to link all the compiled tree-sitter grammars for the emacs package to find, something copied from how the neovim plugin does this: I'm not completely sure where to build all these packages and I'm running out of my personal time to get this working together. What I see in the current state is many packages linking as a dependency, but is just building the emacs package, not using to build whatever is in the directory and linking the resulting library for the lisp libraries. And the grammars are already in the nixpkgs, you just need to link them to a place where the emacs tree-sitter plugin can find them.
Hey all. I'm still working on fixing this due to me needing tree-sitter for my emacs setup and wanting to understand nix more. Here's the work so far: It now compiles the rust module correctly, and uses the linking strategy from for the languages. It still tries to download files from github, so I either don't link the files to the correct location, or I should patch a method to prevent the download process. I think the best solution would be to use the grammars already available in the monorepo the same way as does. My first try with them was with , but some of them won't work together with the emacs library due to licensing issues. And I also got myself to the download problem, but I think this is not due to files not being the pre-compiled ones from github, but again about some linking issues. If somebody wants to try this out and give me feedback, I'm all ears. I will probably spend some Christmas holiday spare time to make the PR happen. It is very close already.
I made a PR and now it works at least on my NixOS laptop. It would still be nice if we could either utilize the grammars already available in nix, or at least we'd be able to compile them in the derivation instead of just downloading the binaries. I'd be happy if you could try this out and see if it works for you.

Related discussion:
text: <ins> #!/usr/bin/env python3 from textwrap import dedent from os.path import ( abspath, dirname, join, ) from typing import ( Dict, Any, ) import subprocess import tempfile import json import sys import re import requests def eval_drv(nixpkgs: str, expr: str) -> Any: expr = "n".join( ( "with (import %s {});" % nixpkgs, expr, ) ) with tempfile.NamedTemporaryFile(mode="w") as f: f.write(dedent(expr)) f.flush() p = subprocess.run( ["nix-instantiate", "--json", f.name], stdout=subprocess.PIPE, check=True ) return p.stdout.decode().strip() def get_src(tag_name: str) -> Dict[str, str]: p = subprocess.run( [ "nix-prefetch-github", "--rev", tag_name, "--json", "emacs-tree-sitter", "elisp-tree-sitter", ], stdout=subprocess.PIPE, check=True, ) src = json.loads(p.stdout) fields = ["owner", "repo", "rev", "sha256"] return {f: src[f] for f in fields} def get_cargo_sha256(drv_path: str): # Note: No check=True since we expect this command to fail p = subprocess.run(["nix-store", "-r", drv_path], stderr=subprocess.PIPE) stderr = p.stderr.decode() lines = iter(stderr.split("n")) for l in lines: if l.startswith("error: hash mismatch in fixed-output derivation"): break else: raise ValueError("Did not find expected hash mismatch message") for l in lines: m = re.match(r"s+got:s+(.+)$", l) if m: return m.group(1) raise ValueError("Could not extract actual sha256 hash: ", stderr) if __name__ == "__main__": cwd = sys.argv[1] nixpkgs = abspath(join(cwd, "../../../../../..")) tag_name = requests.get( "https://api.github.com/repos/emacs-tree-sitter/elisp-tree-sitter/releases/latest" ).json()["tag_name"] src = get_src(tag_name) with tempfile.NamedTemporaryFile(mode="w") as f: json.dump(src, f) f.flush() drv_path = eval_drv( nixpkgs, """ rustPlatform.buildRustPackage { pname = "tsc-dyn"; version = "%s"; nativeBuildInputs = [ clang ]; src = fetchFromGitHub (lib.importJSON %s); sourceRoot = "source/core"; cargoSha256 = lib.fakeSha256; } """ % (tag_name, f.name), ) cargo_sha256 = get_cargo_sha256(drv_path) with open(join(cwd, "src.json"), mode="w") as f: json.dump( { "src": src, "version": tag_name, "cargoSha256": cargo_sha256, }, f, indent=2, ) f.write("n") </ins>