[Nix-dev] A Journey into the Haskell NG infrastructure: Part I

Richard Wallace rwallace at thewallacepack.net
Sun Jan 11 00:30:54 CET 2015


Hello,

This looks pretty good. I tried converting one of my projects today and ran
into an issue with cabal-test-quickcheck

building path(s)
‘/nix/store/zyxd5g7ppxqbp9dhlz41vdjaki351a8w-haskell-cabal-test-quickcheck-0.1.2’
building
/nix/store/zyxd5g7ppxqbp9dhlz41vdjaki351a8w-haskell-cabal-test-quickcheck-0.1.2
unpacking sources
unpacking source archive
/nix/store/9pjynpj0mvqlw84m8vs1lzvk2y8cymp3-cabal-test-quickcheck-0.1.2.tar.gz
source root is cabal-test-quickcheck-0.1.2
patching sources
configuring
Building with /nix/store/7nhcrjkv2sp3xxv09gl20gdm91ag2bmd-ghc-7.8.4.
[1 of 1] Compiling Main             ( Setup.hs,
/tmp/nix-build-haskell-cabal-test-quickcheck-0.1.2.drv-0/Main.o )
Linking Setup ...
configureFlags: --verbose
--prefix=/nix/store/zyxd5g7ppxqbp9dhlz41vdjaki351a8w-haskell-cabal-test-quickcheck-0.1.2
--libdir=$prefix/lib/$compiler --libsubdir=$pkgid --enable-split-objs
--disable-library-profiling --enable-shared --enable-library-vanilla
--enable-executable-dynamic --enable-tests
--ghc-option=-optl=-Wl,-rpath=/nix/store/zyxd5g7ppxqbp9dhlz41vdjaki351a8w-haskell-cabal-test-quickcheck-0.1.2/lib/ghc-7.8.4/cabal-test-quickcheck-0.1.2
--package-db=/tmp/nix-build-haskell-cabal-test-quickcheck-0.1.2.drv-0/package.conf.d
Configuring cabal-test-quickcheck-0.1.2...
Setup: At least the following dependencies are missing:
Cabal ==1.20.*
builder for
‘/nix/store/j88cdlva98czlckb9ybbn16qvwv1yj5k-haskell-cabal-test-quickcheck-0.1.2.drv’
failed with exit code 1
cannot build derivation
‘/nix/store/7gd2zp5i25805wlag26sl6i8r3fks4zq-haskell-http-media-0.4.0.drv’:
1 dependencies couldn't be built
building path(s)
‘/nix/store/9n76sbp81vgap0qc1fg8g0plzpsfk7b4-haskell-quickcheck-instances-0.3.10’
cannot build derivation
‘/nix/store/skmviq7sfwm5zdz4dac39j3kvsmhrzip-ghc-7.8.4.drv’: 1 dependencies
couldn't be built
error: build of ‘/nix/store/skmviq7sfwm5zdz4dac39j3kvsmhrzip-ghc-7.8.4.drv’
failed
/run/current-system/sw/bin/nix-shell: failed to build all dependencies

Rich

On Sat, Jan 10, 2015 at 8:19 AM, Peter Simons <simons at cryp.to> wrote:

> Hi,
>
>  > It would be nice to have an example of how to use shell.nix and
>  > default.nix together.
>
> starting with Nixpkgs version 11ac18a, you can do the following.
>
>  1) To create an interactive build environment that can compile a local
> Haskell
>     project, run:
>
>       $ cabal2nix --shell . >shell.nix && nix-shell
>
>     The new shell will be set up with an appropriate ghcWithPackages
> wrapper
>     that about knows all dependencies for this package, and required system
>     libraries will also be configured to be found without extra parameters
> to
>     "cabal configure".
>
>  2) For recent Hackage packages, you can do that without using cabal2nix,
> even,
>     by running:
>
>       $ nix-shell '<nixpkgs>' -A haskellngPackages.hspec.env
>
>     This will give you the same kind of environment as (1), but this time
> the
>     environment is setup based on the information we have in Nixpkgs, so
> you
>     don't have to generate a cabal file at all.
>
> To illustrate these points, here is an example session. Note that my user
> has
> no 'ghc':
>
>  | $ ghc
>  | The program ‘ghc’ is currently not installed. You can install it by
> typing:
>  |   nix-env -i ghc
>
> Anyway, let's build 'hspec'. First, we get the source code:
>
>  | $ curl
> http://hackage.haskell.org/package/hspec-2.1.2/hspec-2.1.2.tar.gz | tar xz
>  |   % Total    % Received % Xferd  Average Speed   Time    Time     Time
> Current
>  |                                  Dload  Upload   Total   Spent    Left
> Speed
>  | 100  5200  100  5200    0     0  75337      0 --:--:-- --:--:--
> --:--:-- 76470
>  |
>  | $ cd hspec-2.1.2
>
> Now enter the build environment based on the package data from Nixpkgs:
>
>  | $ nix-shell '<nixpkgs>' -A haskellngPackages.hspec.env
>
> And compile:
>
>  | [nix-shell:/tmp/hspec-2.1.2]$ ghc --make Setup
>  | [1 of 1] Compiling Main             ( Setup.lhs, Setup.o )
>  | Linking Setup ...
>  |
>  | [nix-shell:/tmp/hspec-2.1.2]$ ./Setup configure
>  | Configuring hspec-2.1.2...
>  |
>  | [nix-shell:/tmp/hspec-2.1.2]$ ./Setup build
>  | Building hspec-2.1.2...
>  | Preprocessing library hspec-2.1.2...
>  | [1 of 7] Compiling Test.Hspec.HUnit ( src/Test/Hspec/HUnit.hs,
> dist/build/Test/Hspec/HUnit.o )
>  | [2 of 7] Compiling Test.Hspec.Formatters (
> src/Test/Hspec/Formatters.hs, dist/build/Test/Hspec/Formatters.o )
>  | [3 of 7] Compiling Test.Hspec.Discover ( src/Test/Hspec/Discover.hs,
> dist/build/Test/Hspec/Discover.o )
>  | [4 of 7] Compiling Test.Hspec.Runner ( src/Test/Hspec/Runner.hs,
> dist/build/Test/Hspec/Runner.o )
>  | [5 of 7] Compiling Test.Hspec.Core  ( src/Test/Hspec/Core.hs,
> dist/build/Test/Hspec/Core.o )
>  | [6 of 7] Compiling Test.Hspec       ( src/Test/Hspec.hs,
> dist/build/Test/Hspec.o )
>  | [7 of 7] Compiling Test.Hspec.QuickCheck (
> src/Test/Hspec/QuickCheck.hs, dist/build/Test/Hspec/QuickCheck.o )
>  | In-place registering hspec-2.1.2...
>  |
>  | [nix-shell:/tmp/hspec-2.1.2]$ exit
>  | exit
>
> Of course, you can use cabal-install if you happen to have that in your
> user
> profile. I just wanted to show the simplest possible use case that works
> without it.
>
> I hope this helps,
> Peter
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150110/188e98ba/attachment-0001.html 


More information about the nix-dev mailing list