Open dysinger opened 5 years ago
/cc @chrisdone as it relates to intero
Related @acowley has patched his emacs to stop trying to dynamically install intero on Nix
Reviewing the code:
This is happening because of Stack.Nix line #78
Where in only adds the STACK_PLATFORM_VARIANT='nix' if you don't use a shell-file. If I add this environment variable to my local shell.nix then it stops wobbling back and forth (global vs project)
I think the solution is to always put in the environment for nix projects.
An example of a shell.nix that works with currently deployed stack.
with (import <nixpkgs> {});
haskellPackages.shellFor {
packages = ps: with ps; [
# ADD THIS LOCAL PROJECT'S ENVIRONMENT TO OUR SHELL
my-project
];
# ADD HOOGLE & INDEX ALL HASKELL PACKAGES
withHoogle = true;
# ADD ALL THE OTHER GOOD HASKELL DEV TOOLS
nativeBuildInputs = with haskellPackages; [
cabal-install
cabal2nix
ghcid
hindent
hlint
hpack
intero
pointfree
stack
];
# STACK INJECTS THIS VARIABLE WHEN YOU DON'T USE A shell.nix FILE.
# THIS SETTING CHANGES SOME COMPUTED PATHS LIKE `compiler-tools-bin`
# See https://github.com/commercialhaskell/stack/issues/4950
STACK_PLATFORM_VARIANT = "nix";
}
Me (above): "I think the solution is to always put in the environment for nix projects."
Maybe this works as intended. I'm not familiar enough with Stack internals these days.
Sorry for the lack of response + thanks for the thorough details @dysinger!
I'm not really familiar enough to comment on this corner of stack
either but it seems like @qrilka might be a good bet based on how many nix
-related questions I've seen him answer.
Good luck!
General summary/comments (optional)
When using Nix with Stack and with the setting of
(in
~/.stack/global-project/stack.yml
) thenstack path --compiler-tools-bin
gives a result of/home/tim/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin
(notice x86_64-linux-nix)BUT if I add a
shell-file
attribute (and remove packages)(in
~/.stack/global-project/stack.yml
) thencd ~/.stack/global-project ; stack path --compiler-tools-bin
gives a result of/home/tim/.stack/compiler-tools/x86_64-linux/ghc-8.6.5/bin
(notice x86_64-linux) but if you just leave the ~/.stack/global-project/stack.yml file alonecd ~ ; stack path --compiler-tools-bin
gives a result of/home/tim/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin
(notice x86_64-linux-nix)Steps to reproduce
stack path --compiler-tool-bin
setting change (depending on what directory you are in: project, non-project or ~/.stack/global-project dirs)Expected
I expect that if I'm on NixOS and I set Nix to
enable: true
that the complier-tools-bin path wouldn't change.Actual
This switching around the compiler-tool-bin dir breaks
intero
's self-installing into crumbling bits as it installs intero into/home/tim/.stack/compiler-tools/x86_64-linux-nix/ghc-8.6.5/bin
(sometimes global compiler-tools-bin path) but then checks if the executable is on disk in/home/tim/.stack/compiler-tools/x86_64-linux/ghc-8.6.5/bin
(project's compiler-tools-bin path)The same problems happen when a local project has the same changes happening to it's local stack.yml
Stack version
1.9.3
Method of installation
nixpkgs