Expert guidance for maintaining and updating Nix packages in the AgentStation CLI tools repository. Handles version updates, hash management, testing, and integration with Nix flakes ecosystem.
Expert assistance for maintaining Nix packages in the `agentstation/nix-packages` repository. This skill provides guidance on building, testing, and updating Nix derivations for AgentStation CLI tools distributed via Nix flakes.
This skill helps you work with the AgentStation Nix packages repository, which provides Nix derivations for:
The repository enables distribution via Nix, Devbox, and other Nix-compatible systems.
Before making changes, understand the repository layout:
```
agentstation/nix-packages/
├── flake.nix # Main flake exporting all packages
├── flake.lock # Lock file for reproducibility (auto-generated)
├── packages/
│ ├── pocket/
│ │ └── default.nix # Go package derivation
│ └── tydirium/
│ └── default.nix # Shell script derivation
├── README.md # User installation instructions
└── CLAUDE.md # Development guidance
```
Always test packages before committing changes:
**Test individual package:**
```bash
nix build .#pocket
nix build .#tydirium
nix run .#pocket -- --help
nix run .#tydirium -- --help
nix develop
```
**Validate entire flake:**
```bash
nix flake check
```
When a new version of a tool is released, follow this process:
**Step 2.1: Update version in `default.nix`**
Locate the package's `default.nix` file (e.g., `packages/pocket/default.nix`) and update:
**Step 2.2: Update source hash**
Set a placeholder hash first:
```nix
src = fetchFromGitHub {
# ... owner, repo, rev ...
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
```
Then build to get the correct hash:
```bash
nix build .#pocket
```
The error message will show:
```
error: hash mismatch in fixed-output derivation
specified: sha256-AAAA...
got: sha256-<REAL_HASH>
```
Copy the "got" hash and update `default.nix`.
**Step 2.3: For Go packages, update vendorHash**
Go packages require updating `vendorHash` for dependencies:
```nix
vendorHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
```
Build again to get the correct vendor hash:
```bash
nix build .#pocket
```
Update with the hash from the error message.
**Step 2.4: Test thoroughly**
After updating hashes:
```bash
nix build .#pocket
nix run .#pocket -- --version
ls -la result/bin/
ls -la result/share/
```
**Step 2.5: Update flake.lock**
```bash
nix flake update
```
**For Go packages (like pocket):**
```nix
postInstall = ''
installShellCompletion --cmd pocket \
--bash <($out/bin/pocket completion bash) \
--fish <($out/bin/pocket completion fish) \
--zsh <($out/bin/pocket completion zsh)
'';
```
**For shell scripts (like tydirium):**
```nix
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
install -Dm755 tydirium $out/bin/tydirium
wrapProgram $out/bin/tydirium \
--prefix PATH : ${lib.makeBinPath [ dnsutils ]}
'';
```
When adding a new AgentStation tool:
**Step 4.1: Create package directory**
```bash
mkdir -p packages/<tool-name>
```
**Step 4.2: Write `default.nix`**
Choose the appropriate builder:
**Step 4.3: Export in `flake.nix`**
Add to packages output:
```nix
packages = {
pocket = pkgs.callPackage ./packages/pocket {};
tydirium = pkgs.callPackage ./packages/tydirium {};
<tool-name> = pkgs.callPackage ./packages/<tool-name> {};
};
```
**Step 4.4: Test the new package**
```bash
nix build .#<tool-name>
nix run .#<tool-name> -- --help
nix flake check
```
**Update all inputs:**
```bash
nix flake update
```
**Check flake metadata:**
```bash
nix flake metadata
```
**Show available outputs:**
```bash
nix flake show
```
**Format Nix files:**
```bash
nix fmt
```
This repository complements `agentstation/homebrew-tap`:
**Hash mismatch errors:**
**Missing dependencies at runtime:**
**Flake evaluation errors:**
**Build failures:**
1. **Never commit with placeholder hashes** - Always resolve to real SHA256 hashes
2. **Test before committing** - Run `nix build` and `nix run` for all modified packages
3. **Maintain reproducibility** - Update `flake.lock` after version changes
4. **Include completions** - Shell completions, man pages, and documentation should be installed
5. **Handle runtime deps** - Scripts must have access to required system tools
6. **Follow Nix conventions** - Use appropriate builders and standard phase overrides
**Example: Updating pocket to version 0.3.0**
```bash
nix build .#pocket
nix build .#pocket
nix build .#pocket
nix run .#pocket -- --version
nix flake update
git add packages/pocket/default.nix flake.lock
git commit -m "pocket: 0.2.0 -> 0.3.0"
```
**Example: Adding runtime dependency to shell script**
```nix
{ lib, stdenv, fetchFromGitHub, makeWrapper, dnsutils, curl }:
stdenv.mkDerivation rec {
# ... pname, version, src ...
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
install -Dm755 script.sh $out/bin/script
wrapProgram $out/bin/script \
--prefix PATH : ${lib.makeBinPath [ dnsutils curl ]}
'';
}
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/nix-package-development-for-agentstation/raw