nixos_info
Retrieve detailed information about NixOS packages and configuration options to verify specifications and prevent configuration errors.
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 |
|---|---|---|---|
| name | Yes | ||
| type | No | package | |
| channel | No | unstable |
Implementation Reference
- mcp_nixos/server.py:456-536 (handler)The nixos_info tool handler function. It performs an exact lookup for a NixOS package or option using the Elasticsearch API on search.nixos.org, formats the results as plain text with details like version, description, homepage, license (for packages) or 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))