# Solve a NixOS problem the declarative, reproducible way

A NixOS-native fix for a configuration, package, or service problem that survives rebuilds and can be rolled back.

- Topic: Software Development
- Framework: RTF
- Level: Standard
- Tags: Fill-in Template
- Source: https://www.thinkwithprompt.com/prompts/solve-a-nixos-problem-the-declarative-reproducible-way

## Prompt

```text
Help me solve a NixOS problem in a way that is idiomatic to NixOS. I already know Linux well, so skip the basics and focus on Nix-specific semantics.

**What I'm trying to do or what's broken:** [GOAL or SYMPTOM]
**Setup:** [flakes or channels, NixOS version, Home Manager yes/no, hardware or VM]
**Relevant config:** [paste configuration.nix, flake.nix, or module snippets]
**Exact errors and commands run:** [paste output of nixos-rebuild, nix build, journalctl, etc.]
**What I've tried:** [ATTEMPTS]

Rules:
- Prefer declarative fixes (module options, overlays, packages in config) over imperative ones (nix-env -i, editing files in /etc, mutable state).
- Check for an existing NixOS module option before writing custom systemd units or activation scripts.
- If the problem is a non-Nix binary (dynamic linking, FHS paths), explain the options: packaging it properly, buildFHSEnv, nix-ld, or steam-run, with trade-offs.
- Explain the root cause in Nix terms (evaluation vs. build vs. activation failure, option conflicts and mkForce/mkDefault priorities, impurity, store paths).
- Say whether the fix differs between flakes and channels.
- Don't invent option names. If unsure an option exists, tell me how to check (nixos-option, search.nixos.org, man configuration.nix) and mark it [VERIFY].

Return:
1. Root cause in 2-3 sentences.
2. The fix as a config diff or module snippet.
3. Commands to apply and test it (including nixos-rebuild test before switch).
4. How to roll back if it goes wrong.
5. Any gotchas for future upgrades.
```

## What to fill in

- GOAL or SYMPTOM
- paste configuration.nix, flake.nix, or module snippets
- paste output of nixos-rebuild, nix build, journalctl, etc.
- ATTEMPTS

Free to copy and use. From ThinkWithPrompt (https://www.thinkwithprompt.com/), a library of 2,663 curated AI prompts.
