feat: project structure and nix build setup
- Add CLI entry point with urfave/cli/v2 (serve, index, list, search commands) - Add database interface and implementations for PostgreSQL and SQLite - Add schema versioning with automatic recreation on version mismatch - Add MCP protocol types and server scaffold - Add NixOS option types - Configure flake.nix with devShell and buildGoModule package Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
99
cmd/nixos-options/main.go
Normal file
99
cmd/nixos-options/main.go
Normal file
@@ -0,0 +1,99 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := &cli.App{
|
||||
Name: "nixos-options",
|
||||
Usage: "MCP server for NixOS options search and query",
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
Name: "serve",
|
||||
Usage: "Run MCP server (stdio)",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "database",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Database connection string (postgres://... or sqlite://...)",
|
||||
EnvVars: []string{"NIXOS_OPTIONS_DATABASE"},
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
fmt.Println("MCP server not yet implemented")
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "index",
|
||||
Usage: "Index a nixpkgs revision",
|
||||
ArgsUsage: "<revision>",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "database",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Database connection string",
|
||||
EnvVars: []string{"NIXOS_OPTIONS_DATABASE"},
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
if c.NArg() < 1 {
|
||||
return fmt.Errorf("revision argument required")
|
||||
}
|
||||
fmt.Printf("Indexing revision: %s\n", c.Args().First())
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "list",
|
||||
Usage: "List indexed revisions",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "database",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Database connection string",
|
||||
EnvVars: []string{"NIXOS_OPTIONS_DATABASE"},
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
fmt.Println("List revisions not yet implemented")
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "search",
|
||||
Usage: "Search for options",
|
||||
ArgsUsage: "<query>",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "database",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Database connection string",
|
||||
EnvVars: []string{"NIXOS_OPTIONS_DATABASE"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "revision",
|
||||
Aliases: []string{"r"},
|
||||
Usage: "Revision to search (default: nixos-stable)",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
if c.NArg() < 1 {
|
||||
return fmt.Errorf("query argument required")
|
||||
}
|
||||
fmt.Printf("Searching for: %s\n", c.Args().First())
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user