-
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
Support custom GHC installation hooks #5585
Support custom GHC installation hooks #5585
Conversation
7e65c4f
to
ad4849e
Compare
cad9878
to
73a6831
Compare
Any movement here? I'm happy to maintain this feature/codepath. |
73a6831
to
204967c
Compare
204967c
to
2da7e9b
Compare
May I ask what sort of practical problems the availability of this feature is intended to solve? Is it primarily that some users want to use a GHC other than a Stack-supplied one and other than one that is on their PATH? (If so, what prevents those users from adding the path to the desired GHC to the head of their PATH and using I appreciate that a hook that is a script is all-flexible/all-powerful, but what troubles me is: could a bad actor not sneak a damaging Would it not be better to specify expressly the script to use on the command line and/or in a Stack configuration file? Stack already has |
Its purpose is for users to be able to decide how GHC is installed. This can be your package manager, can be a nix script or can be ghcup. Stack is not flexible enough currently to cover these use cases. Currently, most stack users of haskell-vscode use
This was also the last missing piece during the (failed) unified installer proposal that caused ghcup to not install stack by default, because integration with ghcup was not really possible. This would fix it.
MSYS2 is installed by both stack, ghcup and chocolatey. If you don't have an msys2 toolchain, you won't be able to build a lot of packages, e.g. any package that has a configure script. It can reasonably be assumed that users have it. I won't be implementing powershell solutions or other things. This would complicate the logic and make it non-uniform across platforms.
No. If a bad actor can place files on the users system, they can just place a malicious stack binary into PATH. This approach is used by git itself, many linux package managers and other tools. It's a common design pattern.
No, because that would mean any tool (e.g. ghcup) would now have additional complication of trying to figure out if a hook is even installed. This makes the install location somewhat predictable. It can be debated whether to allow per-project hooks, but that can be solved in a later PR. No one has requested this for now. My suggestion is to not make this unnecessarily complicated for the first round. It can always be adjusted later. |
Thanks for the explanations. In the spirit of the recent additions to Stack's CONTRIBUTING.md, I'll merge this. On most users wanting only one tool to install GHC, that is true for me too. I also do not want duplicate copies of GHC on my system; GHC is large and my hard drive is not. So I use only the Stack-supplied GHCs. The same is true for MSYS2 (so I use only the Stack-supplied MSYS2). I have used Stack, VS Code and the Haskell extension for VS Code (or its predecessors) for a long time. Anecdotally - and briefly, given this Discourse https://discourse.haskell.org/t/get-a-haskell-development-environment-in-three-steps/4822 which looks like it may help me - when the VS Code extension changed recently to prompt for GHCup, I looked up GHCup to see what it was. However, I could not work out how to install it without it also installing a copy of GHC and MSYS2, which seemed to me to duplicate what I knew Stack did and provided. I was also disappointed to read in its User Guide that its basic usage was not available on Windows. So, at that time, I took up the option not to use GHCup with the extension. |
Also note that ghcup can easily reuse the stack msys2 installation. The user can supply an alternative location during the install script now. Windows works fine. |
Thanks for merging this. As I indicated, I'm happy to maintain this codepath. So ping me whenever there's an issue with it. I'll do some follow up patches to ghcup to finalize integration with stack and will ping you for review. Ghcup development happens on GHC GitLab. Do you have an account there? |
Here are the rendered docs for this feature in current stack master: |
This adds GHC installation hooks. The feature is described in the documentation. I tested it with the newly added integration test.