Skip to content
Back to skills

Module List Order

ASecurity

Sort lists that enumerate Nix modules, such as `imports` and the `modules` argument of `lib.nixosSystem`, in lexicographic order, and re-sort an existing unsorted list when touching it. Lists whose order changes the evaluated result are excluded. Use when adding, removing, or rewriting entries in a list of Nix modules.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agents

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add ncaq/konoka --skill module-list-order --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Module List Order?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Module List Order
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ncaq-module-list-order/badge)](https://www.skillsdirectory.com/skills/ncaq-module-list-order)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: module-list-order
description: Sort lists that enumerate Nix modules, such as `imports` and the `modules` argument of `lib.nixosSystem`, in lexicographic order, and re-sort an existing unsorted list when touching it. Lists whose order changes the evaluated result are excluded. Use when adding, removing, or rewriting entries in a list of Nix modules.
user-invocable: false
---

# モジュールを並べるリストは辞書順にする

`imports`のようにモジュールを並べるリストは、要素を辞書順に並べて書いてください。
要素を足すときは、関係の近い要素の隣に置くのではなく、辞書順で決まる位置に置きます。

並びが決まっていれば、要素を足す位置に迷いません。
重複や漏れも見つけやすくなります。

既存のリストが辞書順になっていなくても、
そのリストに手を入れるときに全体を並べ直します。

## 対象のリスト

- `imports`
- `lib.nixosSystem`や`home-manager.lib.homeManagerConfiguration`に渡す`modules`
- `home-manager.sharedModules`

## 並べ方

要素のソースコード上の文字列を、文字コードの順に比べます。
`LC_ALL=C sort`と同じ順序です。

`.`は`/`より文字コードが小さいので、
`../`で始まるパスは`./`で始まるパスより前に来ます。

```nix
{
  imports = [
    ../prompt
    ./core
    ./link.nix
  ];
}
```

`inputs.sops-nix.nixosModules.sops`のような属性の参照は、
`./`で始まるパスより後に来ます。

## 並べ替えると結果が変わるリストは対象外

並びに意味があるリストは、辞書順にしません。

モジュールシステムは`imports`の順序に依らずに定義をマージするので、
モジュールのリストは普通は並べ替えても結果が変わりません。
ただし同じ優先度で定義されたリスト型や`lines`型のオプションの値は、
モジュールを読み込む順序に依存した順序で連結されます。
この連結の順序が動作に効くリストは、並べ替えずに残します。

overlaysのリストは、後のoverlayが前のoverlayの結果を受け取るので、順序に意味があります。
モジュールのリストと見た目が似ていても、辞書順にはしません。

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.