Skip to content

dominicnunez/mgrep-nix

Repository files navigation

mgrep-nix

Nix flake for mgrep - a calm, CLI-native way to semantically grep everything, like code, images, PDFs and more.

Features:

  • Direct npm packaging from Mixedbread's official distribution
  • Smart Home Manager detection with automatic symlink management
  • Pre-built binaries via Garnix for instant installation
  • Daily automated updates for new mgrep versions
  • Linux and macOS support (x86_64 and aarch64)

Quick Start

Try without installing:

nix run github:dominicnunez/mgrep-nix

Install to your profile:

nix profile add github:dominicnunez/mgrep-nix

Binary Cache

This flake uses Garnix for CI and binary caching. The nixConfig in flake.nix automatically configures the cache, so pre-built binaries are fetched without any manual setup.

If prompted to allow configuration from the flake, answer yes or add accept-flake-config = true to your Nix configuration.

Flake Usage

As a Flake Input

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    mgrep-nix.url = "github:dominicnunez/mgrep-nix";
  };

  outputs = { self, nixpkgs, mgrep-nix, ... }: {
    # Your configuration here
  };
}

NixOS Configuration

{ inputs, pkgs, ... }:
{
  environment.systemPackages = [
    inputs.mgrep-nix.packages.${pkgs.system}.default
  ];
}

Home Manager Configuration

{ inputs, pkgs, ... }:
{
  home.packages = [
    inputs.mgrep-nix.packages.${pkgs.system}.default
  ];
}

Using the Overlay

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    mgrep-nix.url = "github:dominicnunez/mgrep-nix";
  };

  outputs = { self, nixpkgs, mgrep-nix, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        overlays = [ mgrep-nix.overlays.default ];
      };
    in {
      # pkgs.mgrep is now available
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = [ pkgs.mgrep ];
      };
    };
}

Home Manager Integration

This package includes smart Home Manager detection. When Home Manager is detected, the package skips creating symlinks to respect your declarative configuration.

Detection methods:

  • HM_SESSION_VARS environment variable is set
  • ~/.config/home-manager directory exists
  • /etc/profiles/per-user/$USER directory exists

Behavior:

  • Home Manager detected: Skips symlink creation and cleans up any orphaned symlinks
  • Home Manager absent: Creates ~/.local/bin/mgrep symlink for convenience

Automatic cleanup: If you previously installed mgrep standalone (creating a ~/.local/bin/mgrep symlink) and later enable Home Manager, the package will automatically remove the orphaned symlink on first run to prevent PATH conflicts.

Environment Variables

Variable Description
MGREP_NIX_VERBOSE Set to 1 to enable Home Manager detection and symlink management messages

Example:

export MGREP_NIX_VERBOSE=1

Updating

If using nix profile add:

nix profile upgrade '.*mgrep.*'

If using as a flake input:

nix flake update mgrep-nix
nixos-rebuild switch  # or home-manager switch

Contributing

Development Setup

git clone https://github.com/dominicnunez/mgrep-nix
cd mgrep-nix
nix develop  # enters shell with dev tools
nix build
./result/bin/mgrep --version

Update Workflow

The update.sh script checks for new mgrep releases and updates version.json:

# Enter dev shell (provides required tools)
nix develop

# Check for updates (dry run)
./update.sh

# Update to latest version
./update.sh --update

The script:

  1. Queries npm registry for the latest release
  2. Compares against current version in version.json
  3. With --update: fetches hashes and updates version.json

Automated Updates

A GitHub Actions workflow runs daily to check for new releases. When a new version is found, it automatically:

  1. Updates version.json with new version and hashes
  2. Validates with nix flake check
  3. Pushes directly to main

Repository Structure

.
├── flake.nix           # Flake definition with outputs
├── flake.lock          # Locked dependencies
├── package.nix         # mgrep package derivation
├── package-lock.json   # npm lockfile for reproducible builds
├── version.json        # Current version and hashes
├── update.sh           # Update detection and hash fetching script
├── README.md           # This file
├── garnix.yaml         # Garnix CI configuration
└── .github/workflows/
    ├── update.yml      # Daily update workflow
    └── ci.yml          # Garnix build validation

License

This packaging is MIT-licensed.

mgrep is developed by Mixedbread. See their terms of service for usage terms.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors