← スキル一覧に戻る

nix-module-template
by khaneliman
nix-module-templateは、ソフトウェア開発を効率化するスキルです。開発ワークフロー全体をサポートし、チームの生産性向上とコード品質の改善を実現します。
⭐ 303🍴 14📅 2026年1月23日
SKILL.md
name: nix-module-template description: "Basic Nix module structure template. Use when creating new NixOS, Home Manager, or nix-darwin modules from scratch."
Module Template
Standard Structure
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.namespace.moduleName;
in
{
options.namespace.moduleName = {
enable = mkEnableOption "module description";
};
config = mkIf cfg.enable {
# Configuration here
};
}
NixOS System Module
# modules/nixos/services/my-service.nix
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.services.myService;
in
{
options.services.myService = {
enable = mkEnableOption "My Service";
port = lib.mkOption {
type = lib.types.port;
default = 8080;
};
};
config = mkIf cfg.enable {
systemd.services.my-service = {
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = "...";
};
};
}
Home Manager Module
# modules/home/programs/my-app.nix
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.programs.myApp;
in
{
options.programs.myApp = {
enable = mkEnableOption "My App";
};
config = mkIf cfg.enable {
home.packages = [ pkgs.myApp ];
xdg.configFile."myapp/config".text = "...";
};
}
nix-darwin Module
# modules/darwin/system/defaults.nix
{
config,
lib,
...
}:
let
inherit (lib) mkIf mkEnableOption;
cfg = config.myproject.macosDefaults;
in
{
options.myproject.macosDefaults = {
enable = mkEnableOption "macOS defaults";
};
config = mkIf cfg.enable {
system.defaults.dock.autohide = true;
};
}
Key Points
- Always use
cfgpattern for accessing options - Wrap config in
mkIf cfg.enable - Use
mkEnableOptionfor enable flags - Keep modules self-contained
スコア
総合スコア
65/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
✓人気
GitHub Stars 100以上
+5
✓最近の活動
3ヶ月以内に更新
+5
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です
