1{
2 lib,
3 writeText,
4 haskellPackages,
5 cabal-install,
6}:
7
8(haskellPackages.shellFor {
9 packages = p: [
10 p.constraints
11 p.cereal
12 ];
13 # WARNING: When updating this, make sure that the libraries passed to
14 # `extraDependencies` are not actually transitive dependencies of libraries in
15 # `packages` above. We explicitly want to test that it is possible to specify
16 # `extraDependencies` that are not in the closure of `packages`.
17 extraDependencies = p: { libraryHaskellDepends = [ p.conduit ]; };
18 nativeBuildInputs = [ cabal-install ];
19 unpackPhase = ''
20 sourceRoot=$(pwd)/scratch
21 mkdir -p "$sourceRoot"
22 cd "$sourceRoot"
23 tar -xf ${haskellPackages.constraints.src}
24 tar -xf ${haskellPackages.cereal.src}
25 cp ${writeText "cabal.project" "packages: constraints* cereal*"} cabal.project
26 '';
27 buildPhase = ''
28 export HOME=$(mktemp -d)
29 mkdir -p $HOME/.cabal
30 touch $HOME/.cabal/config
31
32 # Check that the extraDependencies.libraryHaskellDepends arg is correctly
33 # picked up. This uses ghci to interpret a small Haskell program that uses
34 # a package from extraDependencies.
35 ghci <<EOF
36 :set -XOverloadedStrings
37 :m + Conduit
38 runResourceT $ connect (yield "done") (sinkFile "outfile")
39 EOF
40
41 if [[ "done" != "$(cat outfile)" ]]; then
42 echo "ERROR: extraDependencies appear not to be available in the environment"
43 exit 1
44 fi
45
46 # Check packages arg
47 cabal v2-build --offline --verbose constraints cereal --ghc-options="-O0 -j$NIX_BUILD_CORES"
48 '';
49 installPhase = ''
50 touch $out
51 '';
52}).overrideAttrs
53 (oldAttrs: {
54 meta =
55 let
56 oldMeta = oldAttrs.meta or { };
57 oldMaintainers = oldMeta.maintainers or [ ];
58 additionalMaintainers = with lib.maintainers; [ cdepillabout ];
59 allMaintainers = oldMaintainers ++ additionalMaintainers;
60 in
61 oldMeta
62 // {
63 maintainers = allMaintainers;
64 inherit (cabal-install.meta) platforms;
65 };
66 # `shellFor` adds a `buildCommand` (via `envFunc -> runCommandCC`), which
67 # overrides custom phases. To ensure this test's phases run, we remove
68 # that `buildCommand` from the derivation.
69 buildCommand = null;
70 })