git.iko.soy/typeable/stackage2nix
on master help sign in
Add support for archive syntax
a9569b8Dmitry Bushev
src/Stack/Config.hs+8−6
@@ -123,17 +123,19 @@ fromYamlPackage
123 -> Yaml.Package
123 -> Yaml.Package
124 -> NonEmpty StackPackage
124 -> NonEmpty StackPackage
125fromYamlPackage fromSimple isExtraDep = \case
125fromYamlPackage fromSimple isExtraDep = \case
126− Yaml.Simple p ->
126+ Yaml.PSimple p ->
127 pure (fromSimple p)
127 pure (fromSimple p)
128− Yaml.LocationSimple (Location p extraDep ms) ->
128+ Yaml.PLocationSimple (Location p extraDep ms) ->
129 unroll ms $ StackPackage (parseSimplePath p) (fromMaybe False extraDep)
129 unroll ms $ StackPackage (parseSimplePath p) (fromMaybe False extraDep)
130− Yaml.LocationGit loc ->
130+ Yaml.PLocationGit loc ->
131 mkStackPackageRepo fromYamlGit loc
131 mkStackPackageRepo fromYamlGit loc
132− Yaml.LocationHg loc ->
132+ Yaml.PLocationHg loc ->
133 mkStackPackageRepo fromYamlHg loc
133 mkStackPackageRepo fromYamlHg loc
134+ Yaml.PArchive a ->
135+ unroll (a ^. aSubdirs) $ StackPackage (a ^. aArchive . to parseSimplePath) isExtraDep
134− Yaml.PNewGit ng -> unroll (ng ^. ngSubdirs)
136+ Yaml.PNewGit ng -> unroll (ng ^. ngSubdirs)
135 $ StackPackage (StackRepo $ fromYamlNewGit ng) isExtraDep
137 $ StackPackage (StackRepo $ fromYamlNewGit ng) isExtraDep
136− Yaml.PNewHg nh -> unroll (nh ^. nhSubdirs)
138+ Yaml.PNewHg nh -> unroll (nh ^. nhSubdirs)
137 $ StackPackage (StackRepo $ fromYamlNewHg nh) isExtraDep
139 $ StackPackage (StackRepo $ fromYamlNewHg nh) isExtraDep
138 where
140 where
139 mkStackPackageRepo f loc = unroll (loc ^. lSubdirs)
141 mkStackPackageRepo f loc = unroll (loc ^. lSubdirs)
src/Stack/Config/Yaml.hs+26−14
@@ -16,6 +16,15 @@ data Location a = Location
16makeLenses ''Location
16makeLenses ''Location
17deriveJSON jsonOpts ''Location
17deriveJSON jsonOpts ''Location
18
18
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+
19data Git = Git
28data Git = Git
20 { _gGit :: Text
29 { _gGit :: Text
21 , _gCommit :: Text
30 , _gCommit :: Text
@@ -53,10 +62,11 @@ makeLenses ''NewHg
53deriveJSON jsonOpts ''NewHg
62deriveJSON jsonOpts ''NewHg
54
63
55data Package
64data Package
56− = Simple Text
65+ = PSimple Text
57− | LocationSimple (Location Text)
66+ | PLocationSimple (Location Text)
58− | LocationGit (Location Git)
67+ | PLocationGit (Location Git)
59− | LocationHg (Location Hg)
68+ | PLocationHg (Location Hg)
69+ | PArchive Archive
60 | PNewGit NewGit
70 | PNewGit NewGit
61 | PNewHg NewHg
71 | PNewHg NewHg
62 deriving (Eq, Show)
72 deriving (Eq, Show)
@@ -65,21 +75,23 @@ makePrisms ''Package
65
75
66instance FromJSON Package where
76instance FromJSON Package where
67 parseJSON v =
77 parseJSON v =
68− (Simple <$> parseJSON v) <|>
78+ (PSimple <$> parseJSON v) <|>
69− (LocationSimple <$> parseJSON v) <|>
79+ (PLocationSimple <$> parseJSON v) <|>
70− (LocationGit <$> parseJSON v) <|>
80+ (PLocationGit <$> parseJSON v) <|>
81+ (PLocationHg <$> parseJSON v) <|>
71− (LocationHg <$> parseJSON v) <|>
82+ (PArchive <$> parseJSON v) <|>
72 (PNewGit <$> parseJSON v) <|>
83 (PNewGit <$> parseJSON v) <|>
73 (PNewHg <$> parseJSON v)
84 (PNewHg <$> parseJSON v)
74
85
75instance ToJSON Package where
86instance ToJSON Package where
76 toJSON = \case
87 toJSON = \case
77− Simple t -> toJSON t
88+ PSimple t -> toJSON t
78− LocationSimple t -> toJSON t
89+ PLocationSimple t -> toJSON t
79− LocationGit t -> toJSON t
90+ PLocationGit t -> toJSON t
80− LocationHg t -> toJSON t
91+ PLocationHg t -> toJSON t
92+ PArchive t -> toJSON t
81− PNewGit t -> toJSON t
93+ PNewGit t -> toJSON t
82− PNewHg t -> toJSON t
94+ PNewHg t -> toJSON t
83
95
84-- To support support both old and new syntax, we allow all varieties of package
96-- To support support both old and new syntax, we allow all varieties of package
85-- definitions in both "packages" and "extra-deps" sections
97-- definitions in both "packages" and "extra-deps" sections
test/Stack/Config/YamlSpec.hs+29−16
@@ -69,13 +69,18 @@ extra-deps:
69 subdirs:
69 subdirs:
70 - subdir1
70 - subdir1
71 - subdir2
71 - 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
72|]
78|]
73
79
74−
75configMinimal :: Config
80configMinimal :: Config
76configMinimal = Config
81configMinimal = Config
77 { _cResolver = "lts-8.15"
82 { _cResolver = "lts-8.15"
78− , _cPackages = Just [ Simple "." ]
83+ , _cPackages = Just [ PSimple "." ]
79 , _cExtraDeps = Nothing
84 , _cExtraDeps = Nothing
80 }
85 }
81
86
@@ -83,46 +88,46 @@ config :: Config
83config = Config
88config = Config
84 { _cResolver = "lts-3.7"
89 { _cResolver = "lts-3.7"
85 , _cPackages = Just
90 , _cPackages = Just
86− [ Simple "."
91+ [ PSimple "."
87− , LocationSimple (Location "dir1/dir2" Nothing Nothing)
92+ , PLocationSimple (Location "dir1/dir2" Nothing Nothing)
88− , LocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
93+ , PLocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
89− , LocationGit $ Location
94+ , PLocationGit $ Location
90 (Git
95 (Git
91 "git@github.com:commercialhaskell/stack.git"
96 "git@github.com:commercialhaskell/stack.git"
92 "6a86ee32e5b869a877151f74064572225e1a0398")
97 "6a86ee32e5b869a877151f74064572225e1a0398")
93 Nothing Nothing
98 Nothing Nothing
94− , LocationGit (Location
99+ , PLocationGit (Location
95 (Git
100 (Git
96 "git@github.com:example/mega-repo"
101 "git@github.com:example/mega-repo"
97 "6a86ee32e5b869a877151f74064572225e1a0000")
102 "6a86ee32e5b869a877151f74064572225e1a0000")
98 Nothing (Just ["subdir1", "subdir2"]))
103 Nothing (Just ["subdir1", "subdir2"]))
99 ]
104 ]
100 , _cExtraDeps = Just
105 , _cExtraDeps = Just
101− [Simple "acme-missiles-0.3"]
106+ [PSimple "acme-missiles-0.3"]
102 }
107 }
103
108
104configNew :: Config
109configNew :: Config
105configNew = Config
110configNew = Config
106 { _cResolver = "lts-3.7"
111 { _cResolver = "lts-3.7"
107 , _cPackages = Just
112 , _cPackages = Just
108− [ Simple "."
113+ [ PSimple "."
109− , LocationSimple (Location "dir1/dir2" Nothing Nothing)
114+ , PLocationSimple (Location "dir1/dir2" Nothing Nothing)
110− , LocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
115+ , PLocationSimple (Location "https://example.com/foo/bar/baz-0.0.2.tar.gz" (Just True) Nothing)
111− , LocationGit $ Location
116+ , PLocationGit $ Location
112 (Git
117 (Git
113 "git@github.com:commercialhaskell/stack.git"
118 "git@github.com:commercialhaskell/stack.git"
114 "6a86ee32e5b869a877151f74064572225e1a0398")
119 "6a86ee32e5b869a877151f74064572225e1a0398")
115 Nothing Nothing
120 Nothing Nothing
116− , LocationGit (Location
121+ , PLocationGit (Location
117 (Git
122 (Git
118 "git@github.com:example/mega-repo"
123 "git@github.com:example/mega-repo"
119 "6a86ee32e5b869a877151f74064572225e1a0000")
124 "6a86ee32e5b869a877151f74064572225e1a0000")
120 Nothing (Just ["subdir1", "subdir2"]))
125 Nothing (Just ["subdir1", "subdir2"]))
121 ]
126 ]
122 , _cExtraDeps = Just
127 , _cExtraDeps = Just
123− [ Simple "acme-missiles-0.3"
128+ [ PSimple "acme-missiles-0.3"
124− , Simple "acme-missiles-hash-0.4@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1"
129+ , PSimple "acme-missiles-hash-0.4@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1"
125− , Simple "acme-missiles-rev-0.5@rev:0"
130+ , PSimple "acme-missiles-rev-0.5@rev:0"
126 , PNewGit $ NewGit
131 , PNewGit $ NewGit
127 "git@github.com:commercialhaskell/stack.git"
132 "git@github.com:commercialhaskell/stack.git"
128 "6a86ee32e5b869a877151f74064572225e1a0398"
133 "6a86ee32e5b869a877151f74064572225e1a0398"
@@ -131,6 +136,14 @@ configNew = Config
131 "git@github.com:example/mega-repo"
136 "git@github.com:example/mega-repo"
132 "6a86ee32e5b869a877151f74064572225e1a0000"
137 "6a86ee32e5b869a877151f74064572225e1a0000"
133 (Just ["subdir1", "subdir2"])
138 (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
134 ]
147 ]
135 }
148 }
136
149