nixos_info
Retrieve accurate details about NixOS packages or options by specifying the name, type, and channel. Ensures precise system configuration guidance.
Instructions
Get detailed info about a NixOS package or option.
Args: name: Name of the package or option to look up type: Type of lookup - "package" or "option" channel: NixOS channel to search in (e.g., "unstable", "stable", "25.05")
Returns: Plain text details about the package/option or error message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | No | unstable | |
| name | Yes | ||
| type | No | package |
Implementation Reference
- mcp_nixos/server.py:456-536 (handler)The nixos_info tool handler function. It performs an exact match query on the NixOS Elasticsearch API for the specified package or option name in the given channel, then formats and returns detailed information including version, description, homepage, licenses for packages, and type, description, default, example for options.async def nixos_info(name: str, type: str = "package", channel: str = "unstable") -> str: # pylint: disable=redefined-builtin """Get detailed info about a NixOS package or option. Args: name: Name of the package or option to look up type: Type of lookup - "package" or "option" channel: NixOS channel to search in (e.g., "unstable", "stable", "25.05") Returns: Plain text details about the package/option or error message """ info_type = type # Avoid shadowing built-in if info_type not in ["package", "option"]: return error("Type must be 'package' or 'option'") channels = get_channels() if channel not in channels: suggestions = get_channel_suggestions(channel) return error(f"Invalid channel '{channel}'. {suggestions}") try: # Exact match query with correct field names field = "package_pname" if info_type == "package" else "option_name" query = {"bool": {"must": [{"term": {"type": info_type}}, {"term": {field: name}}]}} hits = es_query(channels[channel], query, 1) if not hits: return error(f"{info_type.capitalize()} '{name}' not found", "NOT_FOUND") src = hits[0].get("_source", {}) if info_type == "package": info = [] info.append(f"Package: {src.get('package_pname', '')}") info.append(f"Version: {src.get('package_pversion', '')}") desc = src.get("package_description", "") if desc: info.append(f"Description: {desc}") homepage = src.get("package_homepage", []) if homepage: if isinstance(homepage, list): homepage = homepage[0] if homepage else "" info.append(f"Homepage: {homepage}") licenses = src.get("package_license_set", []) if licenses: info.append(f"License: {', '.join(licenses)}") return "\n".join(info) # Option type info = [] info.append(f"Option: {src.get('option_name', '')}") opt_type = src.get("option_type", "") if opt_type: info.append(f"Type: {opt_type}") desc = src.get("option_description", "") if desc: # Strip HTML tags from description if "<rendered-html>" in desc: desc = desc.replace("<rendered-html>", "").replace("</rendered-html>", "") desc = re.sub(r"<[^>]+>", "", desc) desc = desc.strip() info.append(f"Description: {desc}") default = src.get("option_default", "") if default: info.append(f"Default: {default}") example = src.get("option_example", "") if example: info.append(f"Example: {example}") return "\n".join(info) except Exception as e: return error(str(e))