hlb-08092025

Nix-shell
Login

Nix-shell

Part1: Compiling Helix Grammars

Helix (hx) is an Editor written in Rust and is very much like Vim, Neovim and all Vim-alikes, but it does not have exactly the same editor commands, however that's a discussion for another day. The pertinent issue is that Helix has programming language 'grammars' available for almost every language, and they supply the syntax highlighting which you can see in purple, white and orange in the above Helix image.

However they are not included with the Helix package and must be downloaded and built as required. The 'fetch' command below fetches all the grammars which are stored in

 ~/.config/helix/runtime/grammars

Done this way it is about 2GB of source and 280 grammars!

helix --grammar fetch

helix --grammar build

Having run the first command, we now run the second, 'build', but there is a problem because Cargo can't find C++

[tp@nixos:~]$ hx --grammar build
Building 245 grammars
cargo:warning=Compiler family detection failed due to error: ToolNotFound: failed to find tool "c++": No such file or directory (os error 2)

Ok, let's try and find c++ ?


[tp@nixos:~]$ c++ <enter>

The program 'c++' is not in your PATH. It is provided by several packages.
You can make it available in an ephemeral shell by typing one of the following:
    nix-shell -p gcc
    ...

Full Nix compiler availability list

I could install C++ on myNixOS system by editing the system config file as root and building a new system configuration, but I only want to quickly build the grammars, so let's try that suggestion and run it in a temporary nix-shell ?

[tp@nixos:~]$ nix-shell -p gcc
[nix-shell:~]$
[nix-shell:~]$ hx -- grammar build

Building 245 grammars
191 grammars already built
54 grammars built now
	["alloy", "bash", "c-sharp", "caddyfile", "cairo", "clarity", "cpp", "crystal", "csv", "cue", "debian", "djot", "dunstrc", "elixir", "fennel", "fga", "fish", "ghostty", "gitcommit", "gleam", "gomod", "haskell", "html", "htmldjango", "ini", "ink", "jjdescription", "julia", "just", "kotlin", "luau", "mail", "odin", "openscad", "prolog", "properties", "pug", "purescript", "ron", "rust", "rust-format-args", "slang", "sourcepawn", "sql", "svelte", "tera", "tlaplus", "twig", "v", "vhdl", "werk", "wesl", "yara", "zig"]

[nix-shell:~]$ exit

[tp@nixos:~]$

Done, the grammars have now all been built.

Any Questions ?

Part 2