nix-option-types

Define Nix module options using mkEnableOption, mkPackageOption, and mkOption helpers.

340|18|Updated May 11, 2023
One-click install
npx skills add https://github.com/khaneliman/khanelinix --skill nix-option-types
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nix-option-types
Source: https://github.com/khaneliman/khanelinix/tree/main/modules/common/ai-tools/skills/option-types
Command: npx skills add https://github.com/khaneliman/khanelinix --skill nix-option-types

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Nix module option definitions can be verbose and error-prone; this Skill provides patterns and helpers to standardize options, across types and submodules.

Core Features & Use Cases

  • Prefers helpers like mkEnableOption, mkPackageOption, and mkOption to simplify option declarations.
  • Demonstrates basic and collection types for options (strings, ints, ports, paths, and packages) and submodule patterns.
  • Serves as a scalable reference for building Nix modules with consistent interfaces across multiple files.

Quick Start

Use the patterns shown to define a Nix module by replacing placeholders with your project’s option names and types.

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 module options without verbose code?

To define robust Nix module options, use helper functions like mkEnableOption, mkPackageOption, and mkOption. These helpers standardize option declarations, reducing errors and simplifying your Nix configuration interfaces.

What collection types can I use when building a Nix module interface?

When building a Nix module interface, you can use basic and collection types including strings, ints, ports, paths, and packages. These types ensure consistent option typing and validate inputs for scalable definitions.

When should I use mkEnableOption instead of mkOption in nixpkgs?

Use mkEnableOption in nixpkgs for simple boolean flags that enable features, defaulting to false. Use mkOption when you need custom defaults, complex types, or detailed descriptions for broader configuration control.

How do I structure scalable Nix module option definitions across multiple files?

To structure scalable Nix module option definitions across multiple files, apply consistent submodule patterns and helper-based declarations. This approach standardizes interfaces, ensuring your module library remains maintainable as it grows.