← スキル一覧に戻る

managing-flakes
by khaneliman
managing-flakesは、ソフトウェア開発を効率化するスキルです。開発ワークフロー全体をサポートし、チームの生産性向上とコード品質の改善を実現します。
⭐ 303🍴 14📅 2026年1月23日
SKILL.md
name: managing-flakes description: Manages Nix flakes, inputs, dependency resolution, and performance optimization. Use when working with flake.nix, updating inputs, debugging evaluation errors, optimizing flake performance, or composing multi-flake architectures.
Managing Flakes
Flake Schema & Evaluation
Master the Nix flake schema, evaluation mechanics, and advanced patterns.
Evaluation Phases
- Input resolution: Lock file generation (
flake.lock) - System parameters: Flake function evaluation
- Output construction:
packages,apps,devShells - Lazy boundaries: Only evaluate what is requested
Common Outputs
packages.${system}.default: Main packagedevShells.${system}.default: Development environmentnixosConfigurations.${hostname}: System configapps.${system}.default: Runnable applications
Composition Patterns
Multi-Flake Architecture
- Separation of concerns: Split monolithic flakes into logical components
- Shared configuration: Use centralized flakes for common settings
- Inheritance: Pass inputs from parent to child flakes
Modular Design
- Components: Break flakes into
modules/ - Reusability: Export reusable functions in
liboutput - Extension: Use generic flake inputs for plugins
Common Tasks
Task 1: Update a single input
# Update specific input
nix flake update nixpkgs
# Or update all inputs
nix flake update
Task 2: Add a new input
# In flake.nix
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Add new input
new-input = {
url = "github:owner/repo";
inputs.nixpkgs.follows = "nixpkgs"; # Deduplicate nixpkgs
};
};
Why follows?: Prevents multiple nixpkgs versions in closure, speeds up
evaluation.
Task 3: Use a local development flake
# Point to local directory during development
nix registry add my-flake path:/home/user/my-flake
# Now can reference without full path
nix shell my-flake#package
Task 4: Debug slow evaluation
# Show evaluation trace
nix eval .#nixosConfigurations.<host>.config --show-trace
# Profile evaluation
NIX_SHOW_STATS=1 nix eval .#nixosConfigurations.<host>.config
# Look for:
# - Large imports (can these be lazy-loaded?)
# - Repeated nixpkgs imports (use follows?)
# - Unnecessary full-package-set evaluations
Input Management & Follows
Input Management Decision Tree
Adding a new dependency:
-
Is it in nixpkgs already?
- Yes → No new input needed, just reference
pkgs.package-name - No → Continue to step 2
- Yes → No new input needed, just reference
-
Does it depend on nixpkgs?
- Yes → Add
inputs.nixpkgs.follows = "nixpkgs"to deduplicate - No → Skip follows
- Yes → Add
-
Is it from GitHub?
- Yes → Use
github:owner/repo(faster, cached) - No → Use appropriate URI scheme (git+ssh, path, file)
- Yes → Use
-
Is this for development only?
- Yes → Consider registry instead of hard input
- No → Add as regular input
Example: Adding home-manager
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; # Step 2: Deduplicate
};
};
Optimization
- Deduplication: Use
inputs.<name>.followsto share dependencies - Circular dependencies: Avoid loops in follows chains
- Registry: Map local flakes for development (
nix registry add)
URI Schemes
github:owner/repo: GitHub repositorygit+ssh://...: Private Git repositorypath:.: Local directory (requires absolute path or git tracking)file:///...: Local file system (no git requirement)
Performance Optimization
Best Practices
- Laziness: Avoid
importof unused large files - Filtering: Use
nix-filterorlib.cleanSourceto reduce context - Caching: Utilize
eval-cachewhere possible - Profiling: Use
nix build --show-traceto find bottlenecks
Anti-Patterns
- Eagerly evaluating full package sets
- Importing
nixpkgsmultiple times withoutfollows - Checking in massive
flake.lockfiles generated by poor input management
See Also
- Validation: See validating-nix for debugging evaluation errors and build failures
スコア
総合スコア
65/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
✓人気
GitHub Stars 100以上
+5
✓最近の活動
1ヶ月以内に更新
+10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です
