1
0
Fork 0

wfvm: remove duplicated SSH code

This commit is contained in:
Sebastien Bourdeauducq 2020-06-13 18:52:31 +08:00
parent 75c44b0369
commit 088403cf6f
1 changed files with 3 additions and 25 deletions

View File

@ -1,9 +1,4 @@
{ pkgs
, qemuMem
, sshUser ? "user"
, sshPassword ? "user"
,
}:
{ pkgs, qemuMem }:
with pkgs;
@ -39,25 +34,8 @@ let
in
"${qemu_kvm}/bin/qemu-system-x86_64 ${argStr}";
# Pass empty config file to prevent ssh from failing to create ~/.ssh
sshOpts = "-F /dev/null -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=\$TMP/known_hosts";
sshWithQuotes = quotes: cmd: ''
echo ssh windows ${quotes}${cmd}${quotes}
${sshpass}/bin/sshpass -p${sshPassword} -- \
${openssh}/bin/ssh -np 2022 ${sshOpts} \
${sshUser}@localhost \
${quotes}${cmd}${quotes}
'';
ssh = sshWithQuotes "'";
scp = src: target: ''
echo "Copy ${src} to ${target}"
${sshpass}/bin/sshpass -p${sshPassword} -- \
${openssh}/bin/scp -P 2022 ${sshOpts} \
"${src}" "${sshUser}@localhost:${target}"
'';
in
{
inherit qemu-img runQemu ssh sshWithQuotes scp;
inputs = [ qemu_kvm openssh sshpass ];
inherit qemu-img runQemu;
inputs = [ qemu_kvm ];
}