← Back to list

nix-option-types
by khaneliman
Nix configuration for my systems supporting macOS, NixOS, and WSL.
⭐ 303🍴 14📅 Jan 23, 2026
SKILL.md
name: nix-option-types description: "Nix module option types and definition patterns. Use when defining options with mkOption, choosing types, or creating submodules."
Option Types
Prefer Helpers When Available
| Helper | Use For |
|---|---|
mkEnableOption | Boolean enable flags |
mkPackageOption | Package options |
mkOption | Everything else |
Basic Types
options = {
# Boolean (use mkEnableOption for enable flags)
enable = mkEnableOption "feature";
# String
name = mkOption {
type = types.str;
default = "default";
description = "The name";
};
# Integer
count = mkOption {
type = types.int;
default = 1;
};
# Port (validated 1-65535)
port = mkOption {
type = types.port;
default = 8080;
};
# Path
configPath = mkOption {
type = types.path;
default = ./config.yaml;
};
# Package
package = lib.mkPackageOption pkgs "myPackage" { };
};
Collection Types
options = {
# List of strings
args = mkOption {
type = types.listOf types.str;
default = [ ];
};
# Attribute set of strings
env = mkOption {
type = types.attrsOf types.str;
default = { };
};
# Enum (one of values)
level = mkOption {
type = types.enum [ "debug" "info" "error" ];
default = "info";
};
# Nullable
optional = mkOption {
type = types.nullOr types.str;
default = null;
};
# Either type
portOrSocket = mkOption {
type = types.either types.port types.path;
};
};
Submodule Pattern
options.services = mkOption {
type = types.attrsOf (types.submodule {
options = {
enable = mkEnableOption "service";
port = mkOption {
type = types.port;
default = 8080;
};
};
});
default = { };
};
# Usage:
config.namespace.services.myService = {
enable = true;
port = 9000;
};
mkPackageOption
# Simple
package = lib.mkPackageOption pkgs "git" { };
# Nested package path
package = lib.mkPackageOption pkgs "nodePackages" {
default = [ "typescript" ];
};
Score
Total Score
65/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
✓人気
GitHub Stars 100以上
+5
✓最近の活動
1ヶ月以内に更新
+10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon
