npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nix-run

v0.2.1

Published

A Node.js library and CLI tool to run Nix packages and expressions easily. Provides a full programmatic interface to the Nix package manager, allowing JavaScript/TypeScript applications to run packages, evaluate expressions, query nixpkgs, and work with

Readme

nix-run

A Node.js library and CLI tool to run Nix packages and expressions easily.
Provides a full programmatic interface to the Nix package manager, allowing JavaScript/TypeScript applications to run packages, evaluate expressions, query nixpkgs, and work with Nix flakes.


✨ Features

  • Run Nix Packages – Execute binaries from nixpkgs or custom flakes.
  • Version Pinning – Select specific versions like nodejs:20.
  • Expression Evaluation – Evaluate Nix expressions (JSON or raw).
  • Package Search – Search nixpkgs programmatically.
  • Flake Support – List apps, read metadata, run flake apps.
  • Caching Layer – Cache store paths + metadata.
  • CLI Tool – Use nix-run directly from the terminal.
  • TypeScript – Fully typed APIs.

📦 Installation

Requirements

  • Node.js 18+
  • Nix installed (https://nixos.org/download)

Install via npm

npm install nix-run

For development:

git clone https://github.com/Viswesh934/nix-run.git
cd nix-run
npm install
npm run build

🚀 Quick Start

Run a Nix package (programmatically)

import { nixRun } from "nix-run";

const result = await nixRun("hello", [], { stream: false });
console.log(result.stdout); // → "Hello, world!"

CLI Usage

# Run a package
npx nix-run hello

# With arguments
npx nix-run ripgrep -- --help

📘 API Reference

nixRun(pkg, args, options)

Runs a nix package and returns { stdout, stderr, code }.

await nixRun("hello");
await nixRun("ripgrep", ["--version"]);
await nixRun("nodejs:20", ["--version"]);

NixExpression

Evaluate inline or file-based Nix expressions.

const expr = new NixExpression();
const result = await expr.eval("1 + 1");   // "2"
const json = await expr.evalJSON('{ a = 10; }');
// → { a: 10 }

NixQuery

Search and resolve nixpkgs.

const query = new NixQuery();
const results = await query.search("ripgrep");
const storePath = await query.resolveStorePath("coreutils");

NixFlake

Work with Nix flakes.

const flake = new NixFlake();

const meta = await flake.show("github:NixOS/nixpkgs");
const apps = await flake.listApps(".");
const run = await flake.runApp(".", "myapp");

🖥 CLI Usage

# Run packages
nix-run hello
nix-run nodejs -- --version
nix-run ripgrep -- --help

# With version pinning
nix-run nodejs:20 -- --version

📁 Project Structure

nix-run/
│
├── src/
│   ├── index.ts
│   ├── nixRun.ts
│   ├── nixVersion.ts
│   ├── nixUtils.ts
│   ├── nixExpression.ts
│   ├── nixDetect.ts
│   ├── nixQuery.ts
│   ├── nixFlake.ts
│   ├── nixShell.ts
│   ├── nixCache.ts
│   ├── utils/
│   │   ├── exec.ts
│   │   ├── logger.ts
│   │   └── env.ts
│   └── cli.ts
│
├── bin/          # CLI entrypoint
├── examples/
├── test/
├── docs/
└── .nix-runner/  # Cache directory

🧪 Testing

npm test

Tests requiring Nix are skipped automatically if Nix is not installed.


🤝 Contributing

Feel free to open issues or PRs.


📄 License

MIT — see LICENSE.


🔗 Related