Loading...
Loading...
Use when configuring NixOS with flakes, managing overlays with home-manager useGlobalPkgs, structuring NixOS configurations, or facing issues where configuration changes don't apply
npx skill4agent add lihaoze123/my-skills nixos-best-practicesuseGlobalPkgs = trueuseGlobalPkgs = true| Topic | Rule File |
|---|---|
| Overlay scope and useGlobalPkgs | overlay-scope |
| Flakes configuration structure | flakes-structure |
| Host configuration organization | host-organization |
| Package installation best practices | package-installation |
| Common configuration mistakes | common-mistakes |
| Debugging configuration issues | troubleshooting |
# ❌ WRONG: Overlay in home.nix (doesn't apply)
# home-manager/home.nix
{
nixpkgs.overlays = [ inputs.claude-code.overlays.default ]; # Ignored!
home.packages = with pkgs; [ claude-code ]; # Not found!
}
# ✅ CORRECT: Overlay in NixOS home-manager block
# hosts/home/default.nix
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.chumeng = import ./home.nix;
home-manager.extraSpecialArgs = { inherit inputs pkgs-stable system; };
# Overlay must be HERE when useGlobalPkgs = true
nixpkgs.overlays = [ inputs.claude-code.overlays.default ];
}| Task | Solution |
|---|---|
| Add flake input | Add to |
| Add overlay for system packages | Define in |
| Add overlay for home-manager (useGlobalPkgs=true) | Define in |
| Add overlay for home-manager (useGlobalPkgs=false) | Define in |
| Pass inputs to modules | Use |
| Multiple host configurations | Create separate host files in |
| Shared configuration modules | Create modules in |
| Package not found after overlay | Check overlay scope vs useGlobalPkgs setting |
| useGlobalPkgs | Overlay Definition Location | Affects |
|---|---|---|
| | System + Home Manager packages |
| | Nothing (ignored!) |
| | Home Manager packages only |
| | Home Manager packages only |
| Any | System | System packages only |
/etc/nixos/configuration.nixrules/overlay-scope.md # The core overlay scope issue
rules/flakes-structure.md # How to organize flake.nix
rules/host-organization.md # How to structure host configs
rules/common-mistakes.md # Pitfalls and how to avoid themAGENTS.md