nixbrew

Crates.ionixbrew
lib.rsnixbrew
version0.1.0
created_at2025-11-01 21:39:26.992573+00
updated_at2025-11-01 21:39:26.992573+00
descriptionA Homebrew-like CLI for Nix's imperative package management
homepagehttps://github.com/eyuael/nixbrew
repositoryhttps://github.com/eyuael/nixbrew
max_upload_size
id1912462
size48,015
Eyuael (eyuael)

documentation

README

nixbrew

A Homebrew-like CLI for Nix's imperative package management that combines the convenience of Homebrew with Nix's declarative reproducibility.

Features

  • Install: Install packages from nixpkgs with a simple command (supports version specification)
  • Uninstall: Remove packages from your Nix profile
  • Search: Search for packages in nixpkgs
  • List: View all installed packages
  • Update: Update the nixpkgs flake
  • Upgrade: Upgrade specific packages to their latest versions
  • Versions: List all available versions of a package across different channels
  • Pin: Pin packages to specific versions with proper flake references
  • Create Flake: Generate flake.nix files for packages
  • History: View package installation history and available versions
  • Rollback: Rollback packages to previous versions

Installation

Via Nix Flake (Recommended for Nix users)

nix profile install github:eyuael/nixbrew

Via Cargo (crates.io)

cargo install nixbrew

Via GitHub Releases (Pre-built binaries)

Download the latest release from GitHub Releases for your platform:

  • macOS: nixbrew-macos-x86_64 or nixbrew-macos-aarch64
  • Linux: nixbrew-linux-x86_64
  • Windows: nixbrew-windows-x86_64.exe

After downloading, make it executable and add to your PATH:

chmod +x nixbrew
mv nixbrew /usr/local/bin/  # or another directory in your PATH

Build from Source

git clone https://github.com/eyuael/nixbrew.git
cd nixbrew
cargo build --release
sudo cp target/release/nixbrew /usr/local/bin/

Usage

Install a package

nixbrew install ripgrep
nixbrew install ripgrep 14.1.0        # Install specific version
nixbrew install ripgrep 23.11         # Install from specific channel
nixbrew install ripgrep cb82756       # Install from commit hash

Uninstall a package

nixbrew uninstall ripgrep

Search for packages

nixbrew search "text editor"

List installed packages

nixbrew list

Update nixpkgs

nixbrew update

Upgrade a package

nixbrew upgrade ripgrep

List available versions

nixbrew versions ripgrep

Pin a package to a specific version

nixbrew pin ripgrep 14.0.3

Change package version

You can change a package to a different version using any of these methods:

# Install a different version (will replace current version)
nixbrew install ripgrep 14.1.0

# Pin to a specific version
nixbrew pin ripgrep 14.0.3

# Rollback to a previously installed version
nixbrew rollback ripgrep 14.0.3

Create a flake for a package

nixbrew create-flake ripgrep
nixbrew create-flake ripgrep --version 14.0.3

View package history

nixbrew history ripgrep

Rollback to a previous version

nixbrew rollback ripgrep 14.0.3

How it works

nixbrew is a wrapper around Nix profiles that provides Homebrew-style commands. It uses nix profile commands under the hood with experimental features enabled automatically.

Version Management

  • Version Specification: Install packages with specific versions using semantic versions (e.g., "14.1.0"), channel names (e.g., "23.11"), or commit hashes
  • Semantic Version Resolution: Automatically finds the correct nixpkgs channel for specific package versions
  • Version Listing: View available versions across different nixpkgs channels
  • Version Changing: Easily switch between package versions using install, pin, or rollback commands
  • Local Registry: Tracks installed packages and their versions in ~/.nixbrew/registry.json
  • Version Caching: Caches version lookups to reduce network calls
  • Flake Generation: Creates reproducible flake.nix files for packages
  • Rollback Support: Maintains history of package installations for easy rollbacks

Directory Structure

~/.nixbrew/
├── registry.json      # Package registry with history
└── flakes/            # Generated flake files
    ├── ripgrep.flake.nix
    └── ...

Requirements

  • Nix with flakes enabled (required for using nixbrew)
  • Rust toolchain (only required if building from source or installing via cargo)
Commit count: 0

cargo fmt