Skip to content

Commit 2486133

Browse files
authored
Merge pull request #3916 from commercialhaskell/dont-require-yaml-persistent-sqlite
Don't require yaml and persistent-sqlite in snapshots
2 parents 44cbce7 + cd7f3b3 commit 2486133

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Stack/Snapshot.hs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import qualified Data.Conduit.List as CL
3232
import qualified Data.HashMap.Strict as HashMap
3333
import qualified Data.Map as Map
3434
import qualified Data.Set as Set
35+
import Data.Time (toGregorian)
3536
import qualified Data.Text as T
3637
import Data.Text.Encoding (encodeUtf8)
3738
import Data.Yaml (decodeFileEither, ParseException (AesonException))
@@ -686,10 +687,9 @@ findPackage platform compilerVersion (gpd, loc, localLoc) = do
686687
where
687688
PackageIdentifier name _version = fromCabalPackageIdentifier $ C.package $ C.packageDescription gpd
688689

689-
-- | Some hard-coded fixes for build plans, hopefully to be irrelevant over
690-
-- time.
690+
-- | Some hard-coded fixes for build plans, only for hysterical raisins.
691691
snapshotDefFixes :: SnapshotDef -> SnapshotDef
692-
snapshotDefFixes sd | isStackage (sdResolver sd) = sd
692+
snapshotDefFixes sd | isOldStackage (sdResolver sd) = sd
693693
{ sdFlags = Map.unionWith Map.union overrides $ sdFlags sd
694694
}
695695
where
@@ -698,8 +698,12 @@ snapshotDefFixes sd | isStackage (sdResolver sd) = sd
698698
, ($(mkPackageName "yaml"), Map.singleton $(mkFlagName "system-libyaml") False)
699699
]
700700

701-
isStackage (ResolverSnapshot _) = True
702-
isStackage _ = False
701+
-- Only apply this hack to older Stackage snapshots. In
702+
-- particular, nightly-2018-03-13 did not contain these two
703+
-- packages.
704+
isOldStackage (ResolverSnapshot (LTS major _)) = major < 11
705+
isOldStackage (ResolverSnapshot (Nightly (toGregorian -> (year, _, _)))) = year < 2018
706+
isOldStackage _ = False
703707
snapshotDefFixes sd = sd
704708

705709
-- | Convert a global 'LoadedPackageInfo' to a snapshot one by

0 commit comments

Comments
 (0)