目录约定
hosts/、homes/、modules/ 按固定规则发现,无需维护 import 列表或手写 nixosConfigurations。
按约定扫描 hosts/、homes/ 和 modules/,生成对应的 Flake outputs。
| 手写配置 | Snowveil 配置 |
|---|---|
nix | text |
Snowveil 扫描目录并组装模块;NixOS 和 Home Manager 继续处理模块求值。
Snowveil
│
┌───────────┴───────────┐
│ │
Discovery Composition
│ │
┌───────┼────────┐ │
▼ ▼ ▼ ▼
hosts/ users/ modules/ Nix module system
│ │ │ │
▼ ▼ ▼ │
Host User Feature │
│ │ │ │
└───────┴────────┴──────────────┘
│
▼
nixosConfigurations / homeConfigurations
packages / apps / devShells / checks文件扫描读取目录和 meta.nix;随后 Snowveil 按规则选择模块,并交给 NixOS 和 Home Manager。它不改变 option merge、mkIf、mkDefault 或系统配置的求值方式。
| Snowveil | Nix 模块系统 |
|---|---|
| 扫描目录 | 求值模块 |
读取 magic 文件和 meta.nix | 合并 options |
| 生成 outputs | 处理 mkIf、mkDefault |
| 区分 NixOS 与 Home Manager 模块 | 解析模块依赖 |
| 传入模块 | 求值最终配置 |
Snowveil
│
文件系统扫描
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
hosts/ modules/ homes/
│ │ │
▼ ▼ ▼
NixOS 模块集合 Home Manager
│ │ │
└──────────────────┼──────────────────┘
▼
Flake outputs
┌───────┴────────┐
▼ ▼
nixosConfigurations homeConfigurations可查看仓库中的示例项目,也可以直接阅读从普通 flake 迁移。