ワンクリックで
nixos-pitfalls-and-review
Common mistakes in NixOS code and standards for reviewing and refactoring NixOS repositories.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Common mistakes in NixOS code and standards for reviewing and refactoring NixOS repositories.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when creating or editing Obsidian Bases `.base` files with filters, formulas, and views.
Use only when interacting with an already running Obsidian GUI instance through the obsidian CLI.
Use when creating or editing Obsidian-flavored Markdown with wikilinks, embeds, callouts, and frontmatter.
Use when searching markdown knowledge bases, notes, and docs with QMD.
Package new software or update existing packages using Nix
| name | nixos-pitfalls-and-review |
| description | Common mistakes in NixOS code and standards for reviewing and refactoring NixOS repositories. |
NixOS modules are evaluated together and merged through the module system. This has important consequences:
Prefer module-system primitives inside modules:
imports = [ ... ] instead of ad hoc import wiring for moduleslib.mkIf instead of raw top-level if for conditional configlib.mkMerge, lib.mkBefore, lib.mkAfter, and lib.mkForce when merge semantics matterconfig too earlyDo not read merged config values in module top-level bindings unless you know the evaluation rules.
Risky pattern:
{ config, ... }:
let
enabled = config.services.nginx.enable;
in
{
# may cause recursion or surprising evaluation problems
}
Safer pattern:
{ config, lib, ... }:
{
config = lib.mkIf config.services.nginx.enable {
# ...
};
}
Do not create a custom option layer for every single setting.
Create custom options when:
enable switchDo not create them when a plain module import and a few direct assignments are enough.
Hosts should not become giant copies of service configuration. Put reusable service logic in modules and keep hosts focused on machine identity.
stateVersionsystem.stateVersion belongs in the host, not in a shared global file.home.stateVersion belongs in the user or Home Manager config.With flakes, untracked files are often invisible to evaluation.
packages/modules/If a file builds a derivation, it is usually a package file, not a NixOS module.
For larger repos, import a stable set of modules and enable them with options instead of hand-curating imports per host.
Benefits:
Each module should answer one question clearly:
When reviewing a NixOS change, ask:
stateVersion local to the host or user?Run at least:
nix flake checknixos-rebuild build --flake .#<host>If using Home Manager through NixOS, also validate the relevant host build rather than only checking formatting.
The best standards reduce guesswork. If a contributor can predict where a change belongs before searching, the structure is working.