3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/build-support/vm/windows/install/default.nix
aszlig 623f1940c0
vm/windows: Make list of dependencies explicit.
So far, the VMs have always been using the native architecture, because
it was reimporting <nixpkgs> several times. Now, we propagate a list of
packages down to all sub-imports, which not only makes clearer which
dependencies a part actually has, but also will make it easier in case
we want to refactor those parts to use callPackage.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-02-26 05:43:34 +01:00

75 lines
1.6 KiB
Nix

{ stdenv, runCommand, openssh, qemu, controller, mkCygwinImage
, writeText, dosfstools, mtools
}:
{ isoFile
, productKey
}:
let
bootstrapAfterLogin = runCommand "bootstrap.sh" {} ''
cat > "$out" <<EOF
mkdir -p ~/.ssh
cat > ~/.ssh/authorized_keys <<PUBKEY
$(cat "${cygwinSshKey}/key.pub")
PUBKEY
ssh-host-config -y -c 'binmode ntsec' -w dummy
cygrunsrv -S sshd
shutdown -s 5
EOF
'';
cygwinSshKey = stdenv.mkDerivation {
name = "snakeoil-ssh-cygwin";
buildCommand = ''
ensureDir "$out"
${openssh}/bin/ssh-keygen -t ecdsa -f "$out/key" -N ""
'';
};
sshKey = "${cygwinSshKey}/key";
packages = [ "openssh" "shutdown" ];
floppyCreator = import ./unattended-image.nix {
inherit stdenv writeText dosfstools mtools;
};
instfloppy = floppyCreator {
cygwinPackages = packages;
inherit productKey;
};
cygiso = mkCygwinImage {
inherit packages;
extraContents = stdenv.lib.singleton {
source = bootstrapAfterLogin;
target = "bootstrap.sh";
};
};
installController = controller {
inherit sshKey;
installMode = true;
qemuArgs = [
"-boot order=c,once=d"
"-drive file=${instfloppy},readonly,index=0,if=floppy"
"-drive file=winvm.img,index=0,media=disk"
"-drive file=${isoFile},index=1,media=cdrom"
"-drive file=${cygiso}/iso/cd.iso,index=2,media=cdrom"
];
};
in stdenv.mkDerivation {
name = "cygwin-base-vm";
buildCommand = ''
${qemu}/bin/qemu-img create -f qcow2 winvm.img 2G
${installController}
ensureDir "$out"
cp winvm.img "$out/disk.img"
'';
passthru = {
inherit sshKey;
};
}