Closed wedens closed 8 years ago
I use a different style for my shell.nix
file. Can you create a new directory with these files. Then open the Main.hs
file and see if it works?
shell.nix
{ pkgs ? import <nixpkgs> {} }:
let env = pkgs.haskellPackages.ghcWithPackages(p: with p; [
Cabal cabal-install hlint
]);
in pkgs.stdenv.mkDerivation {
name = "xxx";
version = "0.1.0.0";
src = ./.;
buildInputs = [ env ];
shellHook = ''
export NIX_GHC="${env}/bin/ghc"
export NIX_GHCPKG="${env}/bin/ghc-pkg"
export NIX_GHC_DOCDIR="${env}/share/doc/ghc/html"
export NIX_GHC_LIBDIR=$( $NIX_GHC --print-libdir )
'';
}
Main.hs
main = print "hello"
Still nothing. No executables for checkers detected.
PATH
in nix-shell
is correct
Can you try the following steps please
(nix-current-sandbox)
, (nix-exec-path (nix-current-sandbox))
and (nix-executable-find (nix-current-sandbox) "hlint")
with M-:
and send me the output.@svenkeidel
flycheck successfully finds ghc/hlint binaries without nix-sandbox (but obviously is unable to find dependenies)
(nix-current-sandbox)
shows correct path.
(nix-exec-path (nix-current-sandbox))
is empty!
(nix-executable-find (nix-current-sandbox) "hlint")
is nil
Ok, what nix-exec-path
does is, it simply executes nix-shell --run 'echo $PATH'
inside the sandbox directory. nix-executable-find
then uses this path and calls the normal executable-find
function of Emacs with the path it got from nix-exec-path
.
So it seams, the problem is in nix-exec-path
. Can you try the following things and send me the output please:
nix-shell --run 'echo $PATH'
M-:
(nix-shell (nix-current-sandbox) "echo" "$PATH")
Result of nix-shell --run 'echo $PATH'
:
nix/store/r843jhj8hv5sg4qs45pp8l92bayiiigh-ghc-7.10.2/bin:/nix/store/30ayza19w9yyrv3qd4m9i0cxkly08ni0-patchelf-0.8/bin:/nix/store/pzyz725flnqnkbfc6ndn79nmk89zqvap-paxctl-0.9/bin:/nix/store/piq5rxp8c91j5bn9bir9k67agg1fa199-gcc-wrapper-4.9.3/bin:/nix/store/zzj4664wj266mnd8a1l21ggw21g4x2ya-coreutils-8.24/bin:/nix/store/z074lx3wfy4hi14ygdxbysg6i4cl2vsl-findutils-4.4.2/bin:/nix/store/fj6343mw2qphj3fcglpai5x5inlmx4c4-diffutils-3.3/bin:/nix/store/9302xvrawv1qx9991fwg9n0b22c1b47i-gnused-4.2.2/bin:/nix/store/yvi31c5mqaz072sdn5pmh0qhy944i7gd-gnugrep-2.22/bin:/nix/store/3s0fzyxjygylzcrhi71va3sa2g5jwh45-gawk-4.1.3/bin:/nix/store/n6sypqbklshikk0qf8wkbbwyxikzj2z1-gnutar-1.28/bin:/nix/store/gbvijz4iy7a6vb3fcnggaykwrwfnlvnl-gzip-1.6/bin:/nix/store/sc2yq86dh48rlw6y5k9876s3mbkh9ip3-bzip2-1.0.6/bin:/nix/store/gwvh88diwx72rqfwm4nd6wvs3gbgjfra-gnumake-4.1/bin:/nix/store/7d2g3bvmbi5ps3vlkl54h7d7yasc4ynv-bash-4.3-p42/bin:/nix/store/i3f6jxcl1igpsn3b6p9qq15rhfsk8a1x-patch-2.7.5/bin:/nix/store/9dh83qvaqpxkk6d9vvf4g2xfm9v1qk5m-xz-5.2.2/bin:/nix/store/2xrkp6zca9hbmsdjfb3v09dv4awaqyap-gcc-4.9.3/bin:/nix/store/5kdjp8200hazaydx0dmwn5qghqkyi3py-binutils-2.23.1/bin:/nix/store/483br9kb3f5igsgmb6aqsjhl2ipj2bxr-glibc-2.21/bin:/nix/store/zzj4664wj266mnd8a1l21ggw21g4x2ya-coreutils-8.24/bin:/home/wedens/dotfiles/scripts:/home/wedens/dotfiles/scripts:/home/wedens/bin:/var/setuid-wrappers:/home/wedens/.nix-profile/bin:/home/wedens/.nix-profile/sbin:/home/wedens/.nix-profile/lib/kde4/libexec:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/nix/var/nix/profiles/default/lib/kde4/libexec:/run/current-system/sw/bin:/run/current-system/sw/sbin:/run/current-system/sw/lib/kde4/libexec
(nix-shell (nix-current-sandbox) "echo" "$PATH")
output is empty. and every other command called via (nix-shell (nix-current-sandbox) cmd)
results in empty string
I think I have found the error. If you execute nix-shell --run 'echo $PATH' /path/to/sandbox/
and the sandbox directory does not contain a default.nix
file, then you get the error opening file '/path/to/sandbox/default.nix': No such file or directory
. So I fixed this issue by improving the nix-find-sandbox
function to return the path to the shell.nix
file if one exists and otherwise return the path to the parent directory of a default.nix
file. I upload the patch shortly.
Sorry, it seams that I have no commit bit yet. In the mean time, can you try
svenkeidel/nix-emacs@8033ccfd6904f2caee54f433e58b2eddc4e73836
and see if (nix-shell (nix-current-sandbox) "echo" "$PATH")
works now?
yeah. now it shows the same path as in shell. and flycheck is able to find ghc binary
Cool, now flycheck should work. Try opening a Haskell file and activate flycheck-mode
haskell-mode
- :white_check_mark:
flycheck
- :white_check_mark:
thanks for the fix!
Thank you very much for your contribution. Can you close this issue now?
sure
will nix-sandbox
be released on MELPA?
I would like to do a little bit more testing before I release on MELPA, but yeah, this is the plan.
@svenkeidel Speaking of releasing on MELPA, did you get my email from earlier this week?
Yes I got the mail. As I said, I would like to do a little bit more testing before I release.
@svenkeidel You should have commit bit now, just let me know when you are ready for a release.
I've added this configuration from README to my
.emacs
:flycheck-verify-setup
output:my
shell.nix
(generated bycabal2nix
):@svenkeidel