on e94de40 help sign in
93 lines 3.0 kB history raw
1{ stdenv, util, mkPkgSet, recurseIntoAttrs, testSrc }:
3with stdenv.lib;
4with util;
6let
7 pkgs = import ./pkgs.nix;
8 pkgSet = doExactConfig: mkPkgSet {
9 # generated with:
10 # cabal new-build
11 # plan-to-nix -o .
12 pkg-def = pkgs.pkgs;
13 pkg-def-extras = [ pkgs.extras ];
14 modules = [
15 # overrides to fix the build
16 {
17 packages.transformers-compat.components.library.doExactConfig = true;
18 }
20 # vary component config for tests
21 {
22 packages.test-with-packages.components.library.doExactConfig = doExactConfig;
23 }
24 ];
25 };
27 packages = doExactConfig: (pkgSet doExactConfig).config.hsPkgs;
29 package = doExactConfig: (packages doExactConfig).test-with-packages;
31 decLibrary = (package true).components.library;
32 library = (package false).components.library;
34 pkgId = p: "${p.identifier.name}-${p.identifier.version}";
35 showDepends = component: concatMapStringsSep " " pkgId (component.depends or []);
37in recurseIntoAttrs {
38 # Used for testing externally with nix-shell (../tests.sh).
39 # This just adds cabal-install to the existing shells.
40 test-shell = addCabalInstall library;
42 # A variant of test-shell with the component option doExactConfig enabled
43 test-shell-dec = addCabalInstall decLibrary;
45 run = stdenv.mkDerivation {
46 name = "with-packages-test";
47 decLibraryDepends = showDepends (pkgSet true).config.packages.test-with-packages.components.library;
48 libraryDepends = showDepends (pkgSet false).config.packages.test-with-packages.components.library;
50 buildCommand = ''
51 ########################################################################
52 # test with-packages
54 printf "checking component depends ... " >& 2
55 if [ -n "$decLibraryDepends" -a "$decLibraryDepends" = "$libraryDepends" ]; then
56 echo "PASS" >& 2
57 else
58 echo "FAIL" >& 2
59 echo "decLibraryDepends = $decLibraryDepends"
60 echo "libraryDepends = $libraryDepends"
61 exit 1
62 fi
64 printf "checking that the 'library' without doExactConfig works... " >& 2
65 echo ${library} >& 2
67 printf "checking that the 'library' with doExactConfig works... " >& 2
68 echo ${decLibrary} >& 2
69 '' + (if stdenv.hostPlatform.isWindows
70 then ''
71 printf "runghc tests are not working yet for windows. skipping. " >& 2
72 ''
73 else ''
74 printf "checking that non doExactConfig liarary.env has the dependencies... " >& 2
75 ${library.env}/bin/${library.env.targetPrefix}runghc ${./Point.hs}
76 echo >& 2
78 printf "checking that doExactConfig library.env has the dependencies... " >& 2
79 ${decLibrary.env}/bin/${decLibrary.env.targetPrefix}runghc ${./Point.hs}
80 echo >& 2
81 '') + ''
82 touch $out
83 '';
85 meta.platforms = platforms.all;
86 meta.disabled = stdenv.hostPlatform.isMusl;
88 passthru = {
89 # Used for debugging with nix repl
90 inherit packages pkgSet;
91 };
92 };