wenjinnn/.dotfiles/nix-packing
Claude Code and agent skill by wenjinnn/.dotfiles
- community
Checking that the SKILL.md file is still in the repository.
Add a package to a Nix flake the reproducible way. Use when the user wants to install a package that is not in nixpkgs, package a pi/npm extension for Nix, provides a pi.dev/packages URL, or asks to write a derivation or update an existing package with new hashes. Covers attribute lookup, derivation writing, dependency lock generation, hash computation, and build verification.
Install
npx vskill@latest install wenjinnn/.dotfiles/nix-packingSKILL.md
Nix Packing
Add any package to a Nix repository — a nixpkgs-existing reference, a pi/npm extension, or a hand-written derivation — through one reproducible loop.
When to Use
- User provides a
pi.dev/packages/<name>ornpmjs.org/package/<name>URL - User asks to "add", "package", or "打包" a package/extension for Nix
- A tool needed in the flake is not in nixpkgs (or the attribute name is unknown)
- Updating an existing package: new version, hash mismatch, or new dependencies
Prerequisites
- Working directory: a flake repository root (contains
flake.nix; pi packages live underpkgs/pi-packages/) - Nix with flakes enabled
- npm (only for npm-dependency packages, to generate lock files)
Procedure
Step 1: Locate the package
- nixpkgs already has it (
nix search nixpkgs <term>, ornix eval nixpkgs#<attr>.namesucceeds) → stop: reference the existing attribute inhome.packages/environment.systemPackages/ an overlay. No packaging needed - Otherwise, classify the source:
- npm extension (pi plugin, etc.) → Step 2 with the npm flow
- GitHub or other tarball source → Step 2 with the
fetchFromGitHubflow
Step 2: Write the definition
npm extension:
- Get metadata:
``bash curl -s "https://registry.npmjs.org/<scope>/<name>/latest" | jq '{name, version, dependencies, peerDependencies}' ``
- Decision: no real
dependencies(onlypeerDependenciesor none) → simple extraction (npmDepsHash = ""); hasdependencies→buildNpmPackagewith a realnpmDepsHash - Get the tarball hash:
``bash HASH=$(nix-prefetch-url --unpack "https://registry.npmjs.org/<scope>/<name>/-/<name>-<version>.tgz") nix hash to-sri --type sha256 "$HASH" ``
fetchFromGitHub:
Step 3: Lock dependencies (npm packages only)
- Extract the tarball to a scratch dir and run
npm install --package-lock-only - Clean the lock file — remove private/unpublished deps. Pi-internal
@earendil-works/*packages are not on npm, andprefetch-npm-depsfails on them without integrity:
``bash jq '.packages |= with_entries(select(.key == "" or (.key | test("node_modules/@earendil-works") | not)))' \ package-lock.json > package-lock-cleaned.json ``
- Copy it to the repo's lock dir (e.g.
pkgs/pi-packages/locks/<name>-<version>.json, per repo convention) - Discover
npmDepsHash: build with a placeholder hash and read thegot:value from the error
Step 4: Single-package build
nix build .#<pkg-attr>(e.g.nix build .#piPackages."<scope>/<name>") — NOT a full system rebuild- Hash mismatch → update with the
got:value and rebuild; never disable the sandbox or relax fixed-output downloads - Verify the output:
ls result/, andls result/node_modules/when it has dependencies
Step 5: Wire into the declaration source
- Add the package entry to the repo's package set (
pkgs/pi-packages/default.nixfor pi packages; overlays for custom packages) - Add it to the repo's update checker if one exists (
scripts/check-updates.shPACKAGE_SOURCES) - Back up runtime data owned by the package BEFORE switching (see
secrets.mdin nix-first: runtime data never goes into the store)
Step 6: Update loop
- New version: bump
version, re-fetchhash, regenerate the lock, rebuild - Flake input bumps go through
nix flake update <input>— never editflake.lockby hand - Lock changes go in a separate commit from code changes
Pitfalls
- Hash mismatch: always use the
got:value from the error — thenix-prefetch-urlhash can differ from the build hash - `lib.fakeHash` (all-A hash) means "no dependencies" to some helpers — never use it for packages with real dependencies
- Untracked lock files: flakes ignore untracked files —
git addthe lock file before building - Never disable the sandbox or relax pinned downloads to fix a hash
Verification
nix build .#<pkg>succeeds from a clean checkout- The update checker (if any) lists the new package
git log -1shows the commit with the right message
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingmodules/home-manager/llm/skills/nix-packing/SKILL.md
Popularity
- Repository stars
- 114
- Repository forks
- 9
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
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/wenjinnn/.dotfiles/nix-packing)