Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Astro | e9447929b6 |
|
@ -36,6 +36,7 @@ rec {
|
||||||
# Wait for VM to be accessible
|
# Wait for VM to be accessible
|
||||||
sleep 20
|
sleep 20
|
||||||
echo "Waiting for SSH..."
|
echo "Waiting for SSH..."
|
||||||
|
TEXT=""
|
||||||
while true; do
|
while true; do
|
||||||
if test "$timeout" -eq 0; then
|
if test "$timeout" -eq 0; then
|
||||||
echo "SSH connection timed out"
|
echo "SSH connection timed out"
|
||||||
|
@ -47,6 +48,13 @@ rec {
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
${pkgs.vncdo}/bin/vncdo rcapture cap.png 0 0 1024 768
|
||||||
|
${pkgs.imagemagick}/bin/mogrify -density 70x70 -units PixelsPerInch cap.png
|
||||||
|
NEW_TEXT="$(${pkgs.tesseract}/bin/tesseract cap.png stdout)"
|
||||||
|
if [ "$TEXT" != "$NEW_TEXT" ]; then
|
||||||
|
echo "$NEW_TEXT"
|
||||||
|
TEXT="$NEW_TEXT"
|
||||||
|
fi
|
||||||
echo "Retrying in 1 second, timing out in $timeout seconds"
|
echo "Retrying in 1 second, timing out in $timeout seconds"
|
||||||
|
|
||||||
((timeout=$timeout-1))
|
((timeout=$timeout-1))
|
||||||
|
@ -85,7 +93,7 @@ rec {
|
||||||
(map ({ listenAddr, targetAddr, port }:
|
(map ({ listenAddr, targetAddr, port }:
|
||||||
",guestfwd=tcp:${listenAddr}:${toString port}-cmd:${pkgs.socat}/bin/socat\\ -\\ tcp:${targetAddr}:${toString port}"
|
",guestfwd=tcp:${listenAddr}:${toString port}-cmd:${pkgs.socat}/bin/socat\\ -\\ tcp:${targetAddr}:${toString port}"
|
||||||
) forwardedPorts);
|
) forwardedPorts);
|
||||||
qemuParams = mkQemuFlags (pkgs.lib.optional (!display) "-display none" ++ pkgs.lib.optional (!fakeRtc) "-rtc base=localtime" ++ [
|
qemuParams = mkQemuFlags (pkgs.lib.optional (!display) "-vnc 127.0.0.1:0" ++ pkgs.lib.optional (!fakeRtc) "-rtc base=localtime" ++ [
|
||||||
"-drive"
|
"-drive"
|
||||||
"file=${image},index=0,media=disk,cache=unsafe"
|
"file=${image},index=0,media=disk,cache=unsafe"
|
||||||
"-snapshot"
|
"-snapshot"
|
||||||
|
|
18
wfvm/win.nix
18
wfvm/win.nix
|
@ -88,7 +88,7 @@ let
|
||||||
|
|
||||||
installScript = pkgs.writeScript "windows-install-script" (
|
installScript = pkgs.writeScript "windows-install-script" (
|
||||||
let
|
let
|
||||||
qemuParams = utils.mkQemuFlags (lib.optional (!impureMode) "-display none" ++ [
|
qemuParams = utils.mkQemuFlags (lib.optional (!impureMode) "-vnc 127.0.0.1:0" ++ [
|
||||||
# "CD" drive with bootstrap pkgs
|
# "CD" drive with bootstrap pkgs
|
||||||
"-drive"
|
"-drive"
|
||||||
"id=virtio-win,file=${bootstrapPkgs},if=none,format=raw,readonly=on"
|
"id=virtio-win,file=${bootstrapPkgs},if=none,format=raw,readonly=on"
|
||||||
|
@ -108,7 +108,7 @@ let
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
#!${pkgs.runtimeShell}
|
#!${pkgs.runtimeShell}
|
||||||
set -euxo pipefail
|
set -euo pipefail
|
||||||
export PATH=${lib.makeBinPath [ p7zip utils.qemu guestfs-tools pkgs.wimlib ]}:$PATH
|
export PATH=${lib.makeBinPath [ p7zip utils.qemu guestfs-tools pkgs.wimlib ]}:$PATH
|
||||||
|
|
||||||
# Create a bootable "USB" image
|
# Create a bootable "USB" image
|
||||||
|
@ -134,7 +134,19 @@ let
|
||||||
|
|
||||||
# Qemu requires files to be rw
|
# Qemu requires files to be rw
|
||||||
qemu-img create -f qcow2 c.img ${diskImageSize}
|
qemu-img create -f qcow2 c.img ${diskImageSize}
|
||||||
qemu-system-x86_64 ${lib.concatStringsSep " " qemuParams}
|
qemu-system-x86_64 ${lib.concatStringsSep " " qemuParams} &
|
||||||
|
|
||||||
|
TEXT=""
|
||||||
|
while [ -n "$(jobs)" ]; do
|
||||||
|
${pkgs.vncdo}/bin/vncdo rcapture cap.png 0 0 1024 768
|
||||||
|
${pkgs.imagemagick}/bin/mogrify -density 70x70 -units PixelsPerInch cap.png
|
||||||
|
NEW_TEXT="$(${pkgs.tesseract5}/bin/tesseract cap.png stdout)"
|
||||||
|
if [ "$TEXT" != "$NEW_TEXT" ]; then
|
||||||
|
echo "$NEW_TEXT"
|
||||||
|
TEXT="$NEW_TEXT"
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue