Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion stack2nix/Stack2nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ stackexpr args =
case evalue of
Left e -> error (show e)
Right value -> stack2nix args
=<< resolveSnapshot value
=<< resolveSnapshot (argStackYaml args) value

stack2nix :: Args -> Stack -> IO NExpr
stack2nix args stack@(Stack resolver compiler pkgs pkgFlags ghcOpts) =
Expand Down
9 changes: 6 additions & 3 deletions stack2nix/Stack2nix/External/Resolve.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Data.Aeson
import Data.Yaml hiding (Parser)
import Control.Applicative ((<|>))
import Data.List (isPrefixOf, isSuffixOf)
import System.FilePath ((</>), dropFileName)

import qualified Data.ByteString.Lazy.Char8 as L8

Expand Down Expand Up @@ -34,15 +35,17 @@ decodeURLEither url
-- | If a stack.yaml file contains a @resolver@ that points to
-- a file, resolve that file and merge the snapshot into the
-- @Stack@ record.
resolveSnapshot :: Stack -> IO Stack
resolveSnapshot stack@(Stack resolver compiler pkgs flags ghcOptions)
resolveSnapshot :: FilePath -> Stack -> IO Stack
resolveSnapshot stackYaml stack@(Stack resolver compiler pkgs flags ghcOptions)
= if ".yaml" `isSuffixOf` resolver
then do evalue <- if ("http://" `isPrefixOf` resolver) || ("https://" `isPrefixOf` resolver)
then decodeURLEither resolver
else decodeFileEither resolver
else decodeFileEither (srcDir </> resolver)
case evalue of
Left e -> error (show e)
Right (Snapshot resolver' compiler' _name pkgs' flags' ghcOptions') ->
pure $ Stack resolver' (compiler' <|> compiler) (pkgs <> pkgs') (flags <> flags')
(ghcOptions <> ghcOptions')
else pure stack
where
srcDir = dropFileName stackYaml