haskell-flake
haskell-flake copied to clipboard
Detect globally installed GHC and related tools
The following shellHook will warn if the user accidentally ends up using a non-nix-shell haskell tools (such as that of ghcup). Perhaps haskell-flake can provide this as an opt-in module to import (like #160).
haskellProjects.default = { config, ... }: {
devShell = {
mkShellArgs.shellHook = ''
function samePath {
[[ "$1" == "$2" ]] || (
echo "\n!!! WARNING: Found $1, but expected $2"
)
}
function inNixStore {
[[ "$1" == $NIX_STORE/* ]] || (
echo "\n!!! WARNING: $1 is not in the Nix store"
)
}
inNixStore "$(which ghc)"
# samePath "$(which ghc)" "${lib.getExe config.outputs.finalPackages.ghc}"
samePath "$(which cabal)" "${lib.getExe config.outputs.finalPackages.cabal-install}"
samePath "$(which haskell-language-server)" "${lib.getExe config.outputs.finalPackages.haskell-language-server}"
'';
};
}