NUR Packager
Package projects into Nix User Repository (NUR) derivations end-to-end.
Workflow
- Analyze the input (URL, package name, GitHub repo) to determine what it is and how it distributes releases
- Select the packaging strategy (npm source build, binary release, GitHub source build, etc.)
- Create the derivation under
pkgs/<name>/default.nixand register it in the repo rootdefault.nix - Test the build with
nix buildand verify the result works - Automate updates with a script and GitHub Actions workflow if applicable
Strategy Selection
| Input Type | Strategy | Rule File |
|---|---|---|
| npm/node package on registry | buildNpmPackage or node2nix | npm-packaging |
| GitHub repo with release binaries | Multi-platform fetchurl + hashes | binary-release |
| GitHub repo with source builds | buildGoModule, buildRustPackage, etc. | github-source |
| Curl script / direct download | Extract API, fetch per-platform hashes | binary-release |
| AppImage + DMG | appimageTools / undmg | binary-release |
Quick Reference
| Step | Command |
|---|---|
| Analyze project | Read README, check releases, inspect package.json |
| Create derivation | pkgs/<name>/default.nix |
| Register package | Add name = pkgs.callPackage ./pkgs/name { }; to root default.nix |
| Build | nix build .#<name> |
| Build (unfree) | NIXPKGS_ALLOW_UNFREE=1 nix build --impure .#<name> |
| Test binary | ./result/bin/<name> --help |
| Format check | nix fmt -- --check (if alexnix/fmt or nixfmt is configured) |
| Prefetch hash | nix store prefetch-file --json <url> |
Repo Conventions
- Each package lives in
pkgs/<name>/default.nix - Register with
pkgs.callPackage ./pkgs/<name> { }in rootdefault.nix - Update scripts go in
scripts/update-<name>.shorpkgs/<name>/update.sh - GitHub Actions workflows for auto-updates go in
.github/workflows/update-<name>.yml - All multi-platform binary packages use
sha256BySystemorsourcesattrsets - Maintainer field:
maintainers = [ "lmdevv" ] - Meta fields:
description,homepage,license,platforms,mainProgram
Related Skills
- nix-packaging-best-practices: Binary packaging details (autoPatchelfHook, dependencies, FHS env)
- nix-best-practices: Flake structure, overlays, unfree handling
- nix: Running packages, evaluating expressions, troubleshooting
Rule Files
| Topic | File |
|---|---|
| Analyzing a project | analyze-project |
| Node.js/npm packaging | npm-packaging |
| Binary release packaging | binary-release |
| GitHub source builds | github-source |
| Creating and registering derivations | create-derivation |
| Testing builds | testing |
| Update automation | update-automation |
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md