Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support injecting dotenv environment variables into tasks #1330

Open
croth1 opened this issue May 6, 2024 · 3 comments
Open

Support injecting dotenv environment variables into tasks #1330

croth1 opened this issue May 6, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@croth1
Copy link

croth1 commented May 6, 2024

Problem description

pixi tasks nicely support environment variables. Being able to inject environment variables from a .env file could make it easy for injecting host-specific environment variables into pixi run <task-name> without having to manually source the .env file first.

I will leave this here for voting. It's a nice-to-have for me - maybe somebody else would also find this useful for their workflow?

@croth1 croth1 added the enhancement New feature or request label May 6, 2024
@croth1 croth1 changed the title Add support for injecting dotenv environment variables into tasks Support injecting dotenv environment variables into tasks May 6, 2024
@bollwyvl
Copy link
Contributor

bollwyvl commented May 6, 2024

I've been using generated .env's as outputs to isolate/generate settings in the absence of a solid matrix mechanism.

If .env is supported, seems like it would need a fair amount of specificity to handle the breadth of ways it is used, ideally providing a way to compose in a predictable order with other configuration:

[tasks.build]
cmd = "whatever"
env = {FOO="bar"}
env-file = ".env"
# or
env-file = [".env", ".env.dev"]
# and maybe
depends-on = [
  { task="preflight", environment="build", env={FOO="$FOO"}, env-file=[".env.another"] }
]

@croth1
Copy link
Author

croth1 commented May 6, 2024

@bollwyvl, interesting, to be honest I haven't thought about how deep this needs to go - just a weekend observation 😬 Would be one env file per environment enough for your use case? Behaviour like:

By default all environments will source .env. Beyond that allow overwriting this behaviour by setting one per environment, like:

[environments.test]
features = ["test"]
env-file = ".test.env"

(config example is not an implementation suggestion, just for conveying the concept)

@bollwyvl
Copy link
Contributor

bollwyvl commented May 6, 2024

Merely pointing to the flexibility afforder by e.g. task.

As usual: whatever it does, just needs to do that thing consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants