hie-nix
hie-nix copied to clipboard
Install HIE with my build of ghc
I have this ghc environment:
haskellEnv = pkgs.haskell.packages.ghc844.ghcWithPackages (haskellPackages: with haskellPackages;[
telegram-bot-simple
]);
but HIE doesn't see telegram-bot-simple. So, I tried to install HIE like this
(ide.hie84.override {compiler = haskellEnv;})
instead of just ide.hie84 (ide is (import (fetchTarball https://github.com/domenkozar/hie-nix/tarball/master){});
), but it throws an error:
error: anonymous function at /nix/store/hash-source/ghc-8.4.nix:16266:10 called with unexpected argument 'compiler', at /nix/store/hash.tar.gz-unpacked/pkgs/development/haskell-modules/make-package-set.nix:87:27
Is it a bug or am i doing something wrong?
You don't need to override ide with environment, just have the environment be there when you launch hie.
I have a similar question, the LSP client shows Mismatching GHC versions: Project is 8.6.4, HIE is 8.6.3
with this shell.nix:
with import <nixpkgs> {};
let
hie_remote = builtins.fetchTarball {
url = https://github.com/domenkozar/hie-nix/tarball/master;
};
# todo make it automatic depending on nixpkgs' ghc
hie = (import hie_remote {} ).hie86;
haskellPackages.shellFor {
nativeBuildInputs = [ hie ... ];
Is there any attribute I could refer to that uses my nixpkgs' ghc (nixos-unstable) ? (even if it's not in cache)
I had a look at the code so one can pass its own compiler:
hie = (import hie_remote { compiler = pkgs.haskell.compiler.ghc864; } ).hie86;
and lose the cache or alternatively use the same compiler as hie which is what I ended up doing:
haskell.packages.ghc863.shellFor {
So I might have been carried away since niether works. If I try
haskell.packages.ghc863.shellFor {
then I get
runghc daemon.hs
Loaded package environment from /home/teto/mptcpnetlink/hs/.ghc.environment.x86_64-linux-8.6.3
<command line>: cannot satisfy -package-id bytestring-conversion-0.3.1-Dck5sEq1eWb6wVe3cJQ1o3
(use -v for more information)
I am not sure why.
My previous tip was wrong too so I tried to fix it with:
hie = (import "${hie_remote}/ghc-8.6.nix" {
compiler = pkgs.haskell.compiler.ghc864;
} ).haskell-ide-engine;
which ends up with
error: while evaluating the attribute 'nativeBuildInputs' of the derivation 'ghc-shell-for-netlink-pm-1.0.0' at /home/teto/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:301:9:
while evaluating 'getOutput' at /home/teto/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /home/teto/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:125:17, called from undefined position:
while evaluating anonymous function at /nix/store/r1kpqk284ajf6xfw4h8cg1yn4sq920rh-source/ghc-8.6.nix:3:1, called from /home/teto/mptcpnetlink/hs/shell-test.nix:13:10:
while evaluating 'override' at /home/teto/nixpkgs/lib/customisation.nix:73:20, called from /nix/store/r1kpqk284ajf6xfw4h8cg1yn4sq920rh-source/ghc-8.6.nix:39450:4:
while evaluating 'makeOverridable' at /home/teto/nixpkgs/lib/customisation.nix:67:24, called from /home/teto/nixpkgs/lib/customisation.nix:73:29:
anonymous function at /home/teto/nixpkgs/pkgs/development/compilers/ghc/8.6.4.nix:1:1 called with unexpected argument 'initialPackages', at /home/teto/nixpkgs/lib/customisation.nix:69:12
For that first error, just blow away your .ghc.environment
in that directory, along with any dist-newstyle
directory. AFAIK, HIE doesn't handle cabal v2 projects, yet.
@jhenahan aaaahhh~~~ that did it thanks
@domenkozar
You don't need to override ide with environment, just have the environment be there when you launch hie.
I am suddenly have Bad interface file
problem with ghc-8.6.4
(nix-unstable) today. I remember there was some version mismatch warning but still usable before, but today it turned into error.
Can't remember changing anything. However ghc844
and ghc822
have no problem.
test.hs|1 col 8 error| Bad interface file: /nix/store/8vq01xmxlp9wxzilkw85rb621ag7nwmd-ghc-8.6.4/lib/ghc-8.6.4/base-4.12.0.0/Prelude.hi mismatched interface file versions (wanted "8063", got "8064")
test.hs|3 col 1 error| Bad interface file: /nix/store/8vq01xmxlp9wxzilkw85rb621ag7nwmd-ghc-8.6.4/lib/ghc-8.6.4/base-4.12.0.0/Data/Char.hi mismatched interface file versions (wanted "8063", got "8064")
I don't know any way to test hie
separately so I try to make the minimum configuration using neovim
and ale
I use following command to get different ghc
in my shell
$ nix-shell --argstr compiler ghc822
$ nix-shell --argstr compiler ghc844
$ nix-shell
The test command for nvim
is $ nvim -u ale-init.vim test.hs
Below are my files
# shell.nix for nix-shell
# Overrideable ghc version by passing `compiler` argument
# Example:
# $ nix-shell shell.nix --argstr compiler ghc822
#
# To list avaliable ghc version:
# $ nix-env -qaPA nixos.haskell.compiler
{ pkgs ? import <nixpkgs> {}
, compiler ? "default"
}:
with pkgs;
let
haskellPackages = if compiler == "default"
then pkgs.haskellPackages
else haskell.packages.${compiler};
hie_remote = fetchFromGitHub {
owner = "domenkozar";
repo = "hie-nix";
rev = "6794005f909600679d0b7894d0e7140985920775";
sha256 = "0pc90ns0xcsa6b630d8kkq5zg8yzszbgd7qmnylkqpa0l58zvnpn";
};
hie = with import hie_remote {};
if lib.versions.majorMinor ghc.version == "8.2"
then hie82
else if lib.versions.majorMinor ghc.version == "8.4"
then hie84
else hie86;
ghc = haskellPackages.ghcWithPackages (ps: with ps; [
extra
]);
hs = [ cabal-install ghc hie ];
in
mkShell {
name = "${compiler}-sh";
buildInputs = [ hs ];
shellHook = ''
eval "$(egrep ^export "$(type -p ghc)")"
export PS1="\[\033[1;32m\][$name:\W]\n$ \[\033[0m\]"
'';
}
" ale-init.vim
call plug#begin()
Plug 'w0rp/ale'
call plug#end()
let g:ale_linters = {'haskell': [ 'hie' ]}
let g:ale_haskell_hie_executable = 'hie-wrapper'
-- test.hs
module Main where
import Data.Char
main = print $ toUpper <$> "hello"
Edit: update ale-init.vim
to make sure that ale
call hie-wrapper
but problem still persist.
@wizzup I am seeing the same thing, although with hie using 8.4.4 and my project using 8.4.3. Updating ghc to 8.4.4 isn't easy because I'm using a fork of nixpkgs for building static binaries.
Did you find any other workarounds?
@purefn Unfortunately, I still have no luck. I am giving up on trying to build the update fork of this repo because my old PC can't handle the huge build, travis keep timeout constantly and doesn't seem to push the intermediate packages to cachix.
New release is my only hope.
See #55 for 8.6.4 support