Back to list
khaneliman

designing-options

by khaneliman

Nix configuration for my systems supporting macOS, NixOS, and WSL.

303🍴 14📅 Jan 23, 2026

SKILL.md


name: designing-options description: "khanelinix option namespacing and design patterns. Use when defining module options, accessing configuration values, or understanding the khanelinix.* namespace convention."

Options Design

Namespace Convention

ALL options must be under khanelinix.*:

options.khanelinix.{category}.{module}.{option} = { ... };

Namespace Visualization

khanelinix.*
├── programs.*
│   ├── terminal.*
│   │   ├── tools.*      (git, fzf, ripgrep, ...)
│   │   ├── shells.*     (zsh, bash, fish, ...)
│   │   └── editors.*    (neovim, helix, ...)
│   └── graphical.*
│       ├── wms.*        (hyprland, sway, ...)
│       └── apps.*       (firefox, discord, ...)
├── services.*           (user systemd services)
├── desktop.*            (DE configurations)
├── security.*           (sops, gpg, ssh)
├── system.*             (fonts, xdg, env)
└── user.*               (name, email, theme)

Examples

options.khanelinix.programs.terminal.tools.git.enable = ...
options.khanelinix.desktop.windowManagers.hyprland.enable = ...
options.khanelinix.security.sops.enable = ...
options.khanelinix.user.name = ...

Standard Option Pattern

{
  config,
  lib,
  pkgs,
  ...
}:
let
  inherit (lib) mkIf mkEnableOption;

  cfg = config.khanelinix.programs.myApp;
in
{
  options.khanelinix.programs.myApp = {
    enable = mkEnableOption "My App";
  };

  config = mkIf cfg.enable {
    # configuration here
  };
}

Accessing User Context

let
  inherit (config.khanelinix) user;
in
{
  # Use user.name, user.email, user.fullName
  programs.git.userName = user.fullName;
}

Reduce Repetition

Use shared top-level options:

# Define once at top level
options.khanelinix.theme.name = mkOption { ... };

# Reference throughout
config = mkIf (cfg.theme.name == "catppuccin") { ... };

Option Helpers

khanelinix provides helpers in lib.khanelinix:

inherit (lib.khanelinix) mkOpt enabled disabled;

# Quick enable/disable
programs.git = enabled;   # { enable = true; }
programs.foo = disabled;  # { enable = false; }

# Custom option with default
userName = mkOpt types.str "default" "User name";

osConfig Access

When home modules need system config:

{
  config,
  lib,
  osConfig ? { },  # With fallback
  ...
}:

# Always guard with fallback
config = lib.mkIf (osConfig.khanelinix.security.sops.enable or false) {
  # ...
};

Common Anti-Patterns

❌ Direct nixpkgs options

# BAD - bypasses khanelinix abstraction
programs.git.enable = true;

✅ Namespaced options

# GOOD - uses khanelinix namespace
khanelinix.programs.terminal.tools.git.enable = true;

❌ Hardcoded theme values

# BAD - theme string duplicated everywhere
programs.kitty.theme = "Catppuccin-Mocha";

✅ Reference shared theme

# GOOD - single source of truth
programs.kitty.theme = config.khanelinix.user.theme;

❌ Missing type specification

# BAD - implicit type, can cause issues
myOption = mkOption {
  default = "";
  description = "Some option";
};

✅ Explicit types

# GOOD - explicit type
myOption = mkOption {
  type = types.str;
  default = "";
  description = "Some option";
};

See Also

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