khanelinix 7-level configuration hierarchy and customization strategy. Use when deciding where to put customizations, understanding override precedence, resolving option conflicts, or working with host/user specific configs.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
skills listSkill Instructions
name: configuring-layers description: "khanelinix 7-level configuration hierarchy and customization strategy. Use when deciding where to put customizations, understanding override precedence, resolving option conflicts, or working with host/user specific configs."
Configuration Layering
7-Level Hierarchy
From lowest to highest precedence:
- Common modules - Cross-platform base functionality
- Platform modules - OS-specific (nixos/darwin)
- Home modules - User-space applications
- Suite modules - Grouped functionality with defaults
- Archetype modules - High-level use case profiles
- Host configs - Host-specific overrides
- User configs - User-specific customizations (highest priority)
Quick Decision Tree
Question: Where should I put this configuration?
- Does it require sudo/root access? → System modules (
nixos/ordarwin/) - Is it hardware-specific? → Host config (
systems/{arch}/{hostname}/) - Is it user-preference specific? → User config
(
homes/{arch}/{user@host}/) - Does it configure user applications? → Home modules (
modules/home/) - Is it shared across platforms? → Common modules (
modules/common/)
Still unsure? Default to home modules - they're easiest to test and most portable.
Customization Strategy
| What to customize | Where |
|---|---|
| Host hardware/services | systems/{arch}/{hostname}/ |
| Platform behavior | modules/nixos/ or modules/darwin/ |
| User applications | modules/home/ |
| Personal preferences | homes/{arch}/{user@host}/ |
Host Configuration
systems/{arch}/{hostname}/
├── default.nix # Host-specific system config
└── hardware.nix # Hardware-specific settings
Example: systems/x86_64-linux/khanelimain/default.nix
User Configuration
homes/{arch}/{username@hostname}/
├── default.nix # User-specific home config
└── packages.nix # User-specific packages
Example: homes/x86_64-linux/khaneliman@khanelimain/default.nix
Override Precedence
# In module (low priority - can be overridden)
programs.git.userName = lib.mkDefault "Default Name";
# In host config (overrides module default)
programs.git.userName = "Host Specific";
# Force (highest priority - rarely needed)
programs.git.userName = lib.mkForce "Forced Value";
Override Patterns by Use Case
Pattern 1: Testing a new value (keep module default)
# In home config - temporarily override
programs.git.userName = "Test Name"; # Plain assignment
# Module default still exists for other hosts
Pattern 2: Setting project-wide standard (weak default)
# In module
programs.git.userName = lib.mkDefault "Default Name";
# Easily overridden in host/user configs
Pattern 3: Enforcing a requirement (strong override)
# In security-critical module
security.sudo.wheelNeedsPassword = lib.mkForce true;
# Cannot be overridden by downstream configs
Common Override Scenarios
Scenario: Different git config per host
# modules/home/programs/terminal/tools/git/default.nix
programs.git.userName = lib.mkDefault "khaneliman";
# homes/x86_64-linux/khaneliman@workhost/default.nix
programs.git.userName = "Work Name"; # Overrides for this host
# homes/x86_64-linux/khaneliman@personalhost/default.nix
# Uses module default ("khaneliman")
Scenario: Override theme but not fonts
# Suite sets defaults
khanelinix.user.theme = lib.mkDefault "catppuccin-mocha";
khanelinix.user.font.mono = lib.mkDefault "JetBrainsMono";
# User overrides just theme
khanelinix.user.theme = "gruvbox"; # Plain assignment overrides mkDefault
# Font remains JetBrainsMono from suite
Best Practice
Prefer customization in this order:
- Home configuration wherever possible
- Host config for hardware/host-specific
- Platform modules for OS-specific behavior
- Common modules for shared base functionality
See Also
- Module placement: See scaffolding-modules for determining where to place configuration
- Option design: See designing-options for creating properly namespaced options
More by khaneliman
View allCreate development environment templates and project scaffolding with Nix flakes. Use when creating new project templates, setting up dev shells, configuring language-specific environments, or integrating with CI/CD.
Manages encrypted secrets using sops-nix and age. Use when adding new secrets, rotating keys, debugging secret access, or setting up secret management for new hosts/users.
Conduct thorough, actionable code reviews focusing on critical issues. Use when reviewing pull requests, analyzing code changes, identifying bugs, security vulnerabilities, or suggesting improvements that developers will actually implement.
khanelinix directory structure and module placement. Use when creating new modules, deciding where files belong, or understanding the modules/ organization. Covers platform separation (nixos/darwin/home/common) and auto-discovery.
