@@ -49,6 +49,8 @@ data DeployInitOpts = DeployInitOpts
4949 , _deployInitOpts_enableHttps :: Bool
5050 } deriving Show
5151
52+data DoActivateDeployment = DoActivateDeployment deriving (Eq, Ord, Show)
53+
5254deployInit :: MonadObelisk m => DeployInitOpts -> FilePath -> m ()
5355deployInit deployOpts root = do
5456 let deployDir = _deployInitOpts_outputDir deployOpts
@@ -118,8 +120,8 @@ setupObeliskImpl deployDir = liftIO $ do
118120 createDirectoryIfMissing True implDir
119121 writeFile (implDir </> "default.nix") $ "(import " <> toNixPath (goBackUp </> "src") <> " {}).obelisk"
120122
121−deployPush :: MonadObelisk m => FilePath -> m [String] -> m ()
122−deployPush deployPath getNixBuilders = do
123+deployPush :: MonadObelisk m => FilePath -> Maybe DoActivateDeployment -> m [String] -> m ()
124+deployPush deployPath doActivateDeployment getNixBuilders = do
123125 hosts <- Set.fromList . filter (/= mempty) . lines <$> readDeployConfig deployPath "backend_hosts"
124126 adminEmail <- readDeployConfig deployPath "admin_email"
125127 enableHttps <- read <$> readDeployConfig deployPath "enable_https"
@@ -167,25 +169,28 @@ deployPush deployPath getNixBuilders = do
167169 callProcess'
168170 (Map.fromList [("NIX_SSHOPTS", unwords sshOpts)])
169171 "nix-copy-closure" ["-v", "--to", "--use-substitutes", "root@" <> host, "--gzip", outputPath]
170− withSpinner "Uploading config" $ ifor_ buildOutputByHost $ \host _ -> do
171− callProcessAndLogOutput (Notice, Warning) $
172− proc "rsync"
173− [ "-e ssh " <> unwords sshOpts
174− , "-qarvz"
175− , deployPath </> "config"
176− , "root@" <> host <> ":/var/lib/backend"
177− ]
178− --TODO: Create GC root so we're sure our closure won't go away during this time period
179− withSpinner "Switching to new configuration" $ ifor_ buildOutputByHost $ \host outputPath -> do
180− callProcessAndLogOutput (Notice, Warning) $
181− proc "ssh" $ sshOpts <>
182− [ "root@" <> host
183− , unwords
184− [ "nix-env -p /nix/var/nix/profiles/system --set " <> outputPath
185− , "&&"
186− , "/nix/var/nix/profiles/system/bin/switch-to-configuration switch"
172+ case doActivateDeployment of
173+ Nothing -> putLog Warning "Skipping activation of deployment; server is unchanged"
174+ Just _ -> do
175+ withSpinner "Uploading config" $ ifor_ buildOutputByHost $ \host _ -> do
176+ callProcessAndLogOutput (Notice, Warning) $
177+ proc "rsync"
178+ [ "-e ssh " <> unwords sshOpts
179+ , "-qarvz"
180+ , deployPath </> "config"
181+ , "root@" <> host <> ":/var/lib/backend"
182+ ]
183+ --TODO: Create GC root so we're sure our closure won't go away during this time period
184+ withSpinner "Switching to new configuration" $ ifor_ buildOutputByHost $ \host outputPath -> do
185+ callProcessAndLogOutput (Notice, Warning) $
186+ proc "ssh" $ sshOpts <>
187+ [ "root@" <> host
188+ , unwords
189+ [ "nix-env -p /nix/var/nix/profiles/system --set " <> outputPath
190+ , "&&"
191+ , "/nix/var/nix/profiles/system/bin/switch-to-configuration switch"
192+ ]
187193 ]
188− ]
189194 isClean <- checkGitCleanStatus deployPath True
190195 when (not isClean) $ do
191196 withSpinner "Committing changes to Git" $ do