feature/nixpkgs-search #5

Merged
torjus merged 6 commits from feature/nixpkgs-search into master 2026-02-04 17:07:31 +00:00
Owner

Summary

This PR introduces nixpkgs-search, a new combined MCP server that provides both NixOS options search and Nix package search functionality from a single binary. This replaces nixos-options as the primary/recommended server.

New Features

Nix Package Search

  • New nixpkgs-search packages serve MCP server for searching nixpkgs packages
  • search_packages tool - full-text search across package names and descriptions
  • get_package tool - retrieve full package metadata (version, license, maintainers, etc.)
  • Filter by broken, unfree, or insecure status
  • Relevance-ranked results prioritizing exact matches

Combined Indexing

  • nixpkgs-search index <revision> indexes both options and packages in one command
  • --no-packages / --no-options flags for partial indexing
  • Shared database schema (version 3) with new packages table

NixOS Module

  • New nixpkgs-search-mcp NixOS module for deployment
  • Runs separate systemd services for options (port 8082) and packages (port 8083)
  • options.enable and packages.enable flags (both default to true)
  • indexFlags option for customizing indexing behavior
  • Shared database configuration and indexing service

Changes

  • Database: Schema version 3 with packages table, FTS indexes for both SQLite and PostgreSQL
  • MCP Server: New ServerMode concept supporting options/packages tool sets
  • Search Ranking: Improved relevance with exact match prioritization before FTS ranking
  • Documentation: Updated README and CLAUDE.md for new primary server
  • Flake: nixpkgs-search is now the default package and module

Breaking Changes

None - nixos-options and hm-options continue to work as before. They are now marked as legacy in documentation.

Test Plan

  • All existing tests pass (go test ./... -short)
  • Linting passes (golangci-lint run ./...)
  • No vulnerabilities (govulncheck ./...)
  • nix flake check passes
  • Manual testing of package search with relevance ranking
## Summary This PR introduces `nixpkgs-search`, a new combined MCP server that provides both NixOS options search and Nix package search functionality from a single binary. This replaces `nixos-options` as the primary/recommended server. ### New Features **Nix Package Search** - New `nixpkgs-search packages serve` MCP server for searching nixpkgs packages - `search_packages` tool - full-text search across package names and descriptions - `get_package` tool - retrieve full package metadata (version, license, maintainers, etc.) - Filter by `broken`, `unfree`, or `insecure` status - Relevance-ranked results prioritizing exact matches **Combined Indexing** - `nixpkgs-search index <revision>` indexes both options and packages in one command - `--no-packages` / `--no-options` flags for partial indexing - Shared database schema (version 3) with new `packages` table **NixOS Module** - New `nixpkgs-search-mcp` NixOS module for deployment - Runs separate systemd services for options (port 8082) and packages (port 8083) - `options.enable` and `packages.enable` flags (both default to true) - `indexFlags` option for customizing indexing behavior - Shared database configuration and indexing service ### Changes - **Database**: Schema version 3 with packages table, FTS indexes for both SQLite and PostgreSQL - **MCP Server**: New `ServerMode` concept supporting options/packages tool sets - **Search Ranking**: Improved relevance with exact match prioritization before FTS ranking - **Documentation**: Updated README and CLAUDE.md for new primary server - **Flake**: `nixpkgs-search` is now the default package and module ### Breaking Changes None - `nixos-options` and `hm-options` continue to work as before. They are now marked as legacy in documentation. ## Test Plan - [x] All existing tests pass (`go test ./... -short`) - [x] Linting passes (`golangci-lint run ./...`) - [x] No vulnerabilities (`govulncheck ./...`) - [x] `nix flake check` passes - [x] Manual testing of package search with relevance ranking
torjus added 6 commits 2026-02-04 17:06:09 +00:00
Add a new nixpkgs-search CLI that combines NixOS options search with
Nix package search functionality. This provides two MCP servers from
a single binary:
- `nixpkgs-search options serve` for NixOS options
- `nixpkgs-search packages serve` for Nix packages

Key changes:
- Add packages table to database schema (version 3)
- Add Package type and search methods to database layer
- Create internal/packages/ with indexer and parser for nix-env JSON
- Add MCP server mode (options/packages) with separate tool sets
- Add package handlers: search_packages, get_package
- Create cmd/nixpkgs-search with combined indexing support
- Update flake.nix with nixpkgs-search package (now default)
- Bump version to 0.2.0

The index command can index both options and packages together, or
use --no-packages/--no-options flags for partial indexing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add NixOS module for deploying nixpkgs-search as systemd services:
- Runs separate MCP servers for options (port 8082) and packages (port 8083)
- Shared database configuration (SQLite or PostgreSQL)
- Separate indexing service that runs before servers start
- options.enable and packages.enable flags (both default to true)
- indexFlags option for customizing index command (--no-packages, etc.)

Also update flake.nix:
- Register new module as nixpkgs-search-mcp
- Set as default nixosModule

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Document nixpkgs-search as the primary MCP server
- Add package search CLI examples and MCP tools
- Update installation and usage examples
- Add nixpkgs-search-mcp NixOS module documentation
- Mark nixos-options as legacy
- Update environment variable documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update .mcp.json to use nixpkgs-search options/packages servers
- Update CLAUDE.md example to use nixpkgs-search

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The nixpkgs-packages feature has been implemented in nixpkgs-search.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Package search now prioritizes results in this order:
1. Exact pname match
2. Exact attr_path match
3. pname starts with query
4. attr_path starts with query
5. FTS ranking (bm25 for SQLite, ts_rank for PostgreSQL)

This ensures searching for "git" returns the "git" package first,
rather than packages that merely mention "git" in their description.

Also update CLAUDE.md to clarify using `nix run` instead of
`go build -o` for testing binaries.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
torjus merged commit 0bd4ed778a into master 2026-02-04 17:07:31 +00:00
torjus deleted branch feature/nixpkgs-search 2026-02-04 17:07:31 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: torjus/labmcp#5