wfvm: remove dead code

This commit is contained in:
Sebastien Bourdeauducq 2020-06-14 16:50:25 +08:00
parent 768d38db46
commit 0a2e7dae93
6 changed files with 3 additions and 263 deletions

View File

@ -2,5 +2,5 @@
{
makeWindowsImage = attrs: import ./win.nix ({ inherit pkgs; } // attrs);
pkgs = import ./pkgs.nix { inherit pkgs; };
layers = (import ./layers { inherit pkgs; });
}

View File

@ -2,7 +2,6 @@
let
win = (import ./default.nix { inherit pkgs; });
layers = (import ./layers { inherit pkgs; });
in
win.makeWindowsImage {
@ -40,7 +39,7 @@ win.makeWindowsImage {
defaultUser = "artiq";
# Imperative installation commands, to be installed incrementally
installCommands = [ layers.anaconda3 layers.msys2 layers.msys2-packages ];
installCommands = with win.layers; [ anaconda3 msys2 msys2-packages ];
# services = {
# # Enable remote management
@ -59,22 +58,4 @@ win.makeWindowsImage {
# userLocale = "en-US";
# systemLocale = "en-US";
# packages = [
# (
# win.pkgs.makeMSIPkg {
# # Note: File not in repository, it's meant as an example to subsitute
# name = "notepadplusplus";
# msi = ./Notepad++7.7.msi;
# # Custom cert
# # cert = ./notepad++-cert.cer
# }
# )
# (
# win.pkgs.makeCrossPkg {
# name = "hello";
# pkg = pkgs.pkgsCross.mingwW64.hello;
# }
# )
# ];
}

View File

@ -1,32 +0,0 @@
# This runs `run-test.nix` with `nix-build`
{ pkgs ? import <nixpkgs> {}
, artiqpkgs ? import ../. { inherit pkgs; }
, diskImage ? (import ./build.nix { inherit pkgs; })
, qemuMem ? "2G"
, testTimeout ? 180
}:
with pkgs;
let
windowsRunner = overrides:
import ./run-test.nix (
{
inherit pkgs diskImage qemuMem testTimeout;
sipycoPkg = artiqpkgs.conda-sipyco;
artiqPkg = artiqpkgs.conda-artiq;
} // overrides
);
in
stdenv.mkDerivation {
name = "windows-test";
phases = [ "installPhase" "checkPhase" ];
installPhase = "touch $out";
doCheck = true;
checkPhase = ''
${windowsRunner { testCommand = "set ARTIQ_ROOT=%cd%\\anaconda\\envs\\artiq-env\\Lib\\site-packages\\artiq\\examples\\kc705_nist_clock&&python -m unittest discover -v artiq.test"; }}/bin/run.sh
'';
}

View File

@ -1,110 +0,0 @@
{ pkgs ? import <nixpkgs> {}
, lib ? pkgs.lib
}:
/*
This file creates a simple custom simple bundle format containing
a powershell script plus any required executables and assets.
These are assets that are only handled in the pure build steps.
Impure packages are installed in _another_ step that runs impurely outside of
the Nix sandbox.
*/
let
makeBundle =
{ name
, bundle
}: pkgs.runCommandNoCC "${name}-archive.tar" {} ''
cp -r -L ${bundle} build
tar -cpf $out -C build .
'';
in
rec {
/*
Make a custom install bundle
*/
makePkg =
{ name
, src
, installScript
}: let
installScript_ = pkgs.writeText "${name}-install-script" installScript;
bundle = pkgs.runCommandNoCC "${name}-bundle" {} ''
mkdir build
ln -s ${src} build/"$(stripHash "${src}")"
ln -s ${installScript_} build/install.ps1
mv build $out
'';
in
makeBundle {
inherit name bundle;
};
/*
Make an install bundle from a .msi
*/
makeMSIPkg =
{ name
, msi
, cert ? null
, ADDLOCAL ? []
, preInstall ? ""
, postInstall ? ""
}: let
installScript = pkgs.writeText "${name}-install-script" ''
${preInstall}
${if cert != null then "certutil.exe -f -addstore TrustedPublisher cert.cer" else ""}
msiexec.exe /i .\${name}.msi ${if ADDLOCAL != [] then "ADDLOCAL=" else ""}${lib.concatStringsSep "," ADDLOCAL}
${postInstall}
'';
bundle = pkgs.runCommandNoCC "${name}-bundle" {} ''
mkdir build
ln -s ${msi} build/${name}.msi
${if cert != null then "ln -s ${cert} build/cert.cer" else ""}
ln -s ${installScript} build/install.ps1
mv build $out
'';
in
makeBundle {
inherit name bundle;
};
/*
Nix cross-built packages
*/
makeCrossPkg =
{ name
, pkg
, destination ? ''C:\Program Files\${name}\''
, preInstall ? ""
, postInstall ? ""
}: let
installScript = pkgs.writeText "${name}-install-script" ''
${preInstall}
Copy-Item pkg -Destination "${destination}"
${postInstall}
'';
bundle = pkgs.runCommandNoCC "${name}-bundle" {} ''
mkdir -p build/pkg
ln -s ${pkg} build/pkg
ln -s ${installScript} build/install.ps1
mv build $out
'';
in
makeBundle {
inherit name bundle;
};
}

View File

@ -1,91 +0,0 @@
{ pkgs
, sipycoPkg
, artiqPkg
, diskImage ? (import ./build.nix { inherit pkgs; })
, qemuMem ? "2G"
, testTimeout ? 600
, testCommand ? "python -m unittest discover -v sipyco.test && python -m unittest discover -v artiq.test"
,
}:
with pkgs;
let
escape = builtins.replaceStrings [ "\\" ] [ "\\\\" ];
qemu = import ./qemu.nix {
inherit pkgs qemuMem;
};
# Double-escape because we produce a script from a shell heredoc
ssh = cmd: qemu.ssh (escape cmd);
sshUnquoted = qemu.sshWithQuotes "\"";
scp = qemu.scp;
condaEnv = "artiq-env";
tcpPorts = [ 1380 1381 1382 1383 ];
forwardedPorts =
map (
port: {
listenAddr = "192.168.1.50";
targetAddr = "192.168.1.50";
inherit port;
}
) tcpPorts;
in
stdenv.mkDerivation {
name = "windows-test-runner";
# Dummy sources
src = pkgs.runCommandNoCC "dummy" {} "touch $out";
dontUnpack = true;
propagatedBuildInputs = qemu.inputs;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
cat > $out/bin/run.sh << EOF
#!/usr/bin/env bash
set -e -m
cp ${diskImage} c.img
${qemu.runQemu true forwardedPorts [
"-boot"
"order=c"
"-snapshot"
"-drive"
"file=c.img,index=0,media=disk,cache=unsafe"
"-display"
"none"
]} &
echo "Wait for Windows to boot"
sleep 30
${ssh "ver"}
i=0
for pkg in ${sipycoPkg}/noarch/sipyco*.tar.bz2 ${artiqPkg}/noarch/artiq*.tar.bz2 ; do
${scp "\\$pkg" "to_install\\$i.tar.bz2"}
${sshUnquoted "anaconda\\scripts\\activate ${condaEnv} && conda install to_install\\$i.tar.bz2"}
((i=i+1))
done
# Schedule a timed shutdown against hanging test runs
${ssh "shutdown -s -t ${toString testTimeout}"}
FAIL=n
( ${ssh "anaconda\\scripts\\activate ${condaEnv} && ${testCommand}"} ) || FAIL=y
# Abort timeouted shutdown
${ssh "shutdown -a"}
# Power off immediately
${ssh "shutdown -p -f"}
wait
if [ "\$FAIL" = "y" ]; then
exit 1
else
exit 0
fi
EOF
chmod a+x $out/bin/run.sh
'';
}

View File

@ -4,7 +4,6 @@
, qemuMem ? "4G"
, windowsImage ? null
, autoUnattendParams ? {}
, packages ? []
, impureMode ? false
, baseRtc ? "2020-04-20T14:21:42"
, installCommands ? []
@ -52,14 +51,9 @@ let
bundleInstaller = pkgs.callPackage ./bundle {};
# Packages required to drive installation of other packages
bootstrapPkgs = let
winPkgs = import ./pkgs.nix { inherit pkgs; };
in
bootstrapPkgs =
runQemuCommand "bootstrap-win-pkgs.img" ''
mkdir pkgs
mkdir pkgs/bootstrap
mkdir pkgs/user
mkdir pkgs/fod
cp ${bundleInstaller} pkgs/"$(stripHash "${bundleInstaller}")"
@ -71,8 +65,6 @@ let
# SSH setup script goes here because windows XML parser sucks
cp ${autounattend.setupScript} pkgs/ssh-setup.ps1
${lib.concatStringsSep "\n" (builtins.map (x: ''cp ${x} pkgs/bootstrap/"$(stripHash "${x}")"'') packages)}
virt-make-fs --partition --type=fat pkgs/ $out
'';