85.5. helix-25.07.1
Modal terminal text editor with tree-sitter syntax and language-server support (Rust)
| Version | 25.07.1, release 1 |
| Shelf | editors — Text editors, IDEs, notebooks and REPLs |
| Phase | 41_system (System), 452 of 1047 in build order |
| Licence | MPL-2.0 |
| Homepage | https://helix-editor.com/ |
| Build time | 9.3 SBU |
| Installed size | 215.3 MiB in 1232 files |
| Recipe | ports/core/editors/helix/kpkgbuild |
About
helix, the hx command, is a modal text editor for the terminal, in the line of vi and Kakoune. It highlights and selects by syntax with tree-sitter grammars and talks to language servers, both with no plugins to install. KDOS builds it as a host program, beside micro and neovim; it is not on the installation image, and sudo kdos update install helix adds it. The theme generators (kdos theme) write ~/.config/helix/themes/kdos.toml for it; helix uses that theme only once theme = "kdos" is set in its config.toml (see Theming).
It is a Rust program built with cargo from its vendor bundle, the second sha256 = line (see Vendoring). The port installs hx, its runtime directory (grammars, queries, themes and the tutor) at /usr/lib/helix/runtime, and a desktop entry with Terminal=true, since upstream ships none for a terminal program (see Desktop entries belong to the port).
Sources
helix-25.07.1.tar.xz(162.2 MiB)
sha2562d0cf264ac77f8c25386a636e2b3a09a23dec555568cc9a5b2927f84322f544e
upstream: https://github.com/helix-editor/helix/releases/download/25.07.1/helix-25.07.1-source.tar.xz
archive copy: sources-2/editors--helix-25.07.1.tar.xzhelix-vendor-25.07.1.tar.xz(21.4 MiB)
sha2565f5364eb9f7788127864f553c4e4ddf55bba5f1295a78378918b2043f31d0307
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-2/editors--helix-vendor-25.07.1.tar.xz
Dependencies
Required by: no port names it.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install helix'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/editors/helix.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/editors/helix
echo '2d0cf264ac77f8c25386a636e2b3a09a23dec555568cc9a5b2927f84322f544e helix-25.07.1.tar.xz' | sha256sum -c -
echo '5f5364eb9f7788127864f553c4e4ddf55bba5f1295a78378918b2043f31d0307 helix-vendor-25.07.1.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/helix
SRC=$SRC_ROOT/helix-25.07.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf helix-25.07.1.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export HELIX_DEFAULT_RUNTIME=/usr/lib/helix/runtime
export HELIX_DISABLE_AUTO_GRAMMAR_BUILD=1
export RUSTFLAGS="-C target-feature=-crt-static"
cargo build --release --frozen --offline
CARGO_MANIFEST_DIR="$PWD/helix-term" target/release/hx --grammar build
test -f runtime/grammars/rust.so
install -Dm755 target/release/hx $PKG/usr/bin/hx
install -d $PKG/usr/lib/helix
cp -r runtime $PKG/usr/lib/helix/
rm -rf $PKG/usr/lib/helix/runtime/grammars/sources
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/hx.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Editor (helix)
GenericName=Text Editor
Comment=Edit text with helix
Exec=hx %F
Icon=text-x-generic
Terminal=true
Categories=Utility;TextEditor;Development;
Keywords=editor;text;code;helix;hx;
EOF
chmod 644 "$PKG/usr/share/applications/hx.desktop"
The switches, and why each is set:
HELIX_DEFAULT_RUNTIME=/usr/lib/helix/runtime— read byhelix-loaderat compile time and built intohxas the last runtime directory it searches, after~/.config/helix/runtimeand$HELIX_RUNTIME. Without it the one system directoryhxsearches isruntimebeside its own binary,/usr/bin/runtime, and it starts with no grammars or themes unless a wrapper or a global variable points it elsewhere.HELIX_DISABLE_AUTO_GRAMMAR_BUILD=1— stopshelix-term’s build script from fetching the grammars with git and compiling them duringcargo build. The fetch needs the network, which the build does not have; the grammars are compiled in a separate step instead.-C target-feature=-crt-static— linkshxdynamically against musl’slibc.so. Rust’s musl target links statically otherwise, and a static musl program cannotdlopen, which is howhxloads every grammar.RUSTFLAGSreplaces therustflagsof a.cargo/config.tomlrather than adding to them, so the flag has to be given here (see rust).--grammar build— compiles every grammarlanguages.tomlnames into a.sounderruntime/grammars, with the C compiler the tree’sCCnames, from the grammar sources the release’s source tarball carries underruntime/grammars/sources.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/helix, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf helix-25.07.1-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/helix, and runs the triggers its paths call for.
Contents
Installed programs: hx.
Installed directories: /usr/lib/helix, /usr/share/licenses/helix.
Notes
hx --grammar build writes into the first runtime directory in its search order, and that is the user’s ~/.config/helix/runtime unless CARGO_MANIFEST_DIR is set, in which case it is the runtime directory beside the named crate’s parent. The build sets it to helix-term in the source tree so the grammars land in the tree’s own runtime/ before it is copied into $PKG. The test -f runtime/grammars/rust.so after it fails the build at once if they went anywhere else, rather than shipping a runtime with no grammars. Building the grammars also checks that a git program is on the PATH before it compiles anything, even though it fetches nothing, which is why git is in depends. The grammar sources are removed from $PKG after the copy; only the compiled grammars and the queries ship.
The vendor bundle carries a .cargo/config.toml of its own, which replaces the one in the source tree when it is unpacked. Upstream’s sets --cfg tokio_unstable, which only helix’s tests use, so dropping it changes nothing in the editor.