diagrams / diagrams-pandoc

A pandoc filter to express diagrams inline using the haskell EDSL diagrams.
BSD 3-Clause "New" or "Revised" License
38 stars 9 forks source link

modules not found when installed via Nix #7

Open YPares opened 9 years ago

YPares commented 9 years ago

Hi, when trying to run the example, I get:

Error while interpreting
example = circle 1
/tmp/Diagram1804289383846930886.hs:4:8:
    Could not find module ‘Diagrams.Prelude’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:5:8:
    Could not find module ‘Diagrams.TwoD.Types’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:6:8:
    Could not find module ‘Diagrams.Core.Points’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:7:8:
    Could not find module ‘Diagrams.Backend.Cairo’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:8:8:
    Could not find module ‘Diagrams.Backend.Cairo.Internal’
    Use -v to see a list of the files searched for.
/tmp/Diagram1804289383846930886.hs:9:8:
    Could not find module ‘Graphics.SVGFonts’
    Use -v to see a list of the files searched for.

whereas when I run ghci manually, I can import Diagrams.Prelude without any problem.

(I installed GHC, pandoc and diagrams-pandoc through Nix, but as I said, ghci has no problem finding the required modules)

bergey commented 9 years ago

Can you be more specific about how you installed these things? Is it like nix-env -i or do you have some nix-shell environment within which the packages are in scope?

I think I used to have a shell.nix file that loaded all the necessary packages, within which I could run diagrams-pandoc. Getting HSE and Nix to work together is always tricky, though.

YPares commented 9 years ago

I tried both. Both the nix-shell and the installation with nix-env -i had the same issue. But ideally I'd like to use it through a nix-shell, like you did, yes.

bergey commented 9 years ago

OK, thank you for clarifying. I'll dust off my .nix files and add an example of Nix usage. I probably won't get to it before Sunday.

On 2015-11-24 at 12:49, "Yves Parès (Ywen)" notifications@github.com wrote:

I tried both. Both the nix-shell and the installation with nix-env -i had the same issue. But ideally I'd like to use it through a nix-shell, like you do, yes.

2015-11-23 22:55 GMT+01:00 Daniel Bergey notifications@github.com:

Can you be more specific about how you installed these things? Is it like nix-env -i or do you have some nix-shell environment within which the packages are in scope?

I think I used to have a shell.nix file that loaded all the necessary packages, within which I could run diagrams-pandoc. Getting HSE and Nix to work together is always tricky, though.

— Reply to this email directly or view it on GitHub https://github.com/diagrams/diagrams-pandoc/issues/7#issuecomment-159078000 .


Reply to this email directly or view it on GitHub: https://github.com/diagrams/diagrams-pandoc/issues/7#issuecomment-159354184

epsilonhalbe commented 9 years ago

I experience the same thing with stack/cabal sandbox - I've created a new user and used per user global cabal install - then it worked

alsam commented 8 years ago

I've stumbled upon the same problem:

Error while interpreting
example = circle 1
/tmp/Diagram1804289383846930886.hs:9:8:
    Could not find module ‘Graphics.SVGFonts’
    Use -v to see a list of the files searched for.

but after cabal install SVGFonts - details on the package are here: http://hackage.haskell.org/package/SVGFonts the problem has been resolved for me - even succeeded in producing .pdf file with pandoc -t latex diagrams_pandoc_example.md --filter diagrams-pandoc -o diagrams_pandoc_example.pdf -s You might need to install other additional packages via cabal, say diagrams.

edwtjo commented 8 years ago

Since this is still open; I use the following shell.nix and it correctly detects the libraries, i.e. you just need to wrap diagrams-pandoc. I typically do nix-env -i -f shell.nix && nix-shell to invoke it.

with (import (fetchTarball
  https://github.com/NixOS/nixpkgs/archive/2a83412f2a15a6eb416473a37140fe9d9fac8e3b.tar.gz){}).pkgs;
let
  ext = self: with self; [ diagrams diagrams-contrib diagrams-pandoc pandoc SVGFonts ];
  wrappedGhc = haskell.packages.lts-5.ghcWithPackages ext;
  ghcVersion = wrappedGhc.version;
in
stdenv.mkDerivation rec {
  pname = "DPENV";
  version = "0.1";
  name = pname + "-" + version;
  buildInputs = [ makeWrapper ];
  phases = [ "installPhase" ];
  installPhase = ''
    mkdir -p $out/bin
    makeWrapper \
      "${wrappedGhc}/bin/diagrams-pandoc" \
      "$out/bin/diagrams-pandoc" \
        --set NIX_GHC ${wrappedGhc}/bin/ghc \
        --set NIX_GHC_LIBDIR ${wrappedGhc}/lib/ghc-${ghcVersion}
  '';
  shellHook = ''
    export PS1="DP > "
  '';
}