スキル一覧に戻る
DaRacci

code-style

by DaRacci

An idiots nix config

17🍴 0📅 2026年1月24日
GitHubで見るManusで実行

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

ContextConventionExample
Files and directorieskebab-casemy-module.nix, home-manager/
Nix attributescamelCasemyOption, enableFeature
Option pathscamelCaseservices.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.
}

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

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

レビュー

💬

レビュー機能は近日公開予定です