Skip to content

Add compiler packages to list of packages in Stackage LTS #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lts2nix/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ lts2plan compilerPackagesMap lts = Plan { packages, compilerVersion, compilerPac
compilerName = lts ^. key "resolver" . key "compiler" . _String
compilerVersion = parseCompilerVersion compilerName
compilerPackages = Just <$> Map.lookupDefault (error $ "failed to lookup the compiler packages for compiler: " ++ Text.unpack compilerName) compilerName compilerPackagesMap
compilerPackages' = fmap vrToPkg <$> compilerPackages
where vrToPkg v = Package v Nothing Map.empty

-- turn flags into HashMap Text (HashMap Text Bool)
flags :: Map.HashMap Text (Map.HashMap Text Bool)
flags = lts ^. key "flags" . _Object <&> (\v -> Map.mapMaybe (^? _Bool) $ v ^. _Object)
packages = Map.fromList . V.toList $ lts ^. key "packages" . _Array <&> \v ->
packages' = Map.fromList . V.toList $ lts ^. key "packages" . _Array <&> \v ->
let (pkg, rev) = case (parsePackageIdentifier . Text.unpack $ v ^. key "hackage" . _String) of
Just p -> p
_ -> error $ "failed to parse: " ++ Text.unpack (v ^. key "hackage" . _String)
Expand All @@ -76,3 +78,5 @@ lts2plan compilerPackagesMap lts = Plan { packages, compilerVersion, compilerPac
_ -> Nothing
, packageFlags = Map.lookupDefault Map.empty name flags
})

packages = packages' `Map.union` compilerPackages'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want the union the other way around. If packages provides overrides for the compilerPackages, we want them to override those, not rely on the compilerPackages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was my idea too. According to the docs:

The union of two maps. If a key occurs in both maps, the mapping from the first will be the mapping in the result.

so packages' has preference over compilerPackages'.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh... that's somewhat counter intuitive... thanks!