Skip to content

Commit cee8245

Browse files
kirelaginangerman
authored andcommitted
Resolve local file snapshots relative to stack.yaml (input-output-hk#69)
1 parent 1b3d624 commit cee8245

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

stack2nix/Stack2nix.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ stackexpr args =
5757
case evalue of
5858
Left e -> error (show e)
5959
Right value -> stack2nix args
60-
=<< resolveSnapshot value
60+
=<< resolveSnapshot (argStackYaml args) value
6161

6262
stack2nix :: Args -> Stack -> IO NExpr
6363
stack2nix args stack@(Stack resolver compiler pkgs pkgFlags ghcOpts) =

stack2nix/Stack2nix/External/Resolve.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Data.Aeson
77
import Data.Yaml hiding (Parser)
88
import Control.Applicative ((<|>))
99
import Data.List (isPrefixOf, isSuffixOf)
10+
import System.FilePath ((</>), dropFileName)
1011

1112
import qualified Data.ByteString.Lazy.Char8 as L8
1213

@@ -34,15 +35,17 @@ decodeURLEither url
3435
-- | If a stack.yaml file contains a @resolver@ that points to
3536
-- a file, resolve that file and merge the snapshot into the
3637
-- @Stack@ record.
37-
resolveSnapshot :: Stack -> IO Stack
38-
resolveSnapshot stack@(Stack resolver compiler pkgs flags ghcOptions)
38+
resolveSnapshot :: FilePath -> Stack -> IO Stack
39+
resolveSnapshot stackYaml stack@(Stack resolver compiler pkgs flags ghcOptions)
3940
= if ".yaml" `isSuffixOf` resolver
4041
then do evalue <- if ("http://" `isPrefixOf` resolver) || ("https://" `isPrefixOf` resolver)
4142
then decodeURLEither resolver
42-
else decodeFileEither resolver
43+
else decodeFileEither (srcDir </> resolver)
4344
case evalue of
4445
Left e -> error (show e)
4546
Right (Snapshot resolver' compiler' _name pkgs' flags' ghcOptions') ->
4647
pure $ Stack resolver' (compiler' <|> compiler) (pkgs <> pkgs') (flags <> flags')
4748
(ghcOptions <> ghcOptions')
4849
else pure stack
50+
where
51+
srcDir = dropFileName stackYaml

0 commit comments

Comments
 (0)