@@ -28,10 +28,32 @@ import Obelisk.Command.Nix (withNixRemoteCheck)
2828getNixBuildersArg :: MonadObelisk m => m String
2929getNixBuildersArg = do
3030 stateDir <- liftIO getDockerBuilderStateDir
31+ let sshIdFile = stateDir </> sshKeyFileName
32+ checkForNixDarwin sshIdFile
3133 exists <- containerExists stateDir
3234 if exists then startContainer else setupNixDocker stateDir
3335 pure $ nixBuildersArgString stateDir
3436
37+checkForNixDarwin :: MonadObelisk m => String -> m ()
38+checkForNixDarwin sshIdFile = do
39+ (exitCode, _, _) <- readCreateProcessWithExitCode $ proc "which" ["darwin-rebuild"]
40+ unless (exitCode == ExitSuccess) $ failWith $ T.intercalate "\n"
41+ [ "Deployments from macOS require nix-darwin to be installed."
42+ , "Follow the installation instructions here: https://github.com/LnL7/nix-darwin"
43+ , "You'll also need to add the following to your 'configuration.nix' and run 'darwin-rebuild switch':"
44+ , ""
45+ , T.intercalate "\n" $ map (" " <>)
46+ [ "nix.buildMachines = [{"
47+ , " hostName = " <> T.pack (show (containerName :: String)) <> ";"
48+ , " sshUser = \"root\";"
49+ , " sshKey = " <> T.pack (show sshIdFile) <> ";"
50+ , " sshPort = " <> T.pack (show containerSshPort) <> ";"
51+ , " systems = [ \"x86_64-linux\" ];"
52+ , " maxJobs = 2;"
53+ , "}];"
54+ ]
55+ ]
56+
3557-- | String to pass to nix's `--builders` arguments to enable the VM builder.
3658nixBuildersArgString :: FilePath -> String
3759nixBuildersArgString stateDir = unwords [containerName, "x86_64-linux", stateDir </> sshKeyFileName, "1", "1", "kvm"]