Skip to content

Commit 0d98cf0

Browse files
committed
Prevent vmcli start from messing up Ctrl+C
1 parent 3c08696 commit 0d98cf0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

spec/IntegrationSpec.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module IntegrationSpec where
66
import Context
77
import Control.Concurrent (readMVar)
88
import Control.Concurrent.MVar (newEmptyMVar, putMVar)
9+
import Cradle qualified
910
import Data.ByteString qualified as B
1011
import Data.Maybe (fromMaybe)
1112
import Data.String.Conversions
@@ -106,6 +107,14 @@ spec = around_ inTempDirectory $ do
106107
files <- listDirectory "."
107108
files `shouldBe` []
108109

110+
it "`vmcli start` doesn't mess up the terminal" $ do
111+
withContext $ \ctx -> do
112+
writeStandardFlake ctx Nothing
113+
Cradle.StdoutRaw before <- Cradle.run $ Cradle.cmd "stty" & Cradle.addArgs ["-a" :: Text]
114+
_ <- assertSuccess $ test ctx ["start", "server"]
115+
Cradle.StdoutRaw after <- Cradle.run $ Cradle.cmd "stty" & Cradle.addArgs ["-a" :: Text]
116+
after `shouldBe` before
117+
109118
it "starts vms with arbitrary hostnames" $ do
110119
withContext $ \ctx -> do
111120
writeStandardFlake ctx (Just "{ lib, ...} : { networking.hostName = lib.mkForce \"other-hostname\"; }")

src/NixVms.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ runVm ctx verbosity vmName vmExecutable = do
143143
let mkProc stdout stdin =
144144
(System.Process.proc vmExecutable [])
145145
{ env = Just $ Map.toList $ Map.insert "NIX_DISK_IMAGE" nixDiskImage parentEnvironment,
146+
std_in = CreatePipe,
146147
std_out = stdout,
147148
std_err = stdin
148149
}

0 commit comments

Comments
 (0)