Skip to content

Instantly share code, notes, and snippets.

@mausch
Last active February 27, 2026 08:53
Show Gist options
  • Select an option

  • Save mausch/d64942808b64042da1dafb66e1f31032 to your computer and use it in GitHub Desktop.

Select an option

Save mausch/d64942808b64042da1dafb66e1f31032 to your computer and use it in GitHub Desktop.
colgrep.nix
{
description = "ColGREP - Semantic code search powered by ColBERT";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/2fc6539b481e1d2569f25f8799236694180c0993";
flake-utils.url = "github:numtide/flake-utils/11707dc2f618dd54ca8739b309ec4fc024de578b";
rust-overlay = {
url = "github:oxalica/rust-overlay/9b2965450437541d25fde167d8bebfd01c156cef";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.stable.latest.default;
# Platform-specific features
features = if pkgs.stdenv.isDarwin then
[ "accelerate" "coreml" ]
else if pkgs.stdenv.isLinux then
[ "openblas" ]
else
[ ];
# Platform-specific build inputs
darwinBuildInputs = with pkgs; lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Accelerate
darwin.apple_sdk.frameworks.CoreML
darwin.apple_sdk.frameworks.Foundation
];
linuxBuildInputs = with pkgs; lib.optionals stdenv.isLinux [
openblas
onnxruntime # needed at link time and at runtime via ORT_DYLIB_PATH
];
in
{
packages.default = pkgs.rustPlatform.buildRustPackage rec {
pname = "colgrep";
version = "1.0.8";
src = pkgs.fetchFromGitHub {
owner = "lightonai";
repo = "next-plaid";
rev = "v${version}";
hash = "sha256-Sq7QxCd7JGM2JglraKq23yLYCdN+ZqaPOtEKW13JSB0=";
};
cargoHash = "sha256-QZ/yF/FeKs3VNFCQX5vJjgkOXXbO2LcPA18eTQvr/lo=";
# Build only colgrep binary
cargoBuildFlags = [ "-p" "colgrep" ] ++
pkgs.lib.optionals (features != []) [ "--features" (pkgs.lib.concatStringsSep "," features) ];
nativeBuildInputs = with pkgs; [
pkg-config
rustToolchain
makeWrapper # needed for wrapProgram in postInstall
];
buildInputs = with pkgs; [
openssl
] ++ darwinBuildInputs ++ linuxBuildInputs;
# Wrap the binary on Linux so ORT_DYLIB_PATH always points at the
# Nix-store copy of libonnxruntime. This bypasses colgrep's built-in
# download logic and avoids the pre-built .so / glibc mismatch that
# causes a silent exit-101 crash under Nix.
postInstall = pkgs.lib.optionalString pkgs.stdenv.isLinux ''
wrapProgram $out/bin/colgrep \
--set ORT_DYLIB_PATH "${pkgs.onnxruntime}/lib/libonnxruntime.so"
'';
# Skip tests since they may require network access or large models
doCheck = false;
meta = with pkgs.lib; {
description = "Semantic code search for your terminal, built on NextPlaid";
homepage = "https://github.com/lightonai/next-plaid";
license = licenses.asl20;
maintainers = [ ];
mainProgram = "colgrep";
};
};
# Convenience aliases
packages.colgrep = self.packages.${system}.default;
apps.default = {
type = "app";
program = "${self.packages.${system}.default}/bin/colgrep";
};
}
);
}
@mausch
Copy link
Author

mausch commented Feb 16, 2026

https://github.com/lightonai/next-plaid

Usage:

nix run --refresh --no-write-lock-file git+https://gist.github.com/mausch/d64942808b64042da1dafb66e1f31032.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment