File tree Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 15
15
with-packages = haskell . callPackage ./with-packages { inherit util ; } ;
16
16
builder-haddock = haskell . callPackage ./builder-haddock { } ;
17
17
stack-simple = haskell . callPackage ./stack-simple { } ;
18
+ shell-for = haskell . callPackage ./shell-for { inherit util ; } ;
18
19
19
20
# Run unit tests with: nix-instantiate --eval --strict -A unit
20
21
# An empty list means success.
Original file line number Diff line number Diff line change
1
+ -- https://github.com/snoyberg/conduit#readme
2
+
3
+ import Conduit
4
+ import System.Directory (removeFile )
5
+
6
+ main = do
7
+ -- Pure operations: summing numbers.
8
+ print $ runConduitPure $ yieldMany [1 .. 10 ] .| sumC
9
+
10
+ -- Exception safe file access: copy a file.
11
+ writeFile " input.txt" " This is a test." -- create the source file
12
+ runConduitRes $ sourceFileBS " input.txt" .| sinkFile " output.txt" -- actual copying
13
+ readFile " output.txt" >>= putStrLn -- prove that it worked
14
+
15
+ -- Perform transformations.
16
+ print $ runConduitPure $ yieldMany [1 .. 10 ] .| mapC (+ 1 ) .| sinkList
17
+
18
+ removeFile " input.txt"
19
+ removeFile " output.txt"
Original file line number Diff line number Diff line change
1
+ { stdenv , util , mkStackSnapshotPkgSet } :
2
+
3
+ with stdenv . lib ;
4
+ with util ;
5
+
6
+ let
7
+ pkgSet = mkStackSnapshotPkgSet {
8
+ resolver = "lts-12.21" ;
9
+ # Work around a mismatch between stackage metadata and the
10
+ # libraries shipped with GHC.
11
+ # https://github.com/commercialhaskell/stackage/issues/4466
12
+ pkg-def-extras = [ ( hackage : {
13
+ packages = {
14
+ "transformers" = ( ( ( hackage . transformers ) . "0.5.6.2" ) . revisions ) . default ;
15
+ "process" = ( ( ( hackage . process ) . "1.6.5.0" ) . revisions ) . default ;
16
+ } ;
17
+ } ) ] ;
18
+ } ;
19
+
20
+ env = pkgSet . config . hsPkgs . shellFor {
21
+ packages = ps : with ps ; [ conduit conduit-extra resourcet ] ;
22
+ withHoogle = true ;
23
+ } ;
24
+
25
+ in
26
+ stdenv . mkDerivation {
27
+ name = "shell-for-test" ;
28
+
29
+ buildCommand = ''
30
+ ########################################################################
31
+ # test shell-for with an example program
32
+
33
+ printf "checking that the shell env has the dependencies...\n" >& 2
34
+ ${ env . ghc } /bin/runghc ${ ./conduit.hs }
35
+
36
+ touch $out
37
+ '' ;
38
+
39
+ meta . platforms = platforms . all ;
40
+ passthru = {
41
+ # Used for debugging with nix repl
42
+ inherit pkgSet ;
43
+
44
+ # Used for testing externally with nix-shell (../tests.sh).
45
+ # This just adds cabal-install to the existing shell.
46
+ env = addCabalInstall env ;
47
+ } ;
48
+ }
Original file line number Diff line number Diff line change @@ -54,4 +54,11 @@ nix-shell $NIX_BUILD_ARGS \
54
54
--run ' cd cabal-simple && cabal new-build'
55
55
echo >& 2
56
56
57
+ printf " *** Checking shellFor works with a Stackage snapshot...\n" >& 2
58
+ nix-shell $NIX_BUILD_ARGS \
59
+ --pure ./default.nix \
60
+ -A shell-for.env \
61
+ --run ' cd shell-for && runghc conduit.hs'
62
+ echo >& 2
63
+
57
64
printf " \n*** Finished successfully\n" >& 2
You can’t perform that action at this time.
0 commit comments