mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-11-10 06:47:48 +03:00
674f5b0a3d
This change updates to the latest `nix-tools` to get the following fixes (there are 3 PRs in nix-tools, but just the one in haskell.nix to avoid having to update the materialized files multiple times): ## Better support for source repository packages * https://github.com/input-output-hk/nix-tools/pull/107 Currently these are replaced by the `cabalProject` functions with regular `packages:` before running cabal configure. Cabal does not treat these the same (the setting of `tests:` and `benchmarks:` in the `cabal.project` file): * The plan found by `cabalProject` may not match the one used when running `cabal`. * The performance of the solver may not be consistent with running `cabal`. This change replaces `source-repository-package` with another `source-repository-package` pointing at a minimal git repo. ## Only include planned components * https://github.com/input-output-hk/nix-tools/pull/108 Only the components in the `plan.json` are now included in the haskell.nix cabal projects. This avoids missing dependencies attempting to build components that were not in the plan. Should fix #993. ## Pick latest packages * https://github.com/input-output-hk/nix-tools/pull/109 When the same package occurs more than once in a `plan.json` file (perhaps because it is needed both by the project itself and by one of the `setup` dependencies or `build-tool-dependencies` of the project) the latest version will now be the one picked by haskell.nix. This is a work around for a common issue with `cabal-doctest` when cross compiling to windows (an old version of Win32 is used even if a newer one was required by the projects `constraints`).
78 lines
2.8 KiB
Nix
78 lines
2.8 KiB
Nix
# This provides a package set for each snapshot in Stackage.
|
|
#
|
|
# It allows you to use a bare snapshot without having to invoke
|
|
# mkStackPkgSet with a stack.yaml project.
|
|
#
|
|
# A particular package in a snapshot would be accessed with:
|
|
# snapshots."lts-13.18".conduit
|
|
|
|
{ lib, mkPkgSet, stackage, excludeBootPackages, ghc-boot-packages }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
mkSnapshot = name: pkg-def: (let pkgSet = mkPkgSet {
|
|
pkg-def = excludeBootPackages null pkg-def;
|
|
# ghc-boot-packages are needed for the reinstallable ghc library and
|
|
# are constructed from the patched ghc source.
|
|
pkg-def-extras = (pkg-def-extras name)
|
|
++ [(hackage: ghc-boot-packages.${(pkg-def hackage).compiler.nix-name})];
|
|
modules = [
|
|
{ reinstallableLibGhc = true; } # Allow ghc library to be installed for packages that need it
|
|
{ planned = true; } # All components in the snapshot are planned
|
|
{ packages.alex.package.setup-depends = [pkgSet.config.hsPkgs.Cabal]; }
|
|
{ packages.happy.package.setup-depends = [pkgSet.config.hsPkgs.Cabal]; }
|
|
] ++ optional (ltsInRange "1" "15" name) {
|
|
packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ];
|
|
};
|
|
}; in pkgSet).config.hsPkgs;
|
|
|
|
# Tests whether snapshot name is an LTS within
|
|
# the half-open version interval [start, end).
|
|
ltsInRange = start: end: name: let
|
|
components = splitString "-" name;
|
|
version = concatStringsSep "-" (drop 1 components);
|
|
in
|
|
assert length components >= 2;
|
|
head components == "lts"
|
|
&& versionAtLeast version start
|
|
&& versionOlder version end;
|
|
|
|
# A function to get pkg-def-extras with build fixes for certain
|
|
# snapshots.
|
|
pkg-def-extras = let
|
|
fixes = {
|
|
# Work around a mismatch between stackage metadata and the
|
|
# libraries shipped with GHC.
|
|
# https://github.com/commercialhaskell/stackage/issues/4466
|
|
fix-ghc-transformers = {
|
|
predicate = ltsInRange "12" "14"; # [12, 14) : 14.1 has correct versions
|
|
extra = hackage: {
|
|
packages = {
|
|
"transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
|
|
"process" = (((hackage.process)."1.6.5.0").revisions).default;
|
|
};
|
|
};
|
|
};
|
|
|
|
# Add hsc2hs to the snapshot. This is a build tool for many
|
|
# packages. Stackage does not include it in the snapshots
|
|
# because it is expected that hsc2hs comes with ghc.
|
|
fix-hsc2hs = {
|
|
predicate = ltsInRange "1" "14"; # [1, 14) : 14.1 includes hsc2hs
|
|
extra = hackage: {
|
|
packages = {
|
|
"hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
applyFix = name: fix: optional ((fix.predicate or (const true)) name) fix.extra;
|
|
|
|
in
|
|
name: concatLists (mapAttrsToList (_: applyFix name) fixes);
|
|
|
|
in
|
|
mapAttrs mkSnapshot stackage
|