Complex pixi task workflows and orchestration. Use when building task dependency chains, configuring caching with inputs/outputs, creating parameterized tasks, or setting up CI pipelines—e.g., "pixi task depends-on", "task caching for build automation", "multi-environment test matrices".
Complex pixi task workflows and orchestration. Use when building task dependency chains, configuring caching with inputs/outputs, creating parameterized tasks, or setting up CI pipelines—e.g., "pixi task depends-on", "task caching for build automation", "multi-environment test matrices".
Pixi Tasks
Purpose
Complex task patterns: dependency chains, caching with inputs/outputs, cross-environment workflows.
YOU MUST use depends-on for execution order. Tasks without explicit dependencies execute in undefined order and will fail in CI pipelines. No exceptions.
Every time you have multiple upstream dependencies, use this pattern. Tasks with multiple depends-on entries wait for ALL dependencies to complete before executing.
Cache invalidates immediately when ANY of these conditions are met:
Input file changes (hash mismatch)
Output file missing
Command string changes
Environment packages change
Caches without proper inputs/outputs are always stale. Define both or accept that your tasks will re-run unnecessarily.
Platform-Specific Tasks
Define tasks that behave differently per platform using [target.<platform>.tasks]. Pixi automatically selects the correct implementation based on the current platform.
# Target-agnostic tasks that depend on platform-specific setuptask = { cmd = "echo 'Running main task'", depends-on = ["setup"] }
[target.linux-64.tasks]setup = { cmd = "echo 'Linux setup'", description = "Setup for Linux" }
[target.osx-arm64.tasks]setup = { cmd = "echo 'macOS setup'", description = "Setup for macOS" }
pixi run task # Runs the correct 'setup' for your platform, then 'task'
Platform-Specific Dependencies + Tasks
Combine with [target.<platform>.dependencies] to install packages only on specific platforms:
# Install stow only on Linux (via conda-forge)[target.linux-64.dependencies]stow = "*"# Target-agnostic taskstask = { cmd = "stow --version", depends-on = ["check-stow"] }
# Platform-specific setup tasks (same name, different implementations)[target.linux-64.tasks]check-stow = { cmd = "which stow", description = "Verify stow is available (pixi-installed)" }
[target.osx-arm64.tasks]check-stow = { cmd = "which stow || (echo 'Install with: brew install stow' && exit 1)", description = "Verify stow is available (brew-installed)" }
Key insight: Tasks with the same name in different [target.*.tasks] sections are automatically resolved based on the current platform. Target-agnostic tasks can depend on these platform-specific tasks by name.
Cross-Environment Tasks
Run tasks across multiple environments. Always test in all target environments before committing. Environment-specific failures in CI are expensive and avoidable.