nix-naming

Enforces kebab-case naming conventions and attribute organization for Nix code.

1|Updated Aug 21, 2023
One-click install
npx skills add https://github.com/jmuchovej/homelab --skill nix-naming-jmuchovej
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nix-naming
Source: https://github.com/jmuchovej/homelab/tree/main/src/modules/ai-tools/skills/nix-naming
Command: npx skills add https://github.com/jmuchovej/homelab --skill nix-naming-jmuchovej

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Inconsistent naming and disorganized attributes make Nix configurations hard to read and maintain. This Skill provides clear conventions for naming variables, files, and constants, plus patterns for structuring Nix modules. ## Core Features & Use Cases - Naming Conventions: Defines kebab-case for variables and files, UPPER_CASE for constants, with correct and incorrect examples. - The cfg Pattern: Standardizes the let cfg = config... pattern combined with lib.mkIf for conditional module configuration. - Attribute Organization: Guides grouping options before config, ordering related settings, and preferring flat dot-notation over deep nesting. - Use Case: When writing a new NixOS or home-manager module, apply these rules to name files like my-service.nix, structure options and config blocks consistently, and format with nixfmt. ## Quick Start Review my Nix module and rename any variables or files that do not follow kebab-case conventions.

Frequently Asked Questions about nix-naming

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

FAQPage Schema
What naming convention should I use for Nix variables?

Use kebab-case for Nix variables, such as `user-name`, `server-hostname`, and `enable-auto-start`. Avoid camelCase, snake_case, and PascalCase, which are considered incorrect in this style guide.

How do I name Nix files and directories?

Name Nix files and directories in kebab-case, for example `my-module.nix` or `window-managers/`. Names like `myApp.nix` or `my_service.nix` violate the convention.

What is the cfg pattern in Nix modules?

The cfg pattern binds `cfg = config.namespace.module` in a let block, then applies settings with `config = lib.mkIf cfg.enable { ... }`. It keeps module configuration conditional and concise.

How should I organize attributes in a Nix module?

Place options first, then config. Within config, group related settings such as programs together, list packages afterward, and prefer flat dot-notation like `services.nginx.enable = true` over deep nesting.

Which formatter should I use for Nix code?

Use `nixfmt` for consistent Nix code formatting. It standardizes layout automatically and pairs well with flat dot-notation style.