-
Notifications
You must be signed in to change notification settings - Fork 841
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
Using environment variables in stack.yaml #1375
Comments
I'm sure you've thought of this, but you could have a script generate the |
Yes, I can see this being a good reason to support environment variables. Aside: this is also an excellent use case for Stack's Docker integration (or other ways to achieve similar objectives, like Vagrant).
This seems like it's a recipe for losing reproducibility, unless done with great care. And it's the temptation to do this sort of thing that causes me to have misgivings about letting anything external (like environment variables) effect how stack.yaml is interpreted. Legit uses for this outweigh the misgivings, though, but it should be restricted to simple string substitution (avoid the temptation to essentially make a templating solution for stack.yaml). Perhaps something like the environment substitution supported by Yesod's settings.yml. |
Perhaps instead you could provide an environment variable that tells stack to run a script to get its |
Sharing info between stack.yaml files just came up in #haskell-stack (pinging @bitemyapp @MichaelXavier). This is another example of nice-to-have features for the configuration in general. I'm a bit concerned that going down this road could be a pandora's box of complexity for both stack code and for users' mental model. I like @3noch's idea, though it would be nice to support arbitrary generate: yaml-generator arg1 arg2
resolver: lts-3.13
packages:
- yaml-generator The |
@3noch/@mgsloan: I hope I'm not being too obstinate, but I really think if you need this level of sophistication you should wrap |
A PR adding simple environment variable substitution would be welcome (but if you want to do more than that, we should discuss further first). |
@borsboom I'm with you. I'd actually prefer not to have any special handling for this case at all, since it greatly complicates things. EDIT: I only suggested that idea in the hopes of moving sophistication out of stack. Basic environment variable substitution seems like a nice compromise. |
Tend to agree with @borsboom - most of my more developed projects wrap Stack with Makefiles and I'm pretty grateful (so far) that |
Yeah, I agree with that! Making this the domain of your own build system / scripts is quite reasonable. I like that the stack.yaml will necessarily be in the filesystem (whereas with my It might be good to figure out some recommended approaches for this templating / inheritance, though. This way, we're more likely to end up with a bunch of projects which do something similar, so it's easier to start developing on them. This can wait a while, let's see what folks come up with. |
I'll just say +1 on keeping things simple. I hit this very case today where for ease of development it made sense that my default stack.yaml would not use docker, but to produce consistent bins for testing and deployment, I wanted the docker functionality. It was 3 or 4 lines in my shake build to add a rule for building |
The initial environment variable substitution proposal would be extremely useful for SMACCMPilot. It looks like the Ruby world uses embedded ruby syntax to splice in environment variables, e.g.:
It would be ... overkill to import
It seems like we could
I'm not very familiar with the code either for Stack or |
I'm bumping the priority here because more issues have cropped up that would profit from a solution of this. |
This would be useful for the global stack configuration. |
(My attention was drawn here from Haskell Weekly.) If what is desired is something like this:
What about using something like an "extra-deps" folder that is gitignored and contains symlinks?
Where |
Depending on non-versionable settings like environment variables would make Stack less reproducible, which is my favorite thing about it. For something we all have to use like stack files the simpler, the better. I'd vote to close this, which would also bring down the number of open issues to a nice round 695:grin: |
Sure, closing for now! I am starting to like the idea of allowing flags and interpolation by default in stack yaml, I have seen some good uses for it, particularly conditionals on OS. But I definitely like keeping it as simple as possible. Perhaps the future solution will be to have something like |
Hi! Would you be so nice and dd ability to use environment variables within stack.yam configuration files? This would be a life saver in a situation when a big team develops a set of libraries and every person keeps these libraries in different places, so the environment variable would point where are the sources that should override packages from Hackage.
Another small topic is to add extra dependencies recursively - all packages found in folder X. In such use case we can easily override packages for development time without changing stack yams configuration and this (n combination with the above idea) is a very useful utility, portable across developer environments.
Thank you! :)
The text was updated successfully, but these errors were encountered: