terlar/nix-config/flake-parts
Claude Code and agent skill by terlar/nix-config
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Use when working with flake-parts or dev-flake — structuring flakes, defining perSystem outputs, writing reusable flake modules, using withSystem or moduleWithSystem, exporting flakeModules, setting up dev environments with dev-flake, or debugging flake-parts evaluation.
Install
npx vskill@latest install terlar/nix-config/flake-partsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Basic structure
Always pass the outputs function argument as inputs (not self.inputs) to avoid infinite recursion.
Key options
| Option | Purpose | |
|---|---|---|
systems | List of systems to iterate over in perSystem | |
perSystem | Module evaluated once per system; receives pkgs, system, config, etc. | |
flake | System-independent flake outputs merged directly | |
imports | Import flake-parts modules | |
debug | Expose full module config in flake outputs for inspection |
perSystem module args
| Arg | Value | |
|---|---|---|
system | Current system string (e.g., "x86_64-linux") | |
pkgs | nixpkgs.legacyPackages.${system} (configurable) | |
config | The current perSystem module's config | |
inputs' | All inputs with outputs pre-selected for system | |
self' | This flake's own outputs pre-selected for system |
Override pkgs for the whole perSystem scope (e.g. to allow unfree):
withSystem — access per-system config from top level
Use withSystem to reference per-system packages from top-level module scope (e.g. when building nixosConfigurations):
moduleWithSystem — inject perSystem args into NixOS modules
Wrap a NixOS module to receive per-system args. The target system is inferred from the module's own pkgs or system arg:
Exporting flake-parts modules
Expose reusable flake-parts modules under flake.flakeModules:
Dogfooding pattern — use your own module and export it:
Consumers import it as:
Convention: local module files are named flake-module.nix. Always set _file on inner mkPerSystemOption calls for accurate error attribution.
Importing flake-parts modules
Debugging
Enable debug = true to expose all intermediate module config for inspection:
Then inspect any output path:
dev-flake
dev-flake (github:terlar/dev-flake) is a flake-parts module that bundles devshell, git-hooks-nix (pre-commit), and treefmt-nix behind a thin dev.* option surface. All features default to enabled.
What it wires up automatically
devShells.default— named devshell with pre-commit installed on entry;
treefmt and pre-commit available as shell commands
checks.pre-commit— all configured pre-commit hooks as a flake checkchecks.treefmt— treefmt check (only when pre-commit is disabled, to avoid
double-checking; otherwise treefmt runs through pre-commit)
- Default hooks enabled:
deadnix,statix
Top-level dev.* options
| Option | Default | Description | |
|---|---|---|---|
dev.name | "project" | Project name, used as devshell prompt | |
dev.rootSrc | self.outPath | Project root for pre-commit; set to parent self in sub-flakes | |
dev.devshell.enable | true | Enable devshell | |
dev.devshell.addCommands | true | Add treefmt and pre-commit to shell menu | |
dev.pre-commit.enable | true | Enable pre-commit | |
dev.treefmt.enable | true | Enable treefmt |
Root-flake usage
Sub-flake usage (recommended)
Isolate dev dependencies in ./dev/ so they don't pollute the main flake's closure. Use flake-parts partitions in the root flake to wire it in.
`./dev/flake.nix` — inputs only, no outputs:
`./dev/flake-module.nix`:
Root `flake.nix` — wire in via partitions:
Extending defaults
All underlying options from devshell, git-hooks-nix, and treefmt-nix remain fully accessible:
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingmodules/home/profiles/user/terje/programs/opencode/skills/flake-parts/SKILL.md
Popularity
- Repository stars
- 104
- Repository forks
- 5
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/terlar/nix-config/flake-parts)