on master help sign in
Replace runInteractiveProcess with callProcess

- the former is deprecated - the later provides better error diagnostics

commit5efd3c7fac9dafcdb0a8a8dd0922b60e8804355f authorSridhar Ratnakumar <srid@srid.ca> dateMon 30 Apr 2018, 21:45 (8 years ago) parentd376ce1
3 files changed+18−15
lib/command/src/Obelisk/Command/Nix.hs+5−1 lib/command/src/Obelisk/Command/Project.hs+4−5 lib/command/src/Obelisk/Command/Thunk.hs+9−9
lib/command/src/Obelisk/Command/Nix.hs+5−1
@@ -54,10 +54,14 @@ nixBuild cfg = do
5454 OutLink_None -> ["--no-out-link"]
5555 OutLink_IndirectRoot outLink -> ["--indirect", "--add-root", outLink]
5656 ]
57− (_, out, err, p) <- runInteractiveProcess "nix-build" args Nothing Nothing
57+ (_, Just out, Just err, p) <- createProcess (proc "nix-build" args)
58+ { std_out = CreatePipe
59+ , std_err = CreatePipe
60+ }
5861 waitForProcess p >>= \case
5962 ExitSuccess -> return ()
6063 _ -> do
64+ -- FIXME: We should interleave `out` and `err` in their original order?
6165 LBS.putStr =<< LBS.hGetContents out
6266 LBS.putStr =<< LBS.hGetContents err
6367 fail "nix-build failed"
lib/command/src/Obelisk/Command/Project.hs+4−5
@@ -20,12 +20,12 @@ import System.Directory
2020import System.Exit
2121import System.FilePath
2222import System.IO
23−import System.Posix (FileStatus, getFileStatus , deviceID, fileID, getRealUserID , fileOwner, fileMode, UserID)
23+import System.Posix (FileStatus, UserID, deviceID, fileID, fileMode, fileOwner, getFileStatus, getRealUserID)
2424import System.Posix.Files
2525import System.Process
2626
27−import GitHub.Data.Name (Name)
2827import GitHub.Data.GitData (Branch)
28+import GitHub.Data.Name (Name)
2929
3030import Obelisk.Command.Thunk
3131
@@ -67,14 +67,13 @@ initProject source = do
6767 _ <- nixBuildAttrWithCache implDir "command"
6868 --TODO: We should probably handoff to the impl here
6969 skeleton <- nixBuildAttrWithCache implDir "skeleton" --TODO: I don't think there's actually any reason to cache this
70− (_, _, _, p) <- runInteractiveProcess "cp" --TODO: Make this package depend on nix-prefetch-url properly
70+ callProcess "cp" --TODO: Make this package depend on nix-prefetch-url properly
7171 [ "-r"
7272 , "--no-preserve=mode"
7373 , "-T"
7474 , skeleton </> "."
7575 , "."
76− ] Nothing Nothing
77− ExitSuccess <- waitForProcess p
76+ ]
7877 return ()
7978
8079--TODO: Handle errors
lib/command/src/Obelisk/Command/Thunk.hs+9−9
@@ -42,14 +42,14 @@ import Data.Set (Set)
4242import qualified Data.Set as Set
4343import Data.Text (Text)
4444import qualified Data.Text as T
45−import qualified Data.Text.IO as T
4645import Data.Text.Encoding
46+import qualified Data.Text.IO as T
4747import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
4848import Data.Yaml (parseMaybe, (.:))
4949import qualified Data.Yaml as Yaml
5050import GitHub
51−import GitHub.Endpoints.Repos.Contents (archiveForR)
5251import GitHub.Data.Name
52+import GitHub.Endpoints.Repos.Contents (archiveForR)
5353import Network.URI
5454import Obelisk.Command.Nix
5555import System.Directory
@@ -58,7 +58,7 @@ import System.FilePath
5858import System.IO
5959import System.IO.Error
6060import System.IO.Temp
61−import System.Posix (modificationTime, getSymbolicLinkStatus)
61+import System.Posix (getSymbolicLinkStatus, modificationTime)
6262import System.Process
6363
6464import Development.Placeholders
@@ -116,12 +116,12 @@ commitNameToRef (N c) = Ref.fromHex $ encodeUtf8 c
116116
117117getNixSha256ForUriUnpacked :: URI -> IO NixSha256
118118getNixSha256ForUriUnpacked uri = do
119− (_, out, err, p) <- runInteractiveProcess "nix-prefetch-url" --TODO: Make this package depend on nix-prefetch-url properly
120− [ "--unpack"
121− , "--type"
122− , "sha256"
123− , show uri
124− ] Nothing Nothing
119+ --TODO: Make this package depend on nix-prefetch-url properly
120+ let cmd = proc "nix-prefetch-url" ["--unpack" , "--type" , "sha256" , show uri]
121+ (_, Just out, Just err, p) <- createProcess cmd
122+ { std_out = CreatePipe
123+ , std_err = CreatePipe
124+ }
125125 --TODO: Deal with errors here; usually they're HTTP errors
126126 waitForProcess p >>= \case
127127 ExitSuccess -> return ()