← Back to list

code-style
by DaRacci
An idiots nix config
⭐ 17🍴 0📅 Jan 24, 2026
SKILL.md
name: code-style description: Write Nix code following repository conventions
Code Style
Critical Requirement
MUST run nix fmt <paths...> after making any changes to ensure consistent formatting.
Indentation
- Use 2 spaces for indentation
- No tabs allowed
Naming Conventions
| Context | Convention | Example |
|---|---|---|
| Files and directories | kebab-case | my-module.nix, home-manager/ |
| Nix attributes | camelCase | myOption, enableFeature |
| Option paths | camelCase | services.myService.enable |
Comments
- Minimal comments preferred
- Code should be self-explanatory
- Use comments to explain why, not what
# Good: explains why
# Workaround for upstream bug #1234
extraConfig = "...";
# Bad: describes what (obvious from code)
# Set extraConfig to the value
extraConfig = "...";
Imports
- Prefer relative imports:
./modules/foo.nix - Group imports at the top of the file
- Use list format for multiple imports:
{
imports = [
./hardware.nix
./services.nix
./networking.nix
];
}
Structured Data
When generating JSON, YAML, or other structured formats, define as Nix attribute sets and convert:
# Good: define as Nix, convert to JSON
environment.etc."config.json".text = builtins.toJSON {
setting = "value";
nested = { key = 123; };
};
# Avoid: inline JSON strings
environment.etc."config.json".text = ''
{"setting": "value", "nested": {"key": 123}}
'';
Common Patterns
Module Structure
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkEnableOption mkOption mkIf types;
cfg = config.services.myService;
in
{
options.services.myService = {
enable = mkEnableOption "my service";
};
config = mkIf cfg.enable {
# configuration here
};
}
Let Bindings
let
inherit (lib) mkIf mkEnableOption;
cfg = config.myModule;
in
{
# use cfg, mkIf, etc.
}
Score
Total Score
60/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon