on e94de40 help sign in
90 lines 2.8 kB history raw
1{ stdenv, cabal-install, mkCabalProjectPkgSet, recurseIntoAttrs, runCommand, testSrc }:
3with stdenv.lib;
5let
6 pkgSet = mkCabalProjectPkgSet {
7 plan-pkgs = import ./pkgs.nix;
8 pkg-def-extras = [{
9 pkga = ./.plan.nix/pkga.nix;
10 pkgb = ./.plan.nix/pkgb.nix;
11 }];
12 modules = [{
13 # Package has no exposed modules which causes
14 # haddock: No input file(s)
15 packages.bytestring-builder.doHaddock = false;
16 }];
17 };
19 env = pkgSet.config.hsPkgs.shellFor {
20 # Shell will provide the dependencies of pkga and pkgb, but not
21 # pkga and pkgb themselves.
22 packages = ps: with ps; [ pkga pkgb ];
23 # This adds cabal-install to the shell, which helps tests because
24 # they use a nix-shell --pure. Normally you would BYO cabal-install.
25 tools = { cabal = "3.2.0.0"; };
26 exactDeps = true;
27 };
29 envPkga = pkgSet.config.hsPkgs.shellFor {
30 # Shell will provide the dependencies of pkga
31 packages = ps: with ps; [ pkga ];
32 # This adds cabal-install to the shell, which helps tests because
33 # they use a nix-shell --pure. Normally you would BYO cabal-install.
34 tools = { cabal = "3.2.0.0"; };
35 exactDeps = true;
36 };
38 envDefault = pkgSet.config.hsPkgs.shellFor {
39 # The default implementation of packages should use isLocal and the
40 # result should be the same as:
41 # packages = ps: with ps; [ pkga pkgb ];
42 # This adds cabal-install to the shell, which helps tests because
43 # they use a nix-shell --pure. Normally you would BYO cabal-install.
44 tools = { cabal = "3.2.0.0"; };
45 };
47in recurseIntoAttrs (if stdenv.hostPlatform.isWindows
48 then
49 let skip = runCommand "skip-test-shell-for" {} ''
50 echo "Skipping shell-for test on windows as does not work yet" >& 2
51 touch $out
52 '';
53 in {
54 env = skip;
55 envPkga = skip;
56 envDefault = skip;
57 run = skip;
58 }
59 else {
60 inherit env envPkga envDefault;
61 run = stdenv.mkDerivation {
62 name = "shell-for-test";
64 buildCommand = ''
65 ########################################################################
66 # test shell-for with an example program
68 cp ${./pkgb/src}/*.hs .
70 printf "checking that the shell env has the dependencies...\n" >& 2
71 ${env.ghc}/bin/${env.ghc.targetPrefix}runghc conduit-test.hs
73 printf "checking that the shell envDefault has the dependencies...\n" >& 2
74 ${envDefault.ghc}/bin/${env.ghc.targetPrefix}runghc conduit-test.hs
76 touch $out
77 '';
79 meta.platforms = platforms.all;
80 meta.disabled = stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWindows;
82 passthru = {
83 # Used for debugging with nix repl
84 inherit pkgSet;
86 # Used for testing externally with nix-shell (../tests.sh).
87 inherit env envPkga envDefault;
88 };
89 };
90})