Skip to content

Terminal utility for looking up Nix store paths in binary caches and viewing their NAR info

License

Notifications You must be signed in to change notification settings

NotAShelf/narnia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

narnia

Terminal utility built with ncurses for looking up Nix store paths in binary caches and viewing their NAR info metadata.

Features

  • Very small binary (< 30kb)
  • Interactive TUI for browsing narinfo contents
  • Support for multiple binary caches
  • Direct executable lookup without prompts
  • Clipboard integration for copying narinfo lines

Usage

# Interactive mode
narnia

# Direct lookup
narnia /nix/store/path/to/executable # absolute path
narnia git # from PATH

# With additional caches
narnia -c https://mycache.cachix.org git
narnia -c https://cache1.example.com -c https://cache2.example.com

Options

-c, --cache URL    Add cache URL (can be used multiple times)
-h, --help         Show help message

Controls

Narnia provides a set of keyboard controls while you are in the interactive TUI.

  • Tab/Shift-Tab: Switch between cache results
  • Up/Down: Navigate narinfo lines
  • PgUp/PgDn: Jump pages
  • Enter: Copy selected line to clipboard
  • r: Retry with new input
  • q: Quit

Cache Resolution

The tool automatically uses https://cache.nixos.org as the default cache. Additional caches can be specified with the -c flag and will be queried in the order provided.

For executables found in PATH, the tool resolves the full Nix store path, extracts the hash, and queries each cache for the corresponding nar info file.

Building

Dependencies

This program depends on curl for network requests and ncurses for the terminal UI. Narnia used to depend on libclipboard, but it has proven ineffective on Wayland systems and has been replaced with a local implementation for cross-protocol copy feature.

  • libcurl
  • ncurses

Once you confirm that you have acquired the relevant dependencies, build with Zig.

zig build -Doptimize=ReleaseSmall

This will automatically optimize the binary for release, with a focus on smaller binary sizes. You may experiment with release modes if you'd like, e.g., a "faster" binary but the speed doesn't seem to change much.

You can, of course, choose to build with gcc if that is what you prefer.

gcc -o narnia main.c -lcurl -lncurses -lclipboard

Installing

The recommended way of using and installing Narnia is through the Nix build tool. This much should be obvious since it is, well, to query Nix Archives (NARs). In most cases you are recommended to use one of

  1. nix profile add
  2. environment.systemPackages

using the flake provided by this repository in order to make the narnia command available in your system. In the case you want to install this tool through traditional means, you may run:

zig build install --prefix /usr/local

About

Terminal utility for looking up Nix store paths in binary caches and viewing their NAR info

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published