on master help sign in
Run ob run in impure nix shell
commit896e9c6f34ad89c4218ec77a0497b02a37816742 authorLuigy Leon <luigy@outlook.com> dateThu 3 May 2018, 20:54 (8 years ago) parente0302d7
2 files changed+12−5
lib/command/src/Obelisk/Command.hs+1−1 lib/command/src/Obelisk/Command/Project.hs+11−4
lib/command/src/Obelisk/Command.hs+1−1
@@ -140,7 +140,7 @@ data ObInternal
140140inNixShell :: Closure (Process ()) -> IO ()
141141inNixShell m = do
142142 progName <- getProgName
143− _ <- forkIO $ inProjectShell "ghc" $ unwords [progName, "internal", "daemon"]
143+ _ <- forkIO $ inImpureProjectShell "ghc" $ unwords [progName, "internal", "daemon"]
144144 -- NB: Loading a nix-shell takes around 4 seconds
145145 threadDelay $ 1000 * 1000 * 4
146146 backend <- initializeBackend "127.0.0.1" "0" obRemoteTable
lib/command/src/Obelisk/Command/Project.hs+11−4
@@ -6,6 +6,7 @@ module Obelisk.Command.Project
66 , findProjectObeliskCommand
77 , findProjectRoot
88 , inProjectShell
9+ , inImpureProjectShell
910 ) where
1011
1112import Control.Monad
@@ -152,18 +153,24 @@ isWritableOnlyBy s uid = fileOwner s == uid && fileMode s .&. 0o22 == 0
152153
153154-- | Run a command in the given shell for the current project
154155inProjectShell :: String -> String -> IO ()
155−inProjectShell shellName command = do
156+inProjectShell = inProjectShell' ["--pure"]
157+
158+inProjectShell' :: [String] -> String -> String -> IO ()
159+inProjectShell' args shellName command = do
156160 findProjectRoot "." >>= \case
157161 Nothing -> putStrLn "Must be used inside of an Obelisk project"
158162 Just root -> do
159− (_, _, _, ph) <- createProcess_ "runNixShellAttr" $ setCwd (Just root) $ proc "nix-shell"
160− [ "--pure"
161− , "-A"
163+ (_, _, _, ph) <- createProcess_ "runNixShellAttr" $ setCwd (Just root) $ proc "nix-shell" $
164+ args <>
165+ [ "-A"
162166 , "shells." <> shellName
163167 , "--run", command
164168 ]
165169 _ <- waitForProcess ph
166170 return ()
167171
172+inImpureProjectShell :: String -> String -> IO ()
173+inImpureProjectShell = inProjectShell' []
174+
168175setCwd :: Maybe FilePath -> CreateProcess -> CreateProcess
169176setCwd fp cp = cp { cwd = fp }