Nix Agent
Overview
Use this skill for direct NixOS execution tasks through nix-agent and mcp-nixos. Use mcp-nixos for discovery, use nix-agent for local mutation and activation. Do not detour into generic brainstorming for operational tasks.
When to Use
- A user asks to install a package on NixOS.
- A user asks which option to use, then wants it applied.
- A user asks to patch local NixOS config through MCP tools.
- The host exposes both
nix-agentandmcp-nixos.
Do not use this skill for writing secret payloads or for broad architecture/design requests.
Tool Surface
nix-agent exposes exactly two tools:
inspect_state(path)– read a local file.apply_patch_set(patch_set, flake_uri=None, mode="nixos")– write each patch, format any.nixfiles, and (whenflake_uriis provided) validate then switch.mode="nixos"(default):sudo nixos-rebuild dry-activate→switch.mode="home-manager":home-manager build→home-manager switch(no sudo).- Returns
changed_files,rollback_generation,current_generation, command outputs, andstatus.
mcp-nixos is responsible for package and option discovery.
Required Workflow
- If the request needs package or option discovery, query
mcp-nixosfirst. - Optionally
inspect_state(path)on any file you intend to modify. - Build a
PatchSetofPatch(path, content)entries. - Call
apply_patch_set(patch_set, flake_uri=..., mode=...)in a single round-trip. Passmode="home-manager"for user-level Home Manager configs; defaultmode="nixos"for system configs. - Report:
- the
changed_files - the final
status - the
rollback_generation(so the user can recover withsudo nixos-rebuild switch --rollbackif needed) - any non-empty
dry_activate_output/switch_output
- the
If status is validation_failed or switch_failed, stop and surface first_error (the extracted first error: line) and the relevant output field instead of retrying blindly.
You can also call apply_patch_set with an empty PatchSet (no patches) plus a flake_uri to trigger a rebuild against the current flake state without writing any files — useful after manual edits.
Common Mistakes
- Starting a generic brainstorming/design workflow for a simple package install.
- Skipping
mcp-nixosand guessing package names or option paths. - Calling
apply_patch_setwithoutflake_uriwhen the user actually wants the change applied. - Writing secret material through patches.
- Re-running
apply_patch_setafter a failure without inspecting the dry-activate output.
Example
User: Use mcp-nixos and nix-agent together to install floorp on my NixOS system.
- Query
mcp-nixosfor the correct Floorp package attribute. - Build a
PatchSetthat addspkgs.floorpto the relevant module. - Call
apply_patch_set(patch_set, flake_uri="/etc/nixos#hostname"). - Report
changed_files,status, androllback_generation.