on iko/ghcjs-patch-master help sign in
Add snapshots attribute (#151)
37a1b7aRodney Lorrimar
@@ -109,6 +109,11 @@ let
109 modules = [ ghcHackagePatches.${compiler.nix-name} ] ++ modules;
109 modules = [ ghcHackagePatches.${compiler.nix-name} ] ++ modules;
110 };
110 };
111
111
112+ # Package sets for all stackage snapshots.
113+ snapshots = self.callPackage ./snapshots.nix {};
114+ # Pick a recent LTS snapshot to be our "default" package set.
115+ haskellPackages = self.snapshots."lts-13.18";
116+
112 # Programs for generating Nix expressions from Cabal and Stack
117 # Programs for generating Nix expressions from Cabal and Stack
113 # files. We need to make sure we build this from the buildPackages,
118 # files. We need to make sure we build this from the buildPackages,
114 # we never want to actually cross compile nix-tools on it's own.
119 # we never want to actually cross compile nix-tools on it's own.
snapshots.nixnew file+65
@@ -0,0 +1,65 @@
1+# This provides a package set for each snapshot in Stackage.
2+#
3+# It allows you to use a bare snapshot without having to invoke
4+# mkStackPkgSet with a stack.yaml project.
5+#
6+# A particular package in a snapshot would be accessed with:
7+# snapshots."lts-13.18".conduit
8+
9+{ lib, mkPkgSet, stackage }:
10+
11+with lib;
12+
13+let
14+ mkSnapshot = name: pkg-def: (mkPkgSet {
15+ inherit pkg-def;
16+ pkg-def-extras = pkg-def-extras name;
17+ }).config.hsPkgs;
18+
19+ # Tests whether snapshot name is an LTS within
20+ # the half-open version interval [start, end).
21+ ltsInRange = start: end: name: let
22+ components = splitString "-" name;
23+ version = concatStringsSep "-" (drop 1 components);
24+ in
25+ assert length components >= 2;
26+ head components == "lts"
27+ && versionAtLeast version start
28+ && versionOlder version end;
29+
30+ # A function to get pkg-def-extras with build fixes for certain
31+ # snapshots.
32+ pkg-def-extras = let
33+ fixes = {
34+ # Work around a mismatch between stackage metadata and the
35+ # libraries shipped with GHC.
36+ # https://github.com/commercialhaskell/stackage/issues/4466
37+ fix-ghc-transformers = {
38+ predicate = ltsInRange "12" "14";
39+ extra = hackage: {
40+ packages = {
41+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
42+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
43+ };
44+ };
45+ };
46+
47+ # Add hsc2hs to the snapshot. This is a build tool for many
48+ # packages. Stackage does not include it in the snapshots
49+ # because it is expected that hsc2hs comes with ghc.
50+ fix-hsc2hs = {
51+ extra = hackage: {
52+ packages = {
53+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
54+ };
55+ };
56+ };
57+ };
58+
59+ applyFix = name: fix: optional ((fix.predicate or (const true)) name) fix.extra;
60+
61+ in
62+ name: concatLists (mapAttrsToList (_: applyFix name) fixes);
63+
64+in
65+ mapAttrs mkSnapshot stackage
test/default.nix+1−1
@@ -16,8 +16,8 @@ in {
16 with-packages = haskell.callPackage ./with-packages { inherit util; };
16 with-packages = haskell.callPackage ./with-packages { inherit util; };
17 builder-haddock = haskell.callPackage ./builder-haddock {};
17 builder-haddock = haskell.callPackage ./builder-haddock {};
18 stack-simple = haskell.callPackage ./stack-simple {};
18 stack-simple = haskell.callPackage ./stack-simple {};
19+ snapshots = haskell.callPackage ./snapshots {};
19 callStackToNix = haskell.callPackage ./callStackToNix {};
20 callStackToNix = haskell.callPackage ./callStackToNix {};
20−
21 callCabalProjectToNix = haskell.callPackage ./call-cabal-project-to-nix {};
21 callCabalProjectToNix = haskell.callPackage ./call-cabal-project-to-nix {};
22
22
23 # Run unit tests with: nix-instantiate --eval --strict -A unit
23 # Run unit tests with: nix-instantiate --eval --strict -A unit
test/snapshots/default.nixnew file+19
@@ -0,0 +1,19 @@
1+{ stdenv, haskellPackages }:
2+
3+with stdenv.lib;
4+
5+ stdenv.mkDerivation {
6+ name = "shell-for-test";
7+
8+ buildCommand = ''
9+ ########################################################################
10+ # test snapshot ghcWithHoogle
11+
12+ printf "checking that the latest LTS snapshot has the lens package...\n" >& 2
13+ test -d ${haskellPackages.lens.components.library}
14+
15+ touch $out
16+ '';
17+
18+ meta.platforms = platforms.all;
19+ }