2019-04-08 08:32:24 +08:00
|
|
|
{ pkgs ? import <nixpkgs> {},
|
2019-04-14 08:00:37 +08:00
|
|
|
diskImageSize ? "22G",
|
2019-04-08 08:32:24 +08:00
|
|
|
qemuMem ? "4G",
|
|
|
|
}:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
let
|
|
|
|
windowsIso = fetchurl {
|
|
|
|
url = "https://software-download.microsoft.com/download/sg/17763.107.101029-1455.rs5_release_svc_refresh_CLIENT_LTSC_EVAL_x64FRE_en-us.iso";
|
|
|
|
sha256 = "668fe1af70c2f7416328aee3a0bb066b12dc6bbd2576f40f812b95741e18bc3a";
|
|
|
|
};
|
2019-04-14 05:34:23 +08:00
|
|
|
anaconda = fetchurl {
|
|
|
|
url = "https://repo.anaconda.com/archive/Anaconda3-2019.03-Windows-x86_64.exe";
|
|
|
|
sha256 = "1f9icm5rwab6l1f23a70dw0qixzrl62wbglimip82h4zhxlh3jfj";
|
2019-04-08 08:32:24 +08:00
|
|
|
};
|
|
|
|
|
2019-04-15 07:12:48 +08:00
|
|
|
escape = builtins.replaceStrings [ "\\" ] [ "\\\\" ];
|
2019-04-14 05:33:31 +08:00
|
|
|
qemu = import ./qemu.nix {
|
|
|
|
inherit pkgs qemuMem;
|
|
|
|
diskImage = "c.img";
|
|
|
|
};
|
|
|
|
# Double-escape because we produce a script from a shell heredoc
|
2019-04-15 07:12:48 +08:00
|
|
|
ssh = cmd: qemu.ssh (escape cmd);
|
2019-04-14 05:33:31 +08:00
|
|
|
scp = qemu.scp;
|
2019-04-08 08:32:24 +08:00
|
|
|
|
2019-04-14 05:34:23 +08:00
|
|
|
sshCondaEnv = cmd: ssh "anaconda\\scripts\\activate && ${cmd}";
|
2019-04-12 00:15:34 +08:00
|
|
|
condaEnv = "artiq-env";
|
2019-04-14 02:32:06 +08:00
|
|
|
condaDepSpecs =
|
2019-04-14 02:20:28 +08:00
|
|
|
builtins.concatStringsSep " "
|
2019-04-14 02:32:06 +08:00
|
|
|
(map (s: "\"${s}\"")
|
|
|
|
(import ../conda-artiq-deps.nix));
|
2019-04-14 05:32:09 +08:00
|
|
|
|
|
|
|
instructions =
|
|
|
|
builtins.toFile "install.txt"
|
|
|
|
(builtins.readFile ./install.txt);
|
2019-04-08 08:32:24 +08:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "windows-installer";
|
|
|
|
src = windowsIso;
|
|
|
|
setSourceRoot = "sourceRoot=`pwd`";
|
|
|
|
unpackCmd = ''
|
|
|
|
ln -s $curSrc windows.iso
|
|
|
|
'';
|
2019-04-18 15:08:17 +08:00
|
|
|
propagatedBuildInputs = qemu.inputs;
|
2019-04-08 08:32:24 +08:00
|
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/data
|
|
|
|
ln -s $(readlink windows.iso) $out/data/windows.iso
|
2019-04-18 22:42:19 +08:00
|
|
|
cat > $out/bin/windows-installer.sh << EOF
|
2019-04-08 08:32:24 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e -m
|
|
|
|
|
2019-04-18 22:42:19 +08:00
|
|
|
${qemu.qemu-img} create -f qcow2 c.img ${diskImageSize}
|
2019-04-18 23:34:09 +08:00
|
|
|
${qemu.runQemu false [] [
|
2019-04-18 22:42:19 +08:00
|
|
|
"-boot" "order=d"
|
|
|
|
"-drive" "file=c.img,index=0,media=disk,cache=unsafe"
|
|
|
|
"-drive" "file=$out/data/windows.iso,index=1,media=cdrom,cache=unsafe"
|
|
|
|
]} &
|
2019-04-14 05:32:09 +08:00
|
|
|
cat ${instructions}
|
2019-04-18 22:42:19 +08:00
|
|
|
wait
|
|
|
|
EOF
|
2019-04-08 08:32:24 +08:00
|
|
|
|
2019-04-18 22:42:19 +08:00
|
|
|
cat > $out/bin/anaconda-installer.sh << EOF
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e -m
|
2019-04-14 05:34:23 +08:00
|
|
|
|
2019-04-18 23:34:09 +08:00
|
|
|
${qemu.runQemu false [] [
|
2019-04-18 22:42:19 +08:00
|
|
|
"-boot" "order=c"
|
|
|
|
"-drive" "file=c.img,index=0,media=disk"
|
|
|
|
]} &
|
|
|
|
sleep 10
|
2019-04-08 08:32:24 +08:00
|
|
|
${ssh "ver"}
|
|
|
|
|
2019-04-14 05:34:23 +08:00
|
|
|
${scp anaconda "Anaconda.exe"}
|
|
|
|
${ssh "start /wait \"\" Anaconda.exe /S /D=%cd%\\anaconda"}
|
2019-04-11 22:22:17 +08:00
|
|
|
|
2019-04-14 05:34:23 +08:00
|
|
|
${sshCondaEnv "conda config --add channels conda-forge"}
|
|
|
|
${sshCondaEnv "conda config --add channels m-labs"}
|
|
|
|
( ${sshCondaEnv "conda update -y conda"} ) || true
|
|
|
|
${sshCondaEnv "conda update -y --all"}
|
|
|
|
${sshCondaEnv "conda create -y -n ${condaEnv}"}
|
|
|
|
${sshCondaEnv "conda install -y -n ${condaEnv} ${condaDepSpecs}"}
|
2019-04-08 08:32:24 +08:00
|
|
|
${ssh "shutdown /p /f"}
|
|
|
|
|
|
|
|
echo "Waiting for qemu exit"
|
|
|
|
wait
|
|
|
|
EOF
|
2019-04-18 22:42:19 +08:00
|
|
|
chmod a+x $out/bin/*.sh
|
2019-04-08 08:32:24 +08:00
|
|
|
'';
|
|
|
|
}
|