nix-option-types

Define Nix option types with mkOption and submodules for strict validation.

1|Updated Jun 2, 2025
One-click install
npx skills add https://github.com/aytordev/system --skill nix-option-types-aytordev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nix-option-types
Source: https://github.com/aytordev/system/tree/main/modules/common/ai-tools/skills/nix/option-types
Command: npx skills add https://github.com/aytordev/system --skill nix-option-types-aytordev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Nix projects often struggle with inconsistent option definitions and weak type safety. This Skill provides a concise guide to using mkOption, lib.types, and submodule patterns to create robust, maintainable configurations.

Core Features & Use Cases

  • Clear guidance on Basic Types, Collection Types, Submodules, and Package Options.
  • Real-world patterns for attrsOf, enum, and submodule compositions to build scalable Nix modules.
  • Use cases across NixOS modules, Home Manager configurations, and nixpkgs overlays.

Quick Start

Define your first option using a typed mkOption with a concrete type and a minimal example to illustrate the pattern.

Frequently Asked Questions about nix-option-types

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

FAQPage Schema
How do I define robust Nix option types with strict validation?

To define robust Nix option types with strict validation, use mkOption with explicit lib.types patterns. This enforces basic, collection, submodule, and package option rules to reduce misconfigurations across NixOS modules.

What's the best way to structure Nix submodules for scalable configurations?

The best way to structure Nix submodules for scalable configurations is applying attrsOf and enum compositions. This approach builds maintainable module hierarchies across Home Manager and nixpkgs overlays.

Can I use mkOption package options across Home Manager and nixpkgs overlays?

Yes, you can use mkOption package options across Home Manager and nixpkgs overlays. The patterns apply uniformly to NixOS modules, ensuring consistent type safety and explicit validation throughout your environments.

Why does my NixOS module fail without explicit collection types?

Your NixOS module fails without explicit collection types because weak type safety causes inconsistent option definitions. Defining attrsOf and submodule patterns enforces strict validation, preventing runtime misconfigurations.

When do I need submodules in Nix module design?

You need submodules in Nix module design when composing complex, nested configurations. They allow scalable attribute set compositions using mkOption, ensuring strict validation and maintainability for NixOS and Home Manager.