- Zig 100%
neji #
A nix-env style terminal frontend for dnf5 on Fedora, written in Zig 0.16 with zero external dependencies (std + libc only).
dnf gets the job done, but its UI is plain. neji wraps the dnf5 CLI with colorized transaction plans, an fzf-style fuzzy package picker, live multi-phase progress bars, and a readable rolling log — so you always know exactly what's happening.
Features #
- Resolve before you commit — plans are resolved with
dnf5 --assumenoand shown as a colorized summary (per-section package counts, sizes) before anything is applied. - Interactive fuzzy picker —
-q/-qaopen a fzf-style picker (subsequence pre-filter + fuzzy scoring) over installed or all available packages. Enter installs (-qa) or shows info (-q); Esc cancels. Piped output falls back to plain tables. - Repo-scoped installs —
-iA <repo>.<pkg>installs a package from a specific repo (nix-env style attrs). - Parallel downloads —
-k N/--parallel Nsets dnf5'smax_parallel_downloads. - Multi-stage live progress — repo refresh spinner, concurrent download bar with per-file
name · pct · speed, and an RPM install bar, rendered over a pseudo-terminal so dnf5's real-time output is captured. - Rolling transaction log — last 40 output lines are kept; the last 8 are shown on failure.
- Confirmation prompt with default-yes (
[Y/n]), plus-y/--yesfor scripted use. - Clear failure output —
✗ Transaction failed (exit N)with the relevant log tail.
Requirements #
- Zig 0.16.0 or newer
- The
dnf5(ordnf) CLI. Detection order:/usr/bin/dnf5,/usr/sbin/dnf5,/bin/dnf5,/usr/bin/dnf,/bin/dnf. - Transactions run as root or via
sudo -n(passwordless sudo). If sudo isn't passwordless, interactive sudo is used.
Usage #
neji <flag> [args] # or a word command: install, remove, upgrade, search, list, info, sweep, clone
Flags (nix-env style):
-i <pkg>... Install packages
-iA <repo>.<pkg> Install a package from a specific repo
-e <pkg>... Erase / remove packages
-u [pkg]... Upgrade all (or specific) packages
-q [query] Query installed packages (fuzzy picker on a TTY, table when piped)
-qa [query] Query all available packages (fuzzy picker / search)
-g Garbage collect (autoremove unused packages)
-c <git-url> Clone & build a project from git
-h Show help
-V Show version
Options:
-y, --yes, --assumeyes Assume yes to all prompts
-k <N>, --parallel <N> Parallel downloads
Short flags can be combined (-iy, -uy, -gy) and -k takes an inline value (-k8).
Examples:
neji -i fzf ripgrep # install packages
neji -iA fedora.vim # install vim specifically from the fedora repo
neji -e fzf # remove a package
neji -q vim # fuzzy-pick among installed vim packages → info
neji -qa ripgrep # fuzzy-pick among all available packages → install
neji -u # upgrade all packages
neji -k8 -i fzf # install with 8 parallel downloads
neji -g # autoremove unused packages
neji -c https://github.com/user/repo # clone and build from git
Word aliases: install, remove, upgrade/update, search, list, info, sweep/autoremove, clone.
Building #
zig build # compile to zig-out/bin/neji (ReleaseSafe preferred)
zig build run # build and run
zig build test # unit tests
Testing #
zig build test runs unit tests collected from all transitively imported modules: util (fuzzy scoring, log buffer), progress (dnf5 output parsing: download/TTY/RPM lines), model (repoquery line parsing), dnf (plan parsing, PTY child output), term (key parsing), finder (matching, UTF-8 backspace), and main (flag/attr/word parsing).
Architecture #
src/
main.zig CLI entry point: nix-env style flag parsing (-i/-iA/-e/-u/-q/-qa/-g/-c/-k), word
dispatch, plan+confirm+run flow, fuzzy query (TTY vs piped), git clone+build
cli.zig Terminal I/O: color palette, ANSI SGR, width detection, confirm prompt, bar()
term.zig Raw mode, signal setup, key parser (CSI/SS3/UTF-8), alt-screen handling
finder.zig Interactive fzf-style picker: query line, fuzzy-ranked scrollable results list
dnf.zig dnf5/dnf wrapper: binary/sudo detection, repoquery + history helpers, plan parser,
process plumbing (pipes, PTY via posix_openpt), capture with timeout
model.zig Data types: Package, Plan/PlanEntry/PlanAction, HistoryTx, formatters, parsers
progress.zig Thread-shared progress state (SpinMutex) + dnf5 output parser → phases/bars
tx.zig Transaction runner: PTY child, \r/\n output split, ANSI strip, live render, log
util.zig fuzzyScore, clamp, SpinMutex, LogBuffer ring, Spinner (braille)
Key design points:
- No libdnf bindings —
nejishells out to thednf5CLI. Plans come from parsingdnf5 -y --assumeno <cmd>output; live progress comes from running the real transaction on a PTY. - PTY trick — dnf5 suppresses live progress when stdout is a pipe, so transactions run on a pseudo-terminal (
posix_openpt/grantpt/unlockpt/ptsname). Output is split on both\nand\r(progress lines update in place) and ANSI escapes are stripped before parsing. - repoquery has no JSON mode — it is driven with
--queryformatusing\x1f(unit separator) as the field delimiter;%{reponame}yields the repo display name (%{repo}stays literal). - Command-specific JSON —
history list --jsonrequires the flag after the subcommand. - Thread-shared progress —
progress.Proguses aSpinMutexso a worker can feed updates read by the renderer.
Development status #
The current implementation is a feature-complete CLI: nix-env style flags, repo-scoped installs, parallel downloads, and an interactive fuzzy package picker are all wired up and tested. The original spec (todo.md) envisions a fuller TUI — dependency trees, install history with rollback (history list/info JSON parsers already exist in dnf.zig), a system-info panel, and more — as future work.
Notes #
- Fedora's repoquery returns 100k+ rows; the picker cuts ranking cost with a cheap subsequence pre-filter before fuzzy scoring (top 200 results).
- No external dependencies; std + libc only.