nixos-config
Use when working with NixOS configurations, Home Manager setups, Nix flakes, services, or troubleshooting Nix builds. Covers creating new configurations, modifying existing ones, adding packages, setting up services, writing modules, and debugging build failures.
What this skill does
# NixOS Configuration Skill **Announce at start**: "I'm using the nixos-config skill to work with your Nix configuration." ## Critical Reminders - **Flakes only** — never use channels or `nix-env` - **Declarative always** — never use imperative approaches when declarative solutions exist - **jj new before building** — new files must be tracked; run `jj new` so they appear in git HEAD - **Always build-test** — never consider the task complete without a successful build - **Clean up result symlinks** — remove any `result` symlinks created during builds ## Quick Reference | Task | Command | |---|---| | Rebuild NixOS (test) | `sudo nixos-rebuild test --flake .#<hostname>` | | Rebuild NixOS (switch) | `sudo nixos-rebuild switch --flake .#<hostname>` | | Home Manager build | `home-manager build --flake .#user@hostname --no-out-link` | | Home Manager switch | `home-manager switch --flake .#user@hostname` | | Check flake | `nix flake check` | | Evaluate expression | `nix-instantiate --eval -E '<expr>'` | | Interactive REPL | `nix repl` | | Show derivation | `nix show-derivation` | | Update single input | `nix flake update <input>` | | Update all inputs | `nix flake update` | ## Workflow ### Phase 1: Analyze Existing Configuration Before making changes, understand the current setup: 1. Read `flake.nix` to understand inputs, outputs, and structure 2. Identify the module organization pattern (flat vs nested, custom namespaces like `mynix`) 3. Check for existing conventions: - Option naming patterns - Module enable/disable patterns - Import structure - Custom library functions 4. Note the hostname(s) and user(s) configured ### Phase 2: Plan Changes Determine scope and approach: 1. **NixOS vs Home Manager** — system-level services and kernel config go in NixOS modules; user programs, dotfiles, and user services go in Home Manager 2. **New module vs existing** — prefer extending existing modules unless the feature is clearly separate 3. **Option design** — plan option names, types, and defaults that match existing conventions 4. Explain the planned changes to the user before implementing ### Phase 3: Implement Write the configuration following Nix best practices: - Use `lib.mkEnableOption` for boolean toggles - Use `lib.mkOption` with proper types (`types.str`, `types.listOf`, `types.attrsOf`, etc.) - Use `lib.mkIf` for conditional configuration - Use `lib.mkDefault` for defaults that users can override - Use `lib.mkForce` sparingly and only when necessary - Use `lib.mkMerge` to combine multiple config blocks - Use `lib.assertMsg` for meaningful error messages on invalid config - Respect the project's existing conventions and namespaces - Add description strings to custom options ### Phase 4: Validate and Build 1. If new files were created, run `jj new` so they are tracked 2. Build and test: - **NixOS**: `sudo nixos-rebuild test --flake .#<hostname>` - **Home Manager**: `home-manager build --flake .#user@hostname --no-out-link` 3. Run `nix flake check` if structural changes were made to the flake 4. Clean up any `result` symlinks: `rm -f result` 5. Squash related changes if needed: `jj squash` ### Phase 5: Troubleshoot If Build Fails If the build fails, follow this process: 1. **Parse the error message** — identify the failing module, option, or derivation 2. **Use debugging tools**: - `nix-instantiate --eval` to test expressions in isolation - `nix repl` to interactively explore values - `nix show-derivation` to inspect build dependencies 3. **Fix the issue** and rebuild 4. **Repeat** until the build succeeds ## Error Handling ### Common Failure Patterns | Error | Cause | Fix | |---|---|---| | `error: getting status of '/nix/store/.../<file>'` | New file not tracked by git | Run `jj new` to snapshot, then rebuild | | `error: attribute 'X' missing` | Typo in option name or missing import | Check spelling, verify module is imported in `flake.nix` | | `error: infinite recursion encountered` | Circular dependency between options | Break the cycle with `lib.mkMerge` or restructure | | `error: value is a X while a Y was expected` | Wrong option type | Check `mkOption` type declaration matches usage | | `error: option 'X' does not exist` | Module not imported or option path wrong | Verify import chain and option path | | `collision between '/nix/store/...'` | Two packages provide same file | Use `lib.mkForce` or `packageOverrides` to resolve | | `error: flake 'X' does not provide attribute` | Wrong output path in flake | Check `nixosConfigurations` / `homeConfigurations` names | ### Build Fails After Adding New Files This is the most common issue. New files are not visible to the Nix evaluator until they are tracked: ```bash jj new # snapshot new files into git HEAD # then rebuild ``` Remember to squash related changes afterward if needed. ## Key Principles 1. **Declarative** — every configuration choice should be expressed declaratively in Nix 2. **Minimal changes** — make targeted changes that integrate with existing patterns 3. **Validate before done** — never claim completion without a passing build 4. **Respect conventions** — follow the project's established module structure, naming, and namespaces 5. **Explain changes** — describe what was changed and why, highlight breaking changes or migration needs ## Resources Reference materials are available in the `references/` directory: - `nix-language.md` — Nix language syntax and builtins - `flake-patterns.md` — Flake structure, inputs, and overlays - `nixos-modules.md` — Module structure, option declarations, and config patterns - `home-manager.md` — Home Manager modules, programs, and services - `troubleshooting.md` — Error catalog, debugging workflow, and migration patterns
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.