git.iko.soy/typeable/stackage2nix
on master help sign in
Add support for hg location in stack.yaml
commitc0dca295fb6d87016b4e23a4986375f029802e92 authorDmitry Bushev <bushevdv@gmail.com> dateTue 4 Jul 2017, 16:20 (9 years ago) parent3fea146
3 files changed+40−14
src/Distribution/Nixpkgs/Haskell/Stack.hs+3−3 src/Stack/Config.hs+24−10 src/Stack/Config/Yaml.hs+13−1
src/Distribution/Nixpkgs/Haskell/Stack.hs+3−3
@@ -61,9 +61,9 @@ stackLocationToSource = \case
6161 , sourceRevision = mempty
6262 , sourceHash = UnknownHash
6363 , sourceCabalDir = mempty }
64− StackRepoGit rg -> Source
65− { sourceUrl = T.unpack $ rg ^. rgUri
66− , sourceRevision = T.unpack $ rg ^. rgCommit
64+ StackRepo r -> Source
65+ { sourceUrl = T.unpack $ r ^. rUri
66+ , sourceRevision = T.unpack $ r ^. rCommit
6767 , sourceHash = UnknownHash
6868 , sourceCabalDir = mempty }
6969
src/Stack/Config.hs+24−10
@@ -25,18 +25,22 @@ makePrisms ''StackResolver
2525unStackResolver :: StackResolver -> String
2626unStackResolver = T.unpack . fromStackResolver
2727
28−data RepoGit = RepoGit
29− { _rgUri :: !Text
30− , _rgCommit :: !Text
28+newtype Vcs = Vcs { fromVcs :: Text }
29+ deriving (Eq, Ord, Show)
30+
31+data Repo = Repo
32+ { _rVcs :: !Vcs
33+ , _rUri :: !Text
34+ , _rCommit :: !Text
3135 } deriving (Eq, Ord, Show)
3236
33−makeLenses ''RepoGit
37+makeLenses ''Repo
3438
3539data PackageLocation
3640 = HackagePackage Text
3741 | StackFilePath FilePath
3842 | StackUri URI
39− | StackRepoGit RepoGit
43+ | StackRepo Repo
4044 deriving (Eq, Ord, Show)
4145
4246makePrisms ''PackageLocation
@@ -72,18 +76,28 @@ fromYamlPackage = \case
7276 Yaml.LocationSimple (Yaml.Location p extraDep) ->
7377 StackPackage (parseSimplePath p) (fromMaybe False extraDep)
7478 Yaml.LocationGit (Location git extraDep) ->
75− StackPackage (StackRepoGit $ fromYamlGit git) (fromMaybe False extraDep)
79+ StackPackage (StackRepo $ fromYamlGit git) (fromMaybe False extraDep)
80+ Yaml.LocationHg (Location hg extraDep) ->
81+ StackPackage (StackRepo $ fromYamlHg hg) (fromMaybe False extraDep)
7682 where
7783 parseSimplePath (T.unpack -> p) = maybe (StackFilePath p) StackUri $ parseURI p
7884
7985fromYamlExtraDep :: Text -> StackPackage
8086fromYamlExtraDep = flip StackPackage True . HackagePackage
8187
82−fromYamlGit :: Yaml.Git -> RepoGit
83−fromYamlGit yg = RepoGit{..}
88+fromYamlGit :: Yaml.Git -> Repo
89+fromYamlGit yg = Repo{..}
90+ where
91+ _rVcs = Vcs "git"
92+ _rUri = yg ^. gGit
93+ _rCommit = yg ^. gCommit
94+
95+fromYamlHg :: Yaml.Hg -> Repo
96+fromYamlHg yh = Repo{..}
8497 where
85− _rgUri = yg ^. gGit
86− _rgCommit = yg ^. gCommit
98+ _rVcs = Vcs "hg"
99+ _rUri = yh ^. hHg
100+ _rCommit = yh ^. hCommit
87101
88102readStackConfig :: StackYaml -> IO (Either String StackConfig)
89103readStackConfig stackYaml = do
src/Stack/Config/Yaml.hs+13−1
@@ -25,10 +25,20 @@ makeLenses ''Git
2525
2626deriveJSON jsonOpts ''Git
2727
28+data Hg = Hg
29+ { _hHg :: !Text
30+ , _hCommit :: !Text
31+ } deriving (Eq, Show)
32+
33+makeLenses ''Hg
34+
35+deriveJSON jsonOpts ''Hg
36+
2837data Package
2938 = Simple Text
3039 | LocationSimple (Location Text)
3140 | LocationGit (Location Git)
41+ | LocationHg (Location Hg)
3242 deriving (Eq, Show)
3343
3444makePrisms ''Package
@@ -37,13 +47,15 @@ instance FromJSON Package where
3747 parseJSON v =
3848 (Simple <$> parseJSON v) <|>
3949 (LocationSimple <$> parseJSON v) <|>
40− (LocationGit <$> parseJSON v)
50+ (LocationGit <$> parseJSON v) <|>
51+ (LocationHg <$> parseJSON v)
4152
4253instance ToJSON Package where
4354 toJSON = \case
4455 Simple t -> toJSON t
4556 LocationSimple t -> toJSON t
4657 LocationGit t -> toJSON t
58+ LocationHg t -> toJSON t
4759
4860data Config = Config
4961 { _cResolver :: !Text