-
Notifications
You must be signed in to change notification settings - Fork 63
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
Haskell Server Wrapper Function for Stack specific $PATH #111
Comments
Would it be something lke: (lambda (argv)
(let
((original-path (getenv-internal "PATH"))
(stack-env-path (shell-command-to-string "stack config env")) ;; TODO: handle case when stack is not present
(args ((mapconcat ’identity argv " "))))
(list (format "env PATH=%s:%s %s" ;; Should it handle empty environment variable case here?
original-path stack-env-path args)))) ??? Result (in *Messages*):
And no |
Also here possible lags with |
Maybe the people have difficulty responding, because the case & semantics are not ordered. It is hard to parse the semantics, even weak interpretation does not infer into the concrete case. It would be easier to understand if you would describe the environment of the project, what is used for what, and then nail the case. Overall, from my experience, and from referring to the current official Stack docs, Stack just as 3 years ago, has very weak Nix integration: link. Cabal has much better integration with Nix, running in Nix environment. Cabal would detect that it is running in Nix environment & would use Nix to load dependencies & work as Nix client, download the Haskell binary caches from Nixpkgs Hydra CI, and store the build artifacts in Nix. Also, important to note that
Tangent: Stack in Nix is also a legitimate combination, if the project uses a lot of FFI & so system package dependencies. But, overall the solution may be (if I understand the question correctly) as simple as this:
Note: ⬆️ It is true. It was true when it was written, & it is the same currently. Would spare the details, but can recommend not do shell work for Nix, or if do any - upfront be ready to throw the work out the window to not be disappointed. Nix taught me to not care to contribute when doing contribution, as caring does not depend on me but on one holding the "merge" button. Also important to note that some "deep" Nix people - use all bashisms possible, which heavily hardcodes Nix to Bash. When operating with Nix in the code - the I'd wanted to give less of a disclaimer, but the solution involves quirks that demand to be mentioned to implement proper solutions & save people's time upfront. Sadly there is a lot of such open secret undocumented technical difficulties which when researched are frequently caused by social context reasons, seems like Nix details (at least in the past) borrowed heavilly from the Conway's law & Cognitive dimensions of notations. |
Yuriy @Pitometsu, can the topic be closed? Having somewhat extensive knowledge on the Haskell tooling & Nix situation both from prior work experience ("having skin in the game" with Stack & Nix situation in the past at work, where I built infrastructure pipeline) & my current experience with them and knowing new things on it. The only thing I can tell - is that Stack and Nix combination completely disintegrates in the main agenda of them (the dependency/package management, Stack goes its own way, has own package inference, own system of building artifacts, while Nix infra demands 100% declarative descriptiveness & reproducibility & integration from Stack, which Stack does not provide for Nix, which produces a result that accumulates downsides of both - not reproducible builds that are not declarative, caching does not work, no deduplication, therefore the set size of the build artifacts during work is tremendous, builds always start anew, the number of custom hacks required is "the more hacks the better" which is a nice indication that path does not work, the maintenance cost of combination is unreasonable, it is undocumented, unsupported use, so no support from both upstreams...). So far Nix & Stack are not designed for each other. Use of Cabal(or HPack or DHall) with Nix is much more happy path & reasonable choice that should succeed. |
I have errors like
when run
haskell-language-server
. I guess the reason is becausehspec-discover
inpackage.yaml:tests:build-tools:
, and so installed bystack
(not bynix-shell
as rest, not-build-specific, tools).But I have no such problems when run it like
env PATH=$PATH:`bash -c 'source <(stack config env); echo $PATH'` haskell-language-server
.I can't just run
stack exec haskell-language-server
to just simply have all thestack
's environments available, becausestack
usingnix --pure
for more robust and reproducible builds, and so that cause nix shells conflicts (not sure -- is it because of shells recursivity, orstack
can't decide, which nix shell is build one, according toSTACK_IN_NIX_SHELL
environment variable, I guess).So the question is: how construction like
env PATH=$PATH:`bash -c 'source <(stack config env); echo $PATH'` haskell-language-server
could be passed tolsp-haskell-server-wrapper-function
properly?Possible workaround would be: just add each tool from
stack
'spackage.yaml:tests:build-tools:
(likehspec-discover
here) into top-levelshell.nix
, but that would be fragile and require continuous project build tools consistency manual maintaining.The text was updated successfully, but these errors were encountered: