nix-idioms

Guides writing, refactoring, and reviewing Nix expressions against version-pinned official practices.

Updated Jul 4, 2023
One-click install
npx skills add https://github.com/kohdice/dotfiles --skill nix-idioms-kohdice
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nix-idioms
Source: https://github.com/kohdice/dotfiles/tree/main/config/agents/skills/nix-idioms
Command: npx skills add https://github.com/kohdice/dotfiles --skill nix-idioms-kohdice

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Nix code often breaks or emits deprecation warnings because recommendations ignore the project's pinned Nix evaluator version and nixpkgs release. This Skill resolves the exact project baseline first, then applies a version-tagged catalog of official idioms so every suggestion is valid for the pinned toolchain. ## Core Features & Use Cases - Baseline Resolution: Detects the Nix evaluator version, nixpkgs pin from flake.lock or npins, evaluation mode, and module consumer (NixOS, Home Manager, nix-darwin) before emitting any code. - Version-Tagged Idiom Catalog: Covers removed and deprecated constructs (e.g. cargoSha256, lib.mdDoc, substituteInPlace --replace) and modern facilities (finalAttrs, SRI hashes, lib.fileset, pkgs/by-name) with the exact release that introduced or removed each. - Structured Review Reports: Produces findings tagged [error], [warn], [recommend], or [gated-option], each citing the authority and version it rests on. - Use Case: When modernizing a flake-based dotfiles repository pinned to nixpkgs-unstable, the Skill flags deprecated aliases relative to that pin and suggests replacements like hash over sha256 without ever recommending APIs above the baseline. ## Quick Start Ask the AI to review or refactor a Nix file in this repository using the nix-idioms skill and report findings against the pinned nixpkgs baseline.

Frequently Asked Questions about nix-idioms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I modernize Nix code without breaking a pinned nixpkgs version?▼

Resolve the project baseline first: the Nix evaluator version, the nixpkgs pin from flake.lock, and the evaluation mode. Then apply only idioms whose introducing release is at or below that pin, and present newer options as gated alternatives labeled with the required version.

How to review a Nix flake for deprecated constructs?▼

Check the pinned nixpkgs release against the version-tagged deprecation catalog, covering entries like cargoSha256 (removed 25.05), lib.mdDoc (removed 24.11), and substituteInPlace --replace (deprecated 24.05). Tag each finding by severity and cite the release that changed the construct.

Does the skill support Home Manager and nix-darwin modules?▼

Yes, it covers NixOS, Home Manager, and nix-darwin module idioms, including mkIf versus plain if conditionals, mkMerge, and stateVersion handling. State versions gate stateful defaults only and are never bumped during modernization.

Can I use pipe operators or new builtins in a flake project?▼

Only if the project has enabled the corresponding experimental feature. A flake project enables nix-command and flakes only; pipe-operators and fetch-tree remain experimental in Nix 2.35.2, and builtins introduced after the installed evaluator version must not be used.

What happens when the pinned nixpkgs is newer than the skill catalog?▼

A staleness guard triggers: the skill reads official release notes between the coverage point (Nix 2.35.2, nixpkgs 26.05) and the actual version, follows the newer recommendations, and reports that the catalog needs updating.