on hkm/aarch64-linux-remote-fix help sign in
haskell.nix/snapshots.nix
77 lines 2.9 kB history raw
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
9{ lib, mkPkgSet, stackage, excludeBootPackages, ghc-boot-packages }:
11with lib;
13let
14 mkSnapshot = name: pkg-def: (let pkgSet = mkPkgSet {
15 pkg-def = excludeBootPackages null pkg-def;
16 # ghc-boot-packages are needed for the reinstallable ghc library and
17 # are constructed from the patched ghc source.
18 pkg-def-extras = (pkg-def-extras name)
19 ++ [(hackage: ghc-boot-packages.${(pkg-def hackage).compiler.nix-name})];
20 modules = [
21 { reinstallableLibGhc = true; } # Allow ghc library to be installed for packages that need it
22 { planned = true; } # All components in the snapshot are planned
23 { packages.alex.package.setup-depends = [pkgSet.config.hsPkgs.Cabal]; }
24 { packages.happy.package.setup-depends = [pkgSet.config.hsPkgs.Cabal]; }
25 ] ++ optional (ltsInRange "1" "15" name) {
26 packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ];
27 };
28 }; in pkgSet).config.hsPkgs;
30 # Tests whether snapshot name is an LTS within
31 # the half-open version interval [start, end).
32 ltsInRange = start: end: name: let
33 components = splitString "-" name;
34 version = concatStringsSep "-" (drop 1 components);
35 in
36 assert length components >= 2;
37 head components == "lts"
38 && versionAtLeast version start
39 && versionOlder version end;
41 # A function to get pkg-def-extras with build fixes for certain
42 # snapshots.
43 pkg-def-extras = let
44 fixes = {
45 # Work around a mismatch between stackage metadata and the
46 # libraries shipped with GHC.
47 # https://github.com/commercialhaskell/stackage/issues/4466
48 fix-ghc-transformers = {
49 predicate = ltsInRange "12" "14"; # [12, 14) : 14.1 has correct versions
50 extra = hackage: {
51 packages = {
52 "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
53 "process" = (((hackage.process)."1.6.5.0").revisions).default;
54 };
55 };
56 };
58 # Add hsc2hs to the snapshot. This is a build tool for many
59 # packages. Stackage does not include it in the snapshots
60 # because it is expected that hsc2hs comes with ghc.
61 fix-hsc2hs = {
62 predicate = ltsInRange "1" "14"; # [1, 14) : 14.1 includes hsc2hs
63 extra = hackage: {
64 packages = {
65 "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
66 };
67 };
68 };
69 };
71 applyFix = name: fix: optional ((fix.predicate or (const true)) name) fix.extra;
73 in
74 name: concatLists (mapAttrsToList (_: applyFix name) fixes);
76in
77 mapAttrs mkSnapshot stackage