feat: add nixpkgs-search binary with package search support
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>
This commit is contained in:
@@ -8,12 +8,13 @@ import (
|
||||
|
||||
// Revision represents an indexed nixpkgs revision.
|
||||
type Revision struct {
|
||||
ID int64
|
||||
GitHash string
|
||||
ChannelName string
|
||||
CommitDate time.Time
|
||||
IndexedAt time.Time
|
||||
OptionCount int
|
||||
ID int64
|
||||
GitHash string
|
||||
ChannelName string
|
||||
CommitDate time.Time
|
||||
IndexedAt time.Time
|
||||
OptionCount int
|
||||
PackageCount int
|
||||
}
|
||||
|
||||
// Option represents a NixOS configuration option.
|
||||
@@ -48,6 +49,24 @@ type File struct {
|
||||
LineCount int
|
||||
}
|
||||
|
||||
// Package represents a Nix package from nixpkgs.
|
||||
type Package struct {
|
||||
ID int64
|
||||
RevisionID int64
|
||||
AttrPath string // e.g., "python312Packages.requests"
|
||||
Pname string // Package name
|
||||
Version string
|
||||
Description string
|
||||
LongDescription string
|
||||
Homepage string
|
||||
License string // JSON array
|
||||
Platforms string // JSON array
|
||||
Maintainers string // JSON array
|
||||
Broken bool
|
||||
Unfree bool
|
||||
Insecure bool
|
||||
}
|
||||
|
||||
// DeclarationWithMetadata includes declaration info plus file metadata.
|
||||
type DeclarationWithMetadata struct {
|
||||
Declaration
|
||||
@@ -79,6 +98,15 @@ type SearchFilters struct {
|
||||
Offset int
|
||||
}
|
||||
|
||||
// PackageSearchFilters contains optional filters for package search.
|
||||
type PackageSearchFilters struct {
|
||||
Broken *bool
|
||||
Unfree *bool
|
||||
Insecure *bool
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
|
||||
// Store defines the interface for database operations.
|
||||
type Store interface {
|
||||
// Schema operations
|
||||
@@ -111,4 +139,11 @@ type Store interface {
|
||||
CreateFilesBatch(ctx context.Context, files []*File) error
|
||||
GetFile(ctx context.Context, revisionID int64, path string) (*File, error)
|
||||
GetFileWithRange(ctx context.Context, revisionID int64, path string, r FileRange) (*FileResult, error)
|
||||
|
||||
// Package operations
|
||||
CreatePackage(ctx context.Context, pkg *Package) error
|
||||
CreatePackagesBatch(ctx context.Context, pkgs []*Package) error
|
||||
GetPackage(ctx context.Context, revisionID int64, attrPath string) (*Package, error)
|
||||
SearchPackages(ctx context.Context, revisionID int64, query string, filters PackageSearchFilters) ([]*Package, error)
|
||||
UpdateRevisionPackageCount(ctx context.Context, id int64, count int) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user