claude/skills/nix-config/SKILL.md
This skill provides comprehensive guidance for working with the nix-config framework - a platform-agnostic modular configuration system for NixOS and Darwin (macOS). Use this skill when adding new modules, hosts, users, or services; when troubleshooting configuration issues; or when modifying any aspect of the nix-config/nix-secrets ecosystem.
npx skillsauth add channinghe/dotfiles nix-configInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides comprehensive knowledge of the nix-config framework - a platform-agnostic modular configuration system that supports both NixOS and Darwin (macOS) through a unified architecture. The framework separates public configuration logic (nix-config) from private sensitive data (nix-secrets) using a three-file pattern for platform-agnostic design.
Each module uses three files to separate platform-specific logic:
default.nix - Platform-agnostic common logicnixos.nix - Linux-specific (systemd, NetworkManager)darwin.nix - macOS-specific (launchd, Homebrew paths)Priority System: lib.mkDefault (low) → normal → lib.mkForce (high)
Layer 1: hosts/common/core/ - Core system configuration
Layer 2: hosts/common/optional/ - Optional services
Layer 3: hosts/common/users/ - User configurations
Layer 4: hosts/nixos/${hostname}/ - Host-specific config
| Location | Type | Content |
|----------|------|---------|
| nix-config/ | Public | Module logic, configuration structure |
| nix-secrets/ | Private | Sensitive data (IPs, passwords, keys) |
To add a new NixOS host:
hosts/nixos/${hostname}/hardware-configuration.nix:
cp hosts/nixos/ExistingHost/hardware-configuration.nix hosts/nixos/NewHost/sudo nixos-generate-config --root /mnt on the hostdefault.nix with host-specific imports and settingsnix-secrets/nix/network.nix (network info)nix-secrets/secrets/${hostname}.yaml./scripts/rebuild.sh NewHost buildTo add a new Darwin (macOS) host:
hosts/darwin/${hostname}/default.nix with host-specific importshostSpec.isDarwin = truenix-secrets/nix/network.nixnix-secrets/secrets/${hostname}.yaml./scripts/rebuild.sh NewMac buildTo add a new user:
hosts/common/users/${username}/home/${username}/common/{core,dotfiles,optional}/hosts/common/users/${username}/default.nixnixos.nix and darwin.nixhosts/common/users/${username}/keys/home/${username}/common/core/default.nixhosts/common/core/default.nix to import the new userTo create a reusable service module:
hosts/common/optional/services/modules/hosts/common/, modules/hosts/nixos/, or modules/hosts/darwin/# Relative path from project root
lib.custom.relativeToRoot "modules/common"
# Scan directory for .nix files
lib.custom.scanPaths ./optional
# Flatten nested imports
imports = lib.flatten [
./hardware-configuration.nix
(map lib.custom.relativeToRoot [
"hosts/common/core"
"hosts/common/optional/services/docker.nix"
])
];
# Conditional imports
imports = lib.optionals (!isDarwin) [
(lib.custom.relativeToRoot "hosts/common/core/openssh-server.nix")
];
# Method 1: hostSpec
lib.mkIf (!config.hostSpec.isDarwin) { ... }
# Method 2: pkgs.stdenv
lib.optionalAttrs pkgs.stdenv.isLinux { ... }
# Method 3: File-level separation
hosts/common/users/${username}/default.nix # Always imported
hosts/common/users/${username}/nixos.nix # Only NixOS
hosts/common/users/${username}/darwin.nix # Only Darwin
| File | Purpose |
|------|---------|
| flake.nix | Root configuration, defines inputs and outputs |
| modules/common/host-spec.nix | Host specification module (username, network info, flags) |
| hosts/common/core/default.nix | Core system config, imports HM and SOPS |
| scripts/rebuild.sh | Cross-platform rebuild script |
nix-secrets/
├── nix/ # Nix-exposed configuration
│ ├── network.nix # Network config per host (no sensitive data)
│ ├── network-storage.nix # NFS/Samba configurations
│ └── services.nix # Service-specific secrets
└── secrets/ # SOPS encrypted files
└── ${hostname}.yaml # Host-specific encrypted secrets
| Issue | Solution |
|-------|----------|
| Option conflicts | Use lib.mkDefault in base config |
| Missing group on Darwin | Use lib.optionalAttrs pkgs.stdenv.isLinux { group = "wheel"; } |
| Wrong stateVersion type | NixOS = string, Darwin = integer |
| Auto-optimise-store on Darwin | Use nix.optimise.automatic instead |
| SOPS SSH key paths differ | Conditional sshKeyPaths in sops.nix |
| Secrets not decrypting | Check AGE key recipients and SSH agent |
# On NixOS
sudo nixos-rebuild switch --flake .#hostname
# On Darwin
sudo darwin-rebuild switch --flake .#hostname
# Cross-platform script
./scripts/rebuild.sh [hostname] [trace|build]
# Using nh (if installed)
nh os switch .
nh darwin switch .
# Edit secret
sops secrets/${hostname}.yaml
# Encrypt file
sops -e -i secrets.txt
# Decrypt file
sops -d -i secrets.txt
# Add new AGE key
sops keys add age1...
# Rotate keys
sops rotate -i secrets.yaml
# Enter dev shell
nix develop
# Format code
nix fmt
# Run checks
nix flake check
# Build ISO
nix build --impure .#nixosConfigurations.iso.config.system.build.isoImage
system.stateVersion = "25.05" (string)fileSystems.* for mountingsystemd.services.* for servicesnetworking.networkd or NetworkManager/etc/ssh/authorized_keys.d/system.stateVersion = 6 (integer; 5 = nix-darwin 25.05)launchd.agents.* for servicesFor detailed documentation and references, consult the bundled resources in the references/ directory:
architecture.md - Detailed architecture and design patternsdirectory-structure.md - Complete directory structure referencehostspec-reference.md - hostSpec module options referencemodule-creation.md - Module creation patterns and examplesnetwork-storage.md - Network storage module documentationThese files provide in-depth information for complex operations and should be referenced when detailed guidance is needed beyond this quick guide.
development
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
development
# Verification Loop Skill A comprehensive verification system for Claude Code sessions. ## When to Use Invoke this skill: - After completing a feature or significant code change - Before creating a PR - When you want to ensure quality gates pass - After refactoring ## Verification Phases ### Phase 1: Build Verification ```bash # Check if project builds npm run build 2>&1 | tail -20 # OR pnpm build 2>&1 | tail -20 ``` If build fails, STOP and fix before continuing. ### Phase 2: Type Check
tools
Tooling and verification. Apply when encountering unfamiliar third-party libraries, framework updates, uncertain parameter types, verifying best practices, or uncertain API parameters.
development
Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.