@@ -88,37 +88,32 @@ deployPush deployPath getNixBuilders = do
8888 route <- readDeployConfig deployPath $ "config" </> "common" </> "route"
8989 routeHost <- getHostFromRoute enableHttps route
9090 let srcPath = deployPath </> "src"
91− build = do
92− builders <- getNixBuilders
93− buildOutput <- nixBuild $ def
94− { _nixBuildConfig_target = Target
95− { _target_path = srcPath
96− , _target_attr = Just "server.system"
97− }
98− , _nixBuildConfig_outLink = OutLink_None
99− , _nixBuildConfig_args =
100− [ strArg "hostName" host
101− , strArg "adminEmail" adminEmail
102− , strArg "routeHost" routeHost
103− , boolArg "enableHttps" enableHttps
104− , rawArg "config" $ deployPath </> "config"
105− ]
106− , _nixBuildConfig_builders = builders
107− }
108− return $ listToMaybe $ lines buildOutput
109− result <- readThunk srcPath >>= \case
110− Right (ThunkData_Packed _) ->
111− build
91+ thunkPtr <- readThunk srcPath >>= \case
92+ Right (ThunkData_Packed ptr) -> return ptr
11293 Right (ThunkData_Checkout _) -> do
11394 checkGitCleanStatus srcPath True >>= \case
114− True -> do
115− result <- build
116− packThunk srcPath
117− return result
118− False -> do
119− _ <- failWith $ T.pack $ "ob deploy push: ensure " <> srcPath <> " has no pending changes and latest is pushed upstream."
120− return Nothing
121− _ -> return Nothing
95+ True -> packThunk srcPath
96+ False -> failWith $ T.pack $ "ob deploy push: ensure " <> srcPath <> " has no pending changes and latest is pushed upstream."
97+ Left err -> failWith $ "ob deploy push: couldn't read src thunk: " <> T.pack (show err)
98+ let version = show . _thunkRev_commit $ _thunkPtr_rev thunkPtr
99+ builders <- getNixBuilders
100+ buildOutput <- nixBuild $ def
101+ { _nixBuildConfig_target = Target
102+ { _target_path = srcPath
103+ , _target_attr = Just "server.system"
104+ }
105+ , _nixBuildConfig_outLink = OutLink_None
106+ , _nixBuildConfig_args =
107+ [ strArg "hostName" host
108+ , strArg "adminEmail" adminEmail
109+ , strArg "routeHost" routeHost
110+ , strArg "version" version
111+ , boolArg "enableHttps" enableHttps
112+ , rawArg "config" $ deployPath </> "config"
113+ ]
114+ , _nixBuildConfig_builders = builders
115+ }
116+ let result = listToMaybe $ lines buildOutput
122117 forM_ result $ \res -> do
123118 let knownHostsPath = deployPath </> "backend_known_hosts"
124119 sshOpts = sshArgs knownHostsPath (deployPath </> "ssh_key") False