git.iko.soy/typeable/stackage2nix
on master help sign in
Add support for archive syntax
commita9569b8641077216ba20978bdf9e9b48373f2013 authorDmitry Bushev <bushevdv@gmail.com> dateSun 18 Mar 2018, 16:08 (9 years ago) parent9785fc7
3 files changed+63−36
src/Stack/Config.hs+8−6 src/Stack/Config/Yaml.hs+26−14 test/Stack/Config/YamlSpec.hs+29−16
src/Stack/Config.hs+8−6
@@ -123,17 +123,19 @@ fromYamlPackage
123123 -> Yaml.Package
124124 -> NonEmpty StackPackage
125125fromYamlPackage fromSimple isExtraDep = \case
126− Yaml.Simple p ->
126+ Yaml.PSimple p ->
127127 pure (fromSimple p)
128− Yaml.LocationSimple (Location p extraDep ms) ->
128+ Yaml.PLocationSimple (Location p extraDep ms) ->
129129 unroll ms $ StackPackage (parseSimplePath p) (fromMaybe False extraDep)
130− Yaml.LocationGit loc ->
130+ Yaml.PLocationGit loc ->
131131 mkStackPackageRepo fromYamlGit loc
132− Yaml.LocationHg loc ->
132+ Yaml.PLocationHg loc ->
133133 mkStackPackageRepo fromYamlHg loc
134− Yaml.PNewGit ng -> unroll (ng ^. ngSubdirs)
134+ Yaml.PArchive a ->
135+ unroll (a ^. aSubdirs) $ StackPackage (a ^. aArchive . to parseSimplePath) isExtraDep
136+ Yaml.PNewGit ng -> unroll (ng ^. ngSubdirs)
135137 $ StackPackage (StackRepo $ fromYamlNewGit ng) isExtraDep
136− Yaml.PNewHg nh -> unroll (nh ^. nhSubdirs)
138+ Yaml.PNewHg nh -> unroll (nh ^. nhSubdirs)
137139 $ StackPackage (StackRepo $ fromYamlNewHg nh) isExtraDep
138140 where
139141 mkStackPackageRepo f loc = unroll (loc ^. lSubdirs)
src/Stack/Config/Yaml.hs+26−14
@@ -16,6 +16,15 @@ data Location a = Location
1616makeLenses ''Location
1717deriveJSON jsonOpts ''Location
1818
19+data Archive = Archive
20+ { _aArchive :: Text
21+ , _aSha256 :: Maybe Text
22+ , _aSubdirs :: Maybe [FilePath]
23+ } deriving (Eq, Show)
24+
25+makeLenses ''Archive
26+deriveJSON jsonOpts ''Archive
27+
1928data Git = Git
2029 { _gGit :: Text
2130 , _gCommit :: Text
@@ -53,10 +62,11 @@ makeLenses ''NewHg
5362deriveJSON jsonOpts ''NewHg
5463
5564data Package
56− = Simple Text
57− | LocationSimple (Location Text)
58− | LocationGit (Location Git)
59− | LocationHg (Location Hg)
65+ = PSimple Text
66+ | PLocationSimple (Location Text)
67+ | PLocationGit (Location Git)
68+ | PLocationHg (Location Hg)
69+ | PArchive Archive
6070 | PNewGit NewGit
6171 | PNewHg NewHg
6272 deriving (Eq, Show)
@@ -65,21 +75,23 @@ makePrisms ''Package
6575
6676instance FromJSON Package where
6777 parseJSON v =
68− (Simple <$> parseJSON v) <|>
69− (LocationSimple <$> parseJSON v) <|>
70− (LocationGit <$> parseJSON v) <|>
71− (LocationHg <$> parseJSON v) <|>
78+ (PSimple <$> parseJSON v) <|>
79+ (PLocationSimple <$> parseJSON v) <|>
80+ (PLocationGit <$> parseJSON v) <|>
81+ (PLocationHg <$> parseJSON v) <|>
82+ (PArchive <$> parseJSON v) <|>
7283 (PNewGit <$> parseJSON v) <|>
7384 (PNewHg <$> parseJSON v)
7485
7586instance ToJSON Package where
7687 toJSON = \case
77− Simple t -> toJSON t
78− LocationSimple t -> toJSON t
79− LocationGit t -> toJSON t
80− LocationHg t -> toJSON t
81− PNewGit t -> toJSON t
82− PNewHg t -> toJSON t
88+ PSimple t -> toJSON t
89+ PLocationSimple t -> toJSON t
90+ PLocationGit t -> toJSON t
91+ PLocationHg t -> toJSON t
92+ PArchive t -> toJSON t
93+ PNewGit t -> toJSON t
94+ PNewHg t -> toJSON t
8395
8496-- To support support both old and new syntax, we allow all varieties of package
8597-- definitions in both "packages" and "extra-deps" sections
test/Stack/Config/YamlSpec.hs+29−16
@@ -69,13 +69,18 @@ extra-deps:
6969 subdirs:
7070 - subdir1
7171 - subdir2
72+ - archive: http://github.com/yesodweb/wai/archive/2f8a8e1b771829f4a8a77c0111352ce45a14c30f.zip
73+ subdirs:
74+ - wai
75+ - warp
76+ - archive: ../acme-missiles-0.3.tar.gz
77+ sha256: e563d8b524017a06b32768c4db8eff1f822f3fb22a90320b7e414402647b735b
7278|]
7379
74−
7580configMinimal :: Config
7681configMinimal = Config
7782 { _cResolver = "lts-8.15"
78− , _cPackages = Just [ Simple "." ]
83+ , _cPackages = Just [ PSimple "." ]
7984 , _cExtraDeps = Nothing
8085 }
8186
@@ -83,46 +88,46 @@ config :: Config
8388config = Config
8489 { _cResolver = "lts-3.7"
8590 , _cPackages = Just
86− [ Simple "."
87− , LocationSimple (Location "dir1/dir2" Nothing Nothing)
88− , LocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
89− , LocationGit $ Location
91+ [ PSimple "."
92+ , PLocationSimple (Location "dir1/dir2" Nothing Nothing)
93+ , PLocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
94+ , PLocationGit $ Location
9095 (Git
9196 "git@github.com:commercialhaskell/stack.git"
9297 "6a86ee32e5b869a877151f74064572225e1a0398")
9398 Nothing Nothing
94− , LocationGit (Location
99+ , PLocationGit (Location
95100 (Git
96101 "git@github.com:example/mega-repo"
97102 "6a86ee32e5b869a877151f74064572225e1a0000")
98103 Nothing (Just ["subdir1", "subdir2"]))
99104 ]
100105 , _cExtraDeps = Just
101− [Simple "acme-missiles-0.3"]
106+ [PSimple "acme-missiles-0.3"]
102107 }
103108
104109configNew :: Config
105110configNew = Config
106111 { _cResolver = "lts-3.7"
107112 , _cPackages = Just
108− [ Simple "."
109− , LocationSimple (Location "dir1/dir2" Nothing Nothing)
110− , LocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
111− , LocationGit $ Location
113+ [ PSimple "."
114+ , PLocationSimple (Location "dir1/dir2" Nothing Nothing)
115+ , PLocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
116+ , PLocationGit $ Location
112117 (Git
113118 "git@github.com:commercialhaskell/stack.git"
114119 "6a86ee32e5b869a877151f74064572225e1a0398")
115120 Nothing Nothing
116− , LocationGit (Location
121+ , PLocationGit (Location
117122 (Git
118123 "git@github.com:example/mega-repo"
119124 "6a86ee32e5b869a877151f74064572225e1a0000")
120125 Nothing (Just ["subdir1", "subdir2"]))
121126 ]
122127 , _cExtraDeps = Just
123− [ Simple "acme-missiles-0.3"
124− , Simple "acme-missiles-hash-0.4@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1"
125− , Simple "acme-missiles-rev-0.5@rev:0"
128+ [ PSimple "acme-missiles-0.3"
129+ , PSimple "acme-missiles-hash-0.4@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1"
130+ , PSimple "acme-missiles-rev-0.5@rev:0"
126131 , PNewGit $ NewGit
127132 "git@github.com:commercialhaskell/stack.git"
128133 "6a86ee32e5b869a877151f74064572225e1a0398"
@@ -131,6 +136,14 @@ configNew = Config
131136 "git@github.com:example/mega-repo"
132137 "6a86ee32e5b869a877151f74064572225e1a0000"
133138 (Just ["subdir1", "subdir2"])
139+ , PArchive $ Archive
140+ "http://github.com/yesodweb/wai/archive/2f8a8e1b771829f4a8a77c0111352ce45a14c30f.zip"
141+ Nothing
142+ (Just ["wai", "warp"])
143+ , PArchive $ Archive
144+ "../acme-missiles-0.3.tar.gz"
145+ (Just "e563d8b524017a06b32768c4db8eff1f822f3fb22a90320b7e414402647b735b")
146+ Nothing
134147 ]
135148 }
136149