just Overlays
Platform-specific justfiles enable cross-platform development while keeping tasks consistent.
The Pattern
Section titled “The Pattern”The root justfile imports platform-specific overlays:
# justfile (root)import? 'justfile.linux'import? 'justfile.darwin'import? 'justfile.windows'import? 'justfile.container'The ? makes imports optional—missing files don’t cause errors.
Overlay Hierarchy
Section titled “Overlay Hierarchy”project/├── justfile # Cross-platform recipes├── justfile.linux # Linux-specific overrides├── justfile.darwin # macOS-specific overrides├── justfile.windows # Windows-specific overrides└── justfile.container # Container environment overridesHow Overlays Work
Section titled “How Overlays Work”Base Recipe
Section titled “Base Recipe”# justfilebuild: cargo build --releasePlatform Override
Section titled “Platform Override”build: cargo build --release --target x86_64-unknown-linux-muslWhen running on Linux, just build uses the overlay definition. On other platforms, it falls back to the base recipe.
Container Overlay
Section titled “Container Overlay”For containerized builds where the same command should work on host and inside containers, see the Container Overlay Pattern. This technique mounts a container-specific build file over the host file, eliminating conditionals entirely.
Common Patterns
Section titled “Common Patterns”Tool Availability
Section titled “Tool Availability”brew-deps: brew install just skaffold helm kubectl
# justfile.linuxapt-deps: sudo apt-get install -y just # Manual install for others...Path Differences
Section titled “Path Differences”socket := "/run/podman/podman.sock"
# justfile.darwinsocket := "~/.colima/default/docker.sock"Binary Names
Section titled “Binary Names”container-runtime := "podman"
# justfile.darwincontainer-runtime := "docker"Example: Angzarr
Section titled “Example: Angzarr”Angzarr uses overlays for devcontainer detection and cross-language formatting:
# justfile (base) - runs formatters in containers_lang-container LANG +ARGS: #!/usr/bin/env bash if [ "${DEVCONTAINER:-}" = "true" ]; then {{ARGS}} else podman run --rm -v "{{TOP}}:/workspace:Z" -w /workspace \ ghcr.io/angzarr-io/angzarr-{{LANG}}:latest {{ARGS}} fi
fmt-python: just _lang-container python black examples/python client/python
fmt-csharp: just _lang-container csharp csharpier format examples/csharp client/csharpThe DEVCONTAINER environment variable (set inside devcontainers) triggers direct execution, avoiding nested containers. On host, formatters run inside language-specific CI images with the workspace mounted.
See Container Overlay Pattern for the full technique.
Best Practices
Section titled “Best Practices”- Keep base portable — Base justfile should work on most platforms
- Override only what differs — Don’t duplicate recipes unnecessarily
- Document requirements — Note platform-specific tool dependencies
- Test overlays — CI should test all supported platforms
Next Steps
Section titled “Next Steps”- just — Core just commands
- Container Overlay Pattern — Mount-based build file swapping
- Getting Started — Full development setup