Skip to content

Commit

Permalink
Parallelize fetching deps
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Dec 30, 2017
1 parent d2f31c0 commit a98a343
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions elm2nix.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ library
src
build-depends:
base >= 4.7 && < 5
, async
, elm-package
, elm-compiler
, directory
Expand Down
3 changes: 3 additions & 0 deletions elm2nix/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import qualified Control.Monad (join)
import Data.Version (showVersion)
import Data.String.Here
import Options.Applicative
import System.IO
import qualified Lib
import qualified Paths_elm2nix as This
import qualified Text.PrettyPrint.ANSI.Leijen as PP

main :: IO ()
main = do
hSetBuffering stdout LineBuffering
hSetBuffering stderr LineBuffering
cmd <- getOpts
case cmd of
Convert -> Lib.convert
Expand Down
6 changes: 3 additions & 3 deletions src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Lib
, init'
) where

import Control.Monad (mapM)
import Control.Concurrent.Async
import Control.Monad.Except (liftIO, throwError)
import Data.List (intercalate)
import qualified Data.Text as Text
Expand Down Expand Up @@ -59,7 +59,7 @@ generateDefault = do

solveDependencies :: Manager.Manager ()
solveDependencies = do
liftIO $ hPutStrLn stderr "Resolving elm-package.json dependencies into elm-stuff/exact-dependencies.json ..."
liftIO $ hPutStrLn stderr "Resolving elm-package.json dependencies into Nix ..."

desc <- readDescription
newSolution <- Solver.solve (Desc.elmVersion desc) (Desc.dependencies desc)
Expand All @@ -69,7 +69,7 @@ solveDependencies = do
liftIO $ hPutStrLn stderr "Prefetching tarballs and computing sha256 hashes ..."

let solL = Map.toList newSolution
sources <- liftIO $ mapM Prefetch.prefetchURL solL
sources <- liftIO $ mapConcurrently Prefetch.prefetchURL solL

liftIO $ putStrLn $ generateNixSources sources

Expand Down

0 comments on commit a98a343

Please sign in to comment.