一键导入
nix-packaging
Package software for Nix when it's missing from nixpkgs or outdated. Covers pre-built binaries, Rust/Go/Node projects, and multi-platform derivations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Package software for Nix when it's missing from nixpkgs or outdated. Covers pre-built binaries, Rust/Go/Node projects, and multi-platform derivations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | nix-packaging |
| description | Package software for Nix when it's missing from nixpkgs or outdated. Covers pre-built binaries, Rust/Go/Node projects, and multi-platform derivations. |
Workflow for adding new or updated software to a Nix flake-based dotfiles setup.
Is the package in nixpkgs?
├── No → Check upstream GitHub releases for pre-built binaries
│ ├── Yes (Linux/macOS binaries available) → Use pre-built binary approach
│ └── No → Build from source (Rust/Go/Node/etc.)
└── Yes → Is it outdated?
├── No → Use nixpkgs version
└── Yes → Check upstream releases
├── Pre-built binaries? → Use binary approach
└── Only source? → Custom derivation with src override
| Situation | Approach | File Location |
|---|---|---|
| Missing from nixpkgs, has binaries | Pre-built binary | pkgs/<name>/default.nix |
| Missing from nixpkgs, must build | Custom build | pkgs/<name>/default.nix |
| Outdated in nixpkgs | Overlay or custom pkg | overlays/ or pkgs/ |
| Flake available upstream | Add as flake input | flake.nix inputs |
Use when upstream provides Linux/macOS binaries in GitHub releases.
{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, zlib
}:
let
inherit (stdenv.hostPlatform) system;
sources = {
x86_64-linux = {
url = "https://github.com/OWNER/REPO/releases/download/vVERSION/PACKAGE-VERSION-x86_64-unknown-linux-gnu.tar.gz";
hash = "sha256-PLACEHOLDER";
sourceRoot = "PACKAGE-VERSION-x86_64-unknown-linux-gnu";
};
aarch64-darwin = {
url = "https://github.com/OWNER/REPO/releases/download/vVERSION/PACKAGE-VERSION-aarch64-apple-darwin.tar.gz";
hash = "sha256-PLACEHOLDER";
sourceRoot = "PACKAGE-VERSION-aarch64-apple-darwin";
};
};
srcInfo = sources.${system} or (throw "Unsupported system: ${system}");
in
stdenv.mkDerivation rec {
pname = "package-name";
version = "X.Y.Z";
src = fetchurl {
url = srcInfo.url;
hash = srcInfo.hash;
};
# Linux-only: auto-patch ELF binaries
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
zlib
stdenv.cc.cc.lib # libstdc++.so.6, libgcc_s.so.1
];
dontBuild = true;
dontConfigure = true;
sourceRoot = srcInfo.sourceRoot;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp binary-name $out/bin/
# Optional: create alternative name
ln -s $out/bin/binary-name $out/bin/alternative-name
runHook postInstall
'';
meta = {
description = "Brief description";
homepage = "https://github.com/OWNER/REPO";
license = lib.licenses.mit;
mainProgram = "binary-name";
platforms = builtins.attrNames sources;
};
}
{ lib
, rustPlatform
, fetchFromGitHub
, pkg-config
, stdenv
, darwin
}:
rustPlatform.buildRustPackage rec {
pname = "package-name";
version = "X.Y.Z";
src = fetchFromGitHub {
owner = "github-owner";
repo = "repo-name";
rev = "v${version}";
hash = "sha256-PLACEHOLDER"; # Get with nix-prefetch-url or lib.fakeHash
};
cargoHash = "sha256-PLACEHOLDER"; # Get with lib.fakeHash, then replace
nativeBuildInputs = [ pkg-config ];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.Security
];
# Skip tests that fail due to environment differences
doCheck = false;
meta = {
description = "Description";
homepage = "https://github.com/OWNER/REPO";
license = lib.licenses.mit;
mainProgram = "binary-name";
};
}
nix-prefetch-url --type sha256 "https://github.com/OWNER/REPO/releases/download/vVERSION/FILE.tar.gz"
hash = lib.fakeHash; # or "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
Build once, copy the "got" hash from the error message, replace.
nix-prefetch-git --url https://github.com/OWNER/REPO --rev vVERSION
mkdir -p pkgs/<name>
# Write default.nix
# home/common.nix (for shared packages)
{ config, pkgs, ... }:
let
mypackage = pkgs.callPackage ../pkgs/<name>/default.nix {};
in
{
home.packages = with pkgs; [
# ... other packages
mypackage
];
}
# NixOS
sudo nixos-rebuild switch --flake .#hostname
# Darwin
darwin-rebuild switch --flake .#hostname
cd ~/dotfiles
nix-build -E 'with import <nixpkgs> {}; callPackage pkgs/<name>/default.nix {}'
# Test the binary
./result/bin/<binary> --version
nix-instantiate --parse pkgs/<name>/default.nix
| Issue | Solution |
|---|---|
auto-patchelf: libstdc++.so.6 not found | Add stdenv.cc.cc.lib to buildInputs |
hash mismatch | Use error's "got:" hash, or lib.fakeHash |
source root not found | Set correct sourceRoot matching tarball structure |
| Tests fail | Add doCheck = false; if tests are environment-sensitive |
| Darwin build fails | Add relevant frameworks from darwin.apple_sdk.frameworks |
See references/ for:
binary-template.nix - Complete pre-built binary templaterust-template.nix - Complete Rust build from source templateoverlay-example.nix - Overlay for overriding nixpkgs packagesUse the local kagi-cli for Kagi search, news, smallweb, quick answers, assistant, translate, and subscriber summarization. Trigger when asked to use Kagi or kagi-cli.
Teaching-assistant mode for hint-first help, conceptual explanations, debugging guidance, and code review without defaulting to full solutions. Use when the user wants to learn, be coached, or get guided help instead of direct code generation.
Documentation-driven development using Air - a filesystem-based planning tool. Use when working with Air documents, managing project specifications, tracking implementation progress, or when the user mentions Air, airctl commands, or documentation-driven development workflows.
Navigate and modify Nix-based dotfiles with flakes and home-manager. Use when working with nix configs, finding where settings live, or understanding the repository structure.
Create or update Pi skills (SKILL.md plus optional scripts, references, or assets). Use when someone asks to design a new Pi skill, refine an existing one, or structure skills for Pi discovery or packaging.
Guide for extending Pi — decide between skills, extensions, prompt templates, themes, context files, or custom models, then create and package them. Use when someone wants to extend Pi, add capabilities, create a skill, build an extension, or make a Pi package.