on iko/ghcjs-patch-master help sign in
Add setup-depends to shellFor (#259)
94f4679Hamish Mackenzie
builder/shell-for.nix+4−1
@@ -25,7 +25,10 @@ let
25 # new-style commands.
25 # new-style commands.
26 packageInputs = lib.filter
26 packageInputs = lib.filter
27 (input: lib.all (cfg: input.identifier != cfg.identifier) selected)
27 (input: lib.all (cfg: input.identifier != cfg.identifier) selected)
28− (lib.concatMap (cfg: cfg.depends) selectedConfigs ++ additionalSelected);
28+ (lib.concatMap (cfg: cfg.depends) selectedConfigs
29+ ++ additionalSelected
30+ ++ lib.concatMap (cfg: cfg.setup.config.depends or []) selected
31+ );
29
32
30 # Add the system libraries and build tools of the selected haskell
33 # Add the system libraries and build tools of the selected haskell
31 # packages to the shell.
34 # packages to the shell.
test/default.nix+1
@@ -18,6 +18,7 @@ in pkgs.recurseIntoAttrs {
18 stack-simple = haskell.callPackage ./stack-simple {};
18 stack-simple = haskell.callPackage ./stack-simple {};
19 snapshots = haskell.callPackage ./snapshots {};
19 snapshots = haskell.callPackage ./snapshots {};
20 shell-for = haskell.callPackage ./shell-for {};
20 shell-for = haskell.callPackage ./shell-for {};
21+ shell-for-setup-deps = haskell.callPackage ./shell-for-setup-deps {};
21 callStackToNix = haskell.callPackage ./call-stack-to-nix {};
22 callStackToNix = haskell.callPackage ./call-stack-to-nix {};
22 callCabalProjectToNix = haskell.callPackage ./call-cabal-project-to-nix {};
23 callCabalProjectToNix = haskell.callPackage ./call-cabal-project-to-nix {};
23 cabal-source-repo = haskell.callPackage ./cabal-source-repo {};
24 cabal-source-repo = haskell.callPackage ./cabal-source-repo {};
test/shell-for-setup-deps/cabal.projectnew file+3
@@ -0,0 +1,3 @@
1+index-state: 2019-10-01T00:00:00Z
2+
3+packages: pkg
test/shell-for-setup-deps/default.nixnew file+47
@@ -0,0 +1,47 @@
1+{ stdenv, cabal-install, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject }:
2+
3+with stdenv.lib;
4+
5+let
6+ plan = importAndFilterProject (callCabalProjectToNix {
7+ src = ./.;
8+ });
9+ pkgSet = mkCabalProjectPkgSet {
10+ plan-pkgs = plan.pkgs;
11+ modules = [{
12+ # Package has no exposed modules which causes
13+ # haddock: No input file(s)
14+ packages.bytestring-builder.doHaddock = false;
15+ }];
16+ };
17+
18+ env = pkgSet.config.hsPkgs.shellFor {};
19+
20+ in
21+ stdenv.mkDerivation {
22+ name = "shell-for-test";
23+
24+ buildCommand = ''
25+ ########################################################################
26+ # test shell-for with an example program
27+
28+ cp ${./pkg/src}/*.hs .
29+
30+ printf "checking that the shell env has the dependencies...\n" >& 2
31+ ${env.ghc}/bin/runghc conduit-test.hs
32+
33+ touch $out
34+ '';
35+
36+ meta.platforms = platforms.all;
37+ meta.disabled = stdenv.hostPlatform.isMusl;
38+
39+ passthru = {
40+ # Used for debugging with nix repl
41+ inherit pkgSet;
42+
43+ # Used for testing externally with nix-shell (../tests.sh).
44+ inherit env;
45+ plan-nix = plan.nix;
46+ };
47+}
test/shell-for-setup-deps/pkg/Setup.hsnew file+23
@@ -0,0 +1,23 @@
1+import Distribution.Simple
2+
3+-- https://github.com/snoyberg/conduit#readme
4+
5+import Conduit
6+import System.Directory (removeFile)
7+
8+example = do
9+ -- Pure operations: summing numbers.
10+ print $ runConduitPure $ yieldMany [1..10] .| sumC
11+
12+ -- Exception safe file access: copy a file.
13+ writeFile "input.txt" "This is a test." -- create the source file
14+ runConduitRes $ sourceFileBS "input.txt" .| sinkFile "output.txt" -- actual copying
15+ readFile "output.txt" >>= putStrLn -- prove that it worked
16+
17+ -- Perform transformations.
18+ print $ runConduitPure $ yieldMany [1..10] .| mapC (+ 1) .| sinkList
19+
20+ removeFile "input.txt"
21+ removeFile "output.txt"
22+
23+main = defaultMain
test/shell-for-setup-deps/pkg/app/Main.hsnew file+6
@@ -0,0 +1,6 @@
1+module Main where
2+
3+import qualified Data.Text.IO as T
4+
5+main :: IO ()
6+main = return ()
test/shell-for-setup-deps/pkg/pkg.cabalnew file+33
@@ -0,0 +1,33 @@
1+cabal-version: 2.2
2+-- Initial package description 'pkgb.cabal' generated by 'cabal init'. For
3+-- further documentation, see http://haskell.org/cabal/users-guide/
4+
5+name: pkg
6+version: 0.1.0.0
7+-- synopsis:
8+-- description:
9+-- bug-reports:
10+license: LicenseRef-PublicDomain
11+author: Rodney Lorrimar
12+maintainer: rodney.lorrimar@iohk.io
13+category: Testing
14+
15+custom-setup
16+ setup-depends: conduit
17+ , conduit-extra
18+
19+library
20+ exposed-modules: Pkg
21+ build-depends: base
22+ hs-source-dirs: src
23+ default-language: Haskell2010
24+
25+executable pkgb
26+ main-is: Main.hs
27+ -- other-modules:
28+ -- other-extensions:
29+ build-depends: base
30+ , optparse-applicative
31+ , text
32+ hs-source-dirs: app
33+ default-language: Haskell2010
test/shell-for-setup-deps/pkg/src/conduit-test.hsnew file+5
@@ -0,0 +1,5 @@
1+module Main where
2+
3+import Conduit
4+
5+main = return ()