Goals:
- Avoid repeating values
- Make it easy to interact with a full tree of tasks
[vars]
profile = "--release"
[tasks.install]
cmd = "cargo install {{ profile }}"
[tasks.test]
depends-on = ["install"]
cmd = "cargo test {{ profile }}"
pixi run test
# Runs:
# cargo install --release
# cargo test --release
pixi run --var profile=--debug test
# Runs:
# cargo install --debug
# cargo test --debug
[vars]
profile = "--release"
[tasks.install]
cmd = "cargo install {{ profile }}"
[feature.test.vars]
profile = "--debug"
[feature.test.tasks.test]
depends-on = ["install"]
cmd = "cargo test {{ profile }}"
[environments]
test = ["test"]
pixi run install
# Runs:
# cargo install --release
pixi run test
# Runs:
# cargo install --release
# cargo test --debug
pixi run --environment test test
# Runs:
# cargo install --debug
# cargo test --debug
pixi run --var "profile=--profile" test
# Runs:
# cargo install --profile
# cargo test --profile
[vars]
profile = "--release"
[tasks.install]
cmd = "cargo install {{ profile }}"
[feature.test.vars]
profile = "--debug"
[feature.test.tasks.test]
depends-on = ["install"]
cmd = "cargo test {{ profile }}"
[environments]
test = { features= ["test"], no-default-feature = true }
pixi run install
# Runs:
# cargo install --release
pixi run test
# Runs:
# cargo install --release
# cargo test --debug
pixi run --environment test test
# Task `install` doesn't exist in environment "test", so it will run in environment "default" instead.
# Runs:
# cargo install --debug
# cargo test --debug
pixi run --var "profile=--profile" test
# Runs:
# cargo install --profile
# cargo test --profile
We need to take care when we merge vars. The current behaviour is that, that the first feature wins:
[feature.test1.vars]
profile = "--debug"
[feature.test1.tasks]
start = "cargo test {{ profile }}"
[feature.test2.vars]
profile = "--release"
[envs]
test = ["test2", "test1"]
Running should behaves as follows:
$ pixi run start
cargo test --release
Keep in mind, that unless no-default-feature=true
, the default feature is always implicitly appended:
test = ["test2", "test1", "default"]