on master help sign in
ob deploy: Fix for nix < 2.0

Passes down the current environment to deploy callProcess commands

commit1f18bad04df22b328df7049fcfa7b0568f03daba authorLuigy Leon <luigy@outlook.com> dateWed 16 May 2018, 16:24 (8 years ago) parent5af4b64
1 file changed+7−5
lib/command/src/Obelisk/Command/Deploy.hs+7−5
lib/command/src/Obelisk/Command/Deploy.hs+7−5
@@ -17,6 +17,7 @@ import qualified Data.Text as T
1717import qualified Data.Text.IO as T
1818import System.Directory
1919import System.FilePath
20+import System.Posix.Env (getEnvironment)
2021import System.Process (delegate_ctlc, env, proc, readProcess)
2122
2223import Obelisk.App (MonadObelisk)
@@ -79,11 +80,11 @@ deployPush deployPath = do
7980 forM_ result $ \res -> do
8081 let deployAndSwitch outputPath sshAgentEnv = do
8182 withSpinner "Adding ssh key" $ do
82− callProcess' (Just sshAgentEnv) "ssh-add" [deployPath </> "ssh_key"]
83+ callProcess' sshAgentEnv "ssh-add" [deployPath </> "ssh_key"]
8384 withSpinner "Uploading closure" $ do
84− callProcess' (Just sshAgentEnv) "nix-copy-closure" ["-v", "--to", "root@" <> host, "--gzip", outputPath]
85+ callProcess' sshAgentEnv "nix-copy-closure" ["-v", "--to", "root@" <> host, "--gzip", outputPath]
8586 withSpinner "Switching to new configuration" $ do
86− callProcess' (Just sshAgentEnv) "ssh"
87+ callProcess' sshAgentEnv "ssh"
8788 [ "root@" <> host
8889 , unwords
8990 [ "nix-env -p /nix/var/nix/profiles/system --set " <> outputPath
@@ -92,7 +93,7 @@ deployPush deployPath = do
9293 ]
9394 ]
9495 sshAgentEnv <- liftIO sshAgent
95− deployAndSwitch res sshAgentEnv `finally` callProcess' (Just sshAgentEnv) "ssh-agent" ["-k"]
96+ deployAndSwitch res sshAgentEnv `finally` callProcess' sshAgentEnv "ssh-agent" ["-k"]
9697 isClean <- liftIO $ checkGitCleanStatus deployPath
9798 when (not isClean) $ do
9899 withSpinner "Commiting changes to Git" $ do
@@ -102,7 +103,8 @@ deployPush deployPath = do
102103 ["-C", deployPath, "commit", "-m", "New deployment"]
103104 where
104105 callProcess' e cmd args = do
105− let p = (proc cmd args) { delegate_ctlc = True, env = e }
106+ currentEnv <- liftIO getEnvironment
107+ let p = (proc cmd args) { delegate_ctlc = True, env = Just $ e <> currentEnv }
106108 callProcessAndLogOutput (Notice, Notice) p
107109
108110deployUpdate :: MonadObelisk m => FilePath -> m ()