AgentSkillsCN

nix-workflow

为 NovelSaga 使用 Nix 开发环境与构建系统——适用于 Nix 配置或可复现的构建流程。

SKILL.md
--- frontmatter
name: nix-workflow
description: Nix development environment and build system for NovelSaga - use for Nix configuration or reproducible builds

Nix Workflow

Quick Reference

  • Development: direnv allow loads environment automatically
  • Build CLI: nix build or nix build .#cli
  • Build All: nix build .#bundle

Development Environment

bash
# First time setup
direnv allow

# Verify environment
which cargo          # Should point to Nix store
which node           # Should point to Nix store

Build Targets

TargetCommandOutput
CLI onlynix buildresult/bin/novelsaga
Full bundlenix build .#bundleCLI + WASM + .so

Hash Update Process

When pnpm-lock.yaml changes:

  1. Set placeholder in packages.nix:

    nix
    hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
    
  2. Get correct hash:

    bash
    nix build .#bundle 2>&1 | grep "got:"
    
  3. Update packages.nix with new hash

Troubleshooting

IssueSolution
Hash mismatchUpdate pnpmDeps hash
Nightly features errorEnsure fenix overlay active
rust-analyzer not workingRun direnv allow, reload VSCode

When to Use

Load this skill when:

  • Modifying flake.nix, packages.nix
  • Running Nix builds
  • Troubleshooting environment issues