Adding support for environment variable in `inputs` and `outputs` field
I want to be adding support for environment variable in inputs and outputs field
Problem description
For example being able to do
[tasks.mkdir_test]
cmd = "mkdir -p $INIT_CWD/test"
outputs = ["$INIT_CWD/test"]
or
[tasks.mkdir_test]
args = [
{ arg = "root", default = "$INIT_CWD"}
]
cmd = "mkdir -p {{ root }}/test"
outputs = ["{{ root }}/test"]
For now it returns
pixi run mkdir_test
✨ Pixi task (mkdir_test in default): mkdir -p $INIT_CWD/test
WARN No files matched the output globs for task 'mkdir_test'
WARN Output globs: `$INIT_CWD/test
Where it should return for example
pixi run mkdir_test
✨ Pixi task (mkdir_test in default): mkdir -p $INIT_CWD/test
pixi run mkdir_test
✨ Pixi task (mkdir_test in default): mkdir -p $INIT_CWD/test
Task '_mkdir_outputs' can be skipped (cache hit) 🚀
ls
test/
With no warning
hey can i work on this issue ?
I like the suggested syntax, and I think mise uses the same: https://mise.jdx.dev/environments/#environment-in-tasks
Another idea could be to use env.THING, similar to how rattler-build is exposing the env context, but I think it's too complex.
But @ruben-arts should give his approval on this
Yeah I think we should scope to args!
The $ENV_VAR would be a custom parsing job. Just like Nichita and Bas say. Doing it first for the args would be a good step forward. The env.THING would be nice but is much more involved. Because pixi can control the env. So which env does it use.
The {{ pixi.xxx }} standard arguments could potentionaly be extended with the init_cwd to help with simplifing the usecase in the initial issue description.
I see INIT_CWD is set in get_task_env() in executable_task.rs at runtime. For the {{ pixi.init_cwd }} approach, should we use std::env::current_dir() directly in to_jinja_context(), or is there a preferred way to access this earlier in the rendering pipeline?
Feel free to make the PR, sounds like you have a pretty good idea of whats going on.