On 11/12/2014 06:10 PM, Benno Fünfstück wrote: > Ah sorry, I wrote that on my phone so the answer was a bit short :). > > You just type eval $buildPhase while you're in nix-shell. eval is a bash > builtin to execute a bash script from a string, and the buildPhase > environment variable contains the script that nix would use to build your > project when you'd use nix-build or similar. So eval $buildPhase just > builds your project but it also sets the GHC_PACKAGE_PATH environment > variable at the end, so that the tests can find the packages. > > Since nix uses the `Setup.hs` file directly instead of going through > cabal-install, you will need to run eval $configurePhase once so that > Setup.hs gets compiled into the Setup executable and the project is > configured. > > -- > Benno
If you insist on using ‘cabal *’, you could also just run ‘echo $buildPhase’ and run the command that sets GHC_PACKAGE_PATH by hand. Personally I recommend you don't use cabal commands but instead eval relevant phases ($configurePhase, $buildPhase, $checkPhase). It lets you avoid gotchas such as this one. > 2014-11-12 18:52 GMT+01:00 Richard Wallace <[email protected]>: > >> Hi Benno, >> >> Thanks for the response. I'm not sure what you mean by "eval $buildPhase" >> and where I would put that. I'm stilling finding my feet with nix. :) >> >> Thanks again, >> Rich >> >> On Tue, Nov 11, 2014 at 11:01 PM, Benno Fünfstück < >> [email protected]> wrote: >> >>> Hello Rich, >>> >>> GHC_PACKAGE_PATH needs to be set correctly for doctests to work. The >>> problem with this is that cabal doesn't work with GHC_PACKAGE_PATH set, so >>> you can't set it permanently. >>> >>> If you use "eval $buildPhase", that will build the project and set >>> GHC_PACKAGE_PATH. doctests should work after that. You might need to run >>> eval "$configurePhase" before though, to compile Setup.hs. >>> >>> -- >>> Benno >>> >>> Am 12.11.2014 00:51 schrieb "Richard Wallace" < >>> [email protected]>: >>> >>>> >>>> Hello all, >>>> >>>> We've got a Haskell project that we're using nix to ensure a consistent >>> build environment. I'm working on adding tests with doctest, and am >>> running into trouble. Here are the default.nix and shell.nix files we're >>> using (many dependencies elided for brevity) >>>> >>>> # This file was auto-generated by cabal2nix. Please do NOT edit >>> manually! >>>> >>>> { cabal, aeson, lens, doctest, >>>> }: >>>> >>>> cabal.mkDerivation (self: { >>>> pname = "hiberico"; >>>> version = "1"; >>>> src = ./.; >>>> isLibrary = false; >>>> isExecutable = true; >>>> buildDepends = [ >>>> aeson lens >>>> ]; >>>> testDepends = [ >>>> doctest aeson lens >>>> ]; >>>> >>>> meta = { >>>> description = "Iberico in Haskell"; >>>> license = "unknown"; >>>> platforms = self.ghc.meta.platforms; >>>> }; >>>> }) >>>> >>>> # shell.nix >>>> let >>>> nixpkgs = (import <nixpkgs> {}).fetchgit { >>>> url = "git://github.com/NixOS/nixpkgs.git"; >>>> rev = "c758ec756b60a2161a5d7369d07d3eb2fe04a5aa"; >>>> sha256 = "01x01gwj2pm165sdhb1fxfdzl638kksx79dyadji5f2wp4hssk8m"; >>>> }; >>>> in >>>> { system ? builtins.currentSystem >>>> , pkgs ? import nixpkgs { inherit system; } >>>> , haskellPackages ? pkgs.haskellPackages.override { >>>> extension = self: super: { >>>> hiberico = self.callPackage ./. {}; >>>> }; >>>> } >>>> }: >>>> pkgs.lib.overrideDerivation haskellPackages.hiberico (attrs: { >>>> buildInputs = [ >>>> haskellPackages.cabalInstall >>>> ] ++ attrs.buildInputs; >>>> }) >>>> >>>> >>>> When I enter the nix-shell (`nix-shell --pure shell.nix`), the >>> environment seems setup correctly. I can run `cabal configure >>> --enable-tests && cabal build && cabal test` and it gets to the point where >>> doctest is parsing the source files and I get >>>> >>>> Building hiberico-1... >>>> Preprocessing executable 'hiberico' for hiberico-1... >>>> Preprocessing test suite 'doctests' for hiberico-1... >>>> Running 1 test suites... >>>> Test suite doctests: RUNNING... >>>> >>>> src/Topology.hs:11:18: >>>> Could not find module 'Data.Aeson' >>>> Perhaps you meant Data.Version (from base) >>>> Use -v to see a list of the files searched for. >>>> >>>> I've added all the dependencies to the doctests suite in the cabal >>> file. Is there something else I'm missing? >>>> >>>> Thanks, >>>> Rich >>>> >>>> _______________________________________________ >>>> nix-dev mailing list >>>> [email protected] >>>> http://lists.science.uu.nl/mailman/listinfo/nix-dev >>>> >>> >>> >> > > > > _______________________________________________ > nix-dev mailing list > [email protected] > http://lists.science.uu.nl/mailman/listinfo/nix-dev > -- Mateusz K. _______________________________________________ nix-dev mailing list [email protected] http://lists.science.uu.nl/mailman/listinfo/nix-dev
