on master help sign in
Fix ob thunk unpack on macos
commit24cf8642d9adf70271b40190e8b06a0a690ec67c authorAlexandre Esteves <alexandre.fmp.esteves@gmail.com> dateThu 10 May 2018, 17:20 (8 years ago) parentacb1be4
4 files changed+20−7
lib/command/src/Obelisk/Command/Deploy.hs+1−2 lib/command/src/Obelisk/Command/Project.hs+4−3 lib/command/src/Obelisk/Command/Thunk.hs+2−2 lib/command/src/Obelisk/Command/Utils.hs+13
lib/command/src/Obelisk/Command/Deploy.hs+1−2
@@ -5,7 +5,6 @@ import Control.Monad
55import System.Directory
66import System.FilePath
77import System.Posix.Files
8−import System.Process
98
109import Obelisk.Command.Utils
1110import Obelisk.Command.Thunk
@@ -15,7 +14,7 @@ deployInit thunkPtr configDir deployDir sshKeyPath hostnames = do
1514 createDirectoryIfMissing True deployDir
1615 hasConfigDir <- doesDirectoryExist configDir
1716 when hasConfigDir $ do
18− callProcess "cp"
17+ cp
1918 [ "-r"
2019 , "-T"
2120 , configDir
lib/command/src/Obelisk/Command/Project.hs+4−3
@@ -22,13 +22,14 @@ import System.Directory
2222import System.FilePath
2323import System.Posix (FileStatus, UserID, deviceID, fileID, fileMode, fileOwner, getFileStatus, getRealUserID)
2424import System.Posix.Files
25−import System.Process (CreateProcess, callProcess, createProcess_, cwd, proc, waitForProcess)
25+import System.Process (CreateProcess, createProcess_, cwd, proc, waitForProcess)
2626
2727import GitHub.Data.GitData (Branch)
2828import GitHub.Data.Name (Name)
2929
3030import Obelisk.Command.CLI (failWith, putError, withSpinner)
3131import Obelisk.Command.Thunk
32+import Obelisk.Command.Utils (cp)
3233
3334--TODO: Make this module resilient to random exceptions
3435
@@ -69,7 +70,7 @@ initProject source = do
6970 --TODO: We should probably handoff to the impl here
7071 skeleton <- nixBuildAttrWithCache implDir "skeleton" --TODO: I don't think there's actually any reason to cache this
7172 withSpinner "Copying project skeleton ..." (Just "Copied project skeleton.") $ do
72− callProcess "cp" --TODO: Make this package depend on nix-prefetch-url properly
73+ cp --TODO: Make this package depend on nix-prefetch-url properly
7374 [ "-r"
7475 , "--no-preserve=mode"
7576 , "-T"
@@ -180,4 +181,4 @@ projectShell root isPure shellName command = do
180181 void $ waitForProcess ph
181182
182183setCwd :: Maybe FilePath -> CreateProcess -> CreateProcess
183−setCwd fp cp = cp { cwd = fp }
184+setCwd fp cfg = cfg { cwd = fp }
lib/command/src/Obelisk/Command/Thunk.hs+2−2
@@ -471,7 +471,7 @@ unpackThunk thunkDir = readThunk thunkDir >>= \case
471471 --If this directory already exists then something is weird and we should fail
472472 createDirectory obGitDir
473473 withSpinner "Copying thunk ..." Nothing $ do
474− callProcess "cp"
474+ cp
475475 [ "-r"
476476 , "-T"
477477 , thunkDir </> "."
@@ -488,7 +488,7 @@ unpackThunk thunkDir = readThunk thunkDir >>= \case
488488 [ "-r"
489489 , thunkDir
490490 ]
491− callProcess "mv"
491+ callProcessNixShell ["coreutils"] "mv"
492492 [ "-T"
493493 , tmpRepo
494494 , thunkDir
lib/command/src/Obelisk/Command/Utils.hs+13
@@ -1,5 +1,9 @@
1+{-# LANGUAGE OverloadedStrings #-}
12module Obelisk.Command.Utils where
23
4+import qualified Data.List as L
5+import Data.Semigroup ((<>))
6+import qualified Data.Text as T
37import System.Process
48
59-- Check whether the working directory is clean
@@ -17,3 +21,12 @@ initGit dir = do
1721 git ["init"]
1822 git ["add", "."]
1923 git ["commit", "-m", "Initial commit."]
24+
25+callProcessNixShell :: [String] -> FilePath -> [String] -> IO ()
26+callProcessNixShell pkgs cmd args = callProcess "nix-shell" $
27+ "-p" : pkgs <> ["--run", L.intercalate " " $ cmd : map quoteAndEscape args]
28+ where
29+ quoteAndEscape x = T.unpack $ "'" <> T.replace "'" "'\''" (T.pack x) <> "'"
30+
31+cp :: [String] -> IO ()
32+cp = callProcessNixShell ["coreutils"] "cp"