on 19052d8 help sign in
89 lines 3.0 kB history raw
1{ stdenv, lib, cabal-install, mkCabalProjectPkgSet, recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }:
3with 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 # Avoid duplicate package issues when runghc looks for packages
28 packageSetupDeps = false;
29 };
31 envPkga = pkgSet.config.hsPkgs.shellFor {
32 # Shell will provide the dependencies of pkga
33 packages = ps: with ps; [ pkga ];
34 # This adds cabal-install to the shell, which helps tests because
35 # they use a nix-shell --pure. Normally you would BYO cabal-install.
36 tools = { cabal = "3.2.0.0"; };
37 exactDeps = true;
38 # Avoid duplicate package issues when runghc looks for packages
39 packageSetupDeps = false;
40 };
42 envDefault = pkgSet.config.hsPkgs.shellFor {
43 # The default implementation of packages should use isLocal and the
44 # result should be the same as:
45 # packages = ps: with ps; [ pkga pkgb ];
46 # This adds cabal-install to the shell, which helps tests because
47 # they use a nix-shell --pure. Normally you would BYO cabal-install.
48 tools = { cabal = "3.2.0.0"; };
49 # Avoid duplicate package issues when runghc looks for packages
50 packageSetupDeps = false;
51 };
53in recurseIntoAttrs {
54 # Does not work on ghcjs because it needs zlib.
55 # Does not work on windows because it needs mintty.
56 meta.disabled = stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isGhcjs || stdenv.hostPlatform.isWindows
57 || compiler-nix-name != ((import ./pkgs.nix).pkgs null).compiler.nix-name;
58 inherit env envPkga envDefault;
59 run = stdenv.mkDerivation {
60 name = "shell-for-test";
62 buildCommand = ''
63 ########################################################################
64 # test shell-for with an example program
66 cp ${./pkgb/src}/*.hs .
68 printf "checking that the shell env has the dependencies...\n" >& 2
69 ${env.ghc}/bin/${env.ghc.targetPrefix}runghc conduit-test.hs
71 printf "checking that the shell envDefault has the dependencies...\n" >& 2
72 ${envDefault.ghc}/bin/${env.ghc.targetPrefix}runghc conduit-test.hs
74 touch $out
75 '';
77 meta = {
78 platforms = platforms.unix;
79 };
81 passthru = {
82 # Used for debugging with nix repl
83 inherit pkgSet;
85 # Used for testing externally with nix-shell (../tests.sh).
86 inherit env envPkga envDefault;
87 };
88 };