diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-08-04 10:43:07 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-08-04 10:43:07 +0000 |
commit | 62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch) | |
tree | c2630f69080637987b68acb1ee8676d2681fe304 /pkgs/build-support/vm | |
parent | d9c82ed3044c72cecf01c6ea042489d30914577c (diff) | |
parent | e24069138dfec3ef94f211f1da005bb5395adc11 (diff) | |
download | nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2 nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip |
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/build-support/vm')
-rw-r--r-- | pkgs/build-support/vm/deb/deb-closure.pl | 2 | ||||
-rw-r--r-- | pkgs/build-support/vm/default.nix | 180 | ||||
-rw-r--r-- | pkgs/build-support/vm/windows/bootstrap.nix | 83 | ||||
-rw-r--r-- | pkgs/build-support/vm/windows/controller/default.nix | 263 | ||||
-rw-r--r-- | pkgs/build-support/vm/windows/cygwin-iso/default.nix | 56 | ||||
-rw-r--r-- | pkgs/build-support/vm/windows/cygwin-iso/mkclosure.py | 78 | ||||
-rw-r--r-- | pkgs/build-support/vm/windows/default.nix | 44 | ||||
-rw-r--r-- | pkgs/build-support/vm/windows/install/default.nix | 74 | ||||
-rw-r--r-- | pkgs/build-support/vm/windows/install/unattended-image.nix | 123 |
9 files changed, 71 insertions, 832 deletions
diff --git a/pkgs/build-support/vm/deb/deb-closure.pl b/pkgs/build-support/vm/deb/deb-closure.pl index bed397d6f07..fe23025df1d 100644 --- a/pkgs/build-support/vm/deb/deb-closure.pl +++ b/pkgs/build-support/vm/deb/deb-closure.pl @@ -50,7 +50,7 @@ sub getDeps { # virtual dependencies. my %provides; -foreach my $cdata (values %packages) { +foreach my $cdata (sort {$a->{Package} cmp $b->{Package}} (values %packages)) { if (defined $cdata->{Provides}) { my @provides = getDeps(Dpkg::Deps::deps_parse($cdata->{Provides})); foreach my $name (@provides) { diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 909cdc6da04..cfc19c03cfd 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -1,6 +1,7 @@ -{ pkgs +{ lib +, pkgs , kernel ? pkgs.linux -, img ? pkgs.stdenv.hostPlatform.platform.kernelTarget +, img ? pkgs.stdenv.hostPlatform.linux-kernel.target , storeDir ? builtins.storeDir , rootModules ? [ "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_balloon" "virtio_rng" "ext4" "unix" "9p" "9pnet_virtio" "crc32c_generic" ] @@ -151,7 +152,7 @@ rec { # Set the system time from the hardware clock. Works around an # apparent KVM > 1.5.2 bug. - ${pkgs.utillinux}/bin/hwclock -s + ${pkgs.util-linux}/bin/hwclock -s export NIX_STORE=${storeDir} export NIX_BUILD_TOP=/tmp @@ -270,7 +271,7 @@ rec { defaultCreateRootFS = '' mkdir /mnt ${e2fsprogs}/bin/mkfs.ext4 /dev/${hd} - ${utillinux}/bin/mount -t ext4 /dev/${hd} /mnt + ${util-linux}/bin/mount -t ext4 /dev/${hd} /mnt if test -e /mnt/.debug; then exec ${bash}/bin/sh @@ -317,7 +318,7 @@ rec { with pkgs; runInLinuxVM ( stdenv.mkDerivation { name = "extract-file"; - buildInputs = [ utillinux ]; + buildInputs = [ util-linux ]; buildCommand = '' ln -s ${kernel}/lib /lib ${kmod}/bin/modprobe loop @@ -342,7 +343,7 @@ rec { with pkgs; runInLinuxVM ( stdenv.mkDerivation { name = "extract-file-mtd"; - buildInputs = [ utillinux mtdutils ]; + buildInputs = [ util-linux mtdutils ]; buildCommand = '' ln -s ${kernel}/lib /lib ${kmod}/bin/modprobe mtd @@ -417,7 +418,7 @@ rec { # Make the Nix store available in /mnt, because that's where the RPMs live. mkdir -p /mnt${storeDir} - ${utillinux}/bin/mount -o bind ${storeDir} /mnt${storeDir} + ${util-linux}/bin/mount -o bind ${storeDir} /mnt${storeDir} # Newer distributions like Fedora 18 require /lib etc. to be # symlinked to /usr. @@ -427,7 +428,7 @@ rec { ln -s /usr/sbin /mnt/sbin ln -s /usr/lib /mnt/lib ln -s /usr/lib64 /mnt/lib64 - ${utillinux}/bin/mount -t proc none /mnt/proc + ${util-linux}/bin/mount -t proc none /mnt/proc ''} echo "unpacking RPMs..." @@ -445,7 +446,7 @@ rec { PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \ rpm --initdb - ${utillinux}/bin/mount -o bind /tmp /mnt/tmp + ${util-linux}/bin/mount -o bind /tmp /mnt/tmp echo "installing RPMs..." PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \ @@ -456,8 +457,8 @@ rec { rm /mnt/.debug - ${utillinux}/bin/umount /mnt${storeDir} /mnt/tmp ${lib.optionalString unifiedSystemDir "/mnt/proc"} - ${utillinux}/bin/umount /mnt + ${util-linux}/bin/umount /mnt${storeDir} /mnt/tmp ${lib.optionalString unifiedSystemDir "/mnt/proc"} + ${util-linux}/bin/umount /mnt ''; passthru = { inherit fullName; }; @@ -572,7 +573,7 @@ rec { buildCommand = '' ${createRootFS} - PATH=$PATH:${stdenv.lib.makeBinPath [ dpkg dpkg glibc lzma ]} + PATH=$PATH:${lib.makeBinPath [ dpkg dpkg glibc xz ]} # Unpack the .debs. We do this to prevent pre-install scripts # (which have lots of circular dependencies) from barfing. @@ -587,9 +588,9 @@ rec { # Make the Nix store available in /mnt, because that's where the .debs live. mkdir -p /mnt/inst${storeDir} - ${utillinux}/bin/mount -o bind ${storeDir} /mnt/inst${storeDir} - ${utillinux}/bin/mount -o bind /proc /mnt/proc - ${utillinux}/bin/mount -o bind /dev /mnt/dev + ${util-linux}/bin/mount -o bind ${storeDir} /mnt/inst${storeDir} + ${util-linux}/bin/mount -o bind /proc /mnt/proc + ${util-linux}/bin/mount -o bind /dev /mnt/dev # Misc. files/directories assumed by various packages. echo "initialising Dpkg DB..." @@ -635,10 +636,10 @@ rec { rm /mnt/.debug - ${utillinux}/bin/umount /mnt/inst${storeDir} - ${utillinux}/bin/umount /mnt/proc - ${utillinux}/bin/umount /mnt/dev - ${utillinux}/bin/umount /mnt + ${util-linux}/bin/umount /mnt/inst${storeDir} + ${util-linux}/bin/umount /mnt/proc + ${util-linux}/bin/umount /mnt/dev + ${util-linux}/bin/umount /mnt ''; passthru = { inherit fullName; }; @@ -821,45 +822,6 @@ rec { /* The set of supported Dpkg-based distributions. */ debDistros = { - - # Interestingly, the SHA-256 hashes provided by Ubuntu in - # http://nl.archive.ubuntu.com/ubuntu/dists/{gutsy,hardy}/Release are - # wrong, but the SHA-1 and MD5 hashes are correct. Intrepid is fine. - - ubuntu1204i386 = { - name = "ubuntu-12.04-precise-i386"; - fullName = "Ubuntu 12.04 Precise (i386)"; - packagesLists = - [ (fetchurl { - url = "mirror://ubuntu/dists/precise/main/binary-i386/Packages.bz2"; - sha256 = "18ns9h4qhvjfcip9z55grzi371racxavgqkp6b5kfkdq2wwwax2d"; - }) - (fetchurl { - url = "mirror://ubuntu/dists/precise/universe/binary-i386/Packages.bz2"; - sha256 = "085lkzbnzkc74kfdmwdc32sfqyfz8dr0rbiifk8kx9jih3xjw2jk"; - }) - ]; - urlPrefix = "mirror://ubuntu"; - packages = commonDebPackages ++ [ "diffutils" ]; - }; - - ubuntu1204x86_64 = { - name = "ubuntu-12.04-precise-amd64"; - fullName = "Ubuntu 12.04 Precise (amd64)"; - packagesLists = - [ (fetchurl { - url = "mirror://ubuntu/dists/precise/main/binary-amd64/Packages.bz2"; - sha256 = "1aabpn0hdih6cbabyn87yvhccqj44q9k03mqmjsb920iqlckl3fc"; - }) - (fetchurl { - url = "mirror://ubuntu/dists/precise/universe/binary-amd64/Packages.bz2"; - sha256 = "0x4hz5aplximgb7gnpvrhkw8m7a40s80rkm5b8hil0afblwlg4vr"; - }) - ]; - urlPrefix = "mirror://ubuntu"; - packages = commonDebPackages ++ [ "diffutils" ]; - }; - ubuntu1404i386 = { name = "ubuntu-14.04-trusty-i386"; fullName = "Ubuntu 14.04 Trusty (i386)"; @@ -928,119 +890,117 @@ rec { packages = commonDebPackages ++ [ "diffutils" "libc-bin" ]; }; - ubuntu1710i386 = { - name = "ubuntu-17.10-artful-i386"; - fullName = "Ubuntu 17.10 Artful (i386)"; + ubuntu1804i386 = { + name = "ubuntu-18.04-bionic-i386"; + fullName = "Ubuntu 18.04 Bionic (i386)"; packagesLists = [ (fetchurl { - url = "mirror://ubuntu/dists/artful/main/binary-i386/Packages.xz"; - sha256 = "18yrj4kqdzm39q0527m97h5ing58hkm9yq9iyj636zh2rclym3c8"; + url = "mirror://ubuntu/dists/bionic/main/binary-i386/Packages.xz"; + sha256 = "0f0v4131kwf7m7f8j3288rlqdxk1k3vqy74b7fcfd6jz9j8d840i"; }) (fetchurl { - url = "mirror://ubuntu/dists/artful/universe/binary-i386/Packages.xz"; - sha256 = "1v0njw2w80xfmxi7by76cs8hyxlla5h3gqajlpdw5srjgx2qrm2g"; + url = "mirror://ubuntu/dists/bionic/universe/binary-i386/Packages.xz"; + sha256 = "1v75c0dqr0wp0dqd4hnci92qqs4hll8frqdbpswadgxm5chn91bw"; }) ]; urlPrefix = "mirror://ubuntu"; packages = commonDebPackages ++ [ "diffutils" "libc-bin" ]; }; - ubuntu1710x86_64 = { - name = "ubuntu-17.10-artful-amd64"; - fullName = "Ubuntu 17.10 Artful (amd64)"; + ubuntu1804x86_64 = { + name = "ubuntu-18.04-bionic-amd64"; + fullName = "Ubuntu 18.04 Bionic (amd64)"; packagesLists = [ (fetchurl { - url = "mirror://ubuntu/dists/artful/main/binary-amd64/Packages.xz"; - sha256 = "104g57j1l3vi8wb5f7rgjvjhf82ccs0vwhc59jfc4ynd51z7fqjk"; + url = "mirror://ubuntu/dists/bionic/main/binary-amd64/Packages.xz"; + sha256 = "1ls81bjyvmfz6i919kszl7xks1ibrh1xqhsk6698ackndkm0wp39"; }) (fetchurl { - url = "mirror://ubuntu/dists/artful/universe/binary-amd64/Packages.xz"; - sha256 = "1qzs95wfy9inaskfx9cf1l5yd3aaqwzy72zzi9xyvkxi75k5gcn4"; + url = "mirror://ubuntu/dists/bionic/universe/binary-amd64/Packages.xz"; + sha256 = "1832nqpn4ap95b3sj870xqayrza9in4kih9jkmjax27pq6x15v1r"; }) ]; urlPrefix = "mirror://ubuntu"; packages = commonDebPackages ++ [ "diffutils" "libc-bin" ]; }; - ubuntu1804i386 = { - name = "ubuntu-18.04-bionic-i386"; - fullName = "Ubuntu 18.04 Bionic (i386)"; + ubuntu2004i386 = { + name = "ubuntu-20.04-focal-i386"; + fullName = "Ubuntu 20.04 Focal (i386)"; packagesLists = [ (fetchurl { - url = "mirror://ubuntu/dists/bionic/main/binary-i386/Packages.xz"; - sha256 = "0f0v4131kwf7m7f8j3288rlqdxk1k3vqy74b7fcfd6jz9j8d840i"; + url = "mirror://ubuntu/dists/focal/main/binary-i386/Packages.xz"; + sha256 = "sha256-7RAYURoN3RKYQAHpwBS9TIV6vCmpURpphyMJQmV4wLc="; }) (fetchurl { - url = "mirror://ubuntu/dists/bionic/universe/binary-i386/Packages.xz"; - sha256 = "1v75c0dqr0wp0dqd4hnci92qqs4hll8frqdbpswadgxm5chn91bw"; + url = "mirror://ubuntu/dists/focal/universe/binary-i386/Packages.xz"; + sha256 = "sha256-oA551xVE80volUPgkMyvzpQ1d+GhuZd4DAe7dXZnULM="; }) ]; urlPrefix = "mirror://ubuntu"; packages = commonDebPackages ++ [ "diffutils" "libc-bin" ]; }; - ubuntu1804x86_64 = { - name = "ubuntu-18.04-bionic-amd64"; - fullName = "Ubuntu 18.04 Bionic (amd64)"; + ubuntu2004x86_64 = { + name = "ubuntu-20.04-focal-amd64"; + fullName = "Ubuntu 20.04 Focal (amd64)"; packagesLists = [ (fetchurl { - url = "mirror://ubuntu/dists/bionic/main/binary-amd64/Packages.xz"; - sha256 = "1ls81bjyvmfz6i919kszl7xks1ibrh1xqhsk6698ackndkm0wp39"; + url = "mirror://ubuntu/dists/focal/main/binary-amd64/Packages.xz"; + sha256 = "sha256-d1eSH/j+7Zw5NKDJk21EG6SiOL7j6myMHfXLzUP8mGE="; }) (fetchurl { - url = "mirror://ubuntu/dists/bionic/universe/binary-amd64/Packages.xz"; - sha256 = "1832nqpn4ap95b3sj870xqayrza9in4kih9jkmjax27pq6x15v1r"; + url = "mirror://ubuntu/dists/focal/universe/binary-amd64/Packages.xz"; + sha256 = "sha256-RqdG2seJvZU3rKVNsWgLnf9RwkgVMRE1A4IZnX2WudE="; }) ]; urlPrefix = "mirror://ubuntu"; packages = commonDebPackages ++ [ "diffutils" "libc-bin" ]; }; - debian8i386 = { - name = "debian-8.11-jessie-i386"; - fullName = "Debian 8.11 Jessie (i386)"; + debian9i386 = { + name = "debian-9.13-stretch-i386"; + fullName = "Debian 9.13 Stretch (i386)"; packagesList = fetchurl { - url = "mirror://debian/dists/jessie/main/binary-i386/Packages.xz"; - sha256 = "0adblarhx50yga900il6m25ng0csa81i3wid1dxxmydbdmri7v7d"; + url = "https://snapshot.debian.org/archive/debian/20210526T143040Z/dists/stretch/main/binary-i386/Packages.xz"; + sha256 = "sha256-fFRumd20wuVaYxzw0VPkAw5mQo8kIg+eXII15VSz9wA="; }; urlPrefix = "mirror://debian"; packages = commonDebianPackages; }; - debian8x86_64 = { - name = "debian-8.11-jessie-amd64"; - fullName = "Debian 8.11 Jessie (amd64)"; + debian9x86_64 = { + name = "debian-9.13-stretch-amd64"; + fullName = "Debian 9.13 Stretch (amd64)"; packagesList = fetchurl { - url = "mirror://debian/dists/jessie/main/binary-amd64/Packages.xz"; - sha256 = "09y1mv4kqllhxpk1ibjsyl5jig5bp0qxw6pp4sn56rglrpygmn5x"; + url = "https://snapshot.debian.org/archive/debian/20210526T143040Z/dists/stretch/main/binary-amd64/Packages.xz"; + sha256 = "sha256-1p4DEVpTGlBE3PtbQ90kYw4QNHkW0F4rna/Xz+ncMhw="; }; urlPrefix = "mirror://debian"; packages = commonDebianPackages; }; - debian9i386 = { - name = "debian-9.8-stretch-i386"; - fullName = "Debian 9.8 Stretch (i386)"; + debian10i386 = { + name = "debian-10.9-buster-i386"; + fullName = "Debian 10.9 Buster (i386)"; packagesList = fetchurl { - url = "http://snapshot.debian.org/archive/debian/20200301T030401Z/dists/stretch/main/binary-i386/Packages.xz"; - sha256 = "1jglr1d1jys3xddp8f7w9j05db39fah8xy4gfkpqbd1b5d2caslz"; + url = "https://snapshot.debian.org/archive/debian/20210526T143040Z/dists/buster/main/binary-i386/Packages.xz"; + sha256 = "sha256-zlkbKV+IGBCyWKD4v4LFM/EUA4TYS9fkLBPuF6MgUDo="; }; urlPrefix = "mirror://debian"; packages = commonDebianPackages; }; - debian9x86_64 = { - name = "debian-9.8-stretch-amd64"; - fullName = "Debian 9.8 Stretch (amd64)"; + debian10x86_64 = { + name = "debian-10.9-buster-amd64"; + fullName = "Debian 10.9 Buster (amd64)"; packagesList = fetchurl { - url = "http://snapshot.debian.org/archive/debian/20190503T090946Z/dists/stretch/main/binary-amd64/Packages.xz"; - sha256 = "01q00nl47p12n7wx0xclx59wf3zlkzrgj3zxpshyvb91xdnw5sh6"; + url = "https://snapshot.debian.org/archive/debian/20210526T143040Z/dists/buster/main/binary-amd64/Packages.xz"; + sha256 = "sha256-k13toY1b3CX7GBPQ7Jm24OMqCEsgPlGK8M99x57o69o="; }; urlPrefix = "mirror://debian"; packages = commonDebianPackages; }; - - }; @@ -1167,7 +1127,7 @@ rec { "passwd" ]; - commonDebianPackages = commonDebPackages ++ [ "sysvinit" "diff" "mktemp" ]; + commonDebianPackages = commonDebPackages ++ [ "sysvinit" "diff" ]; /* A set of functions that build the Linux distributions specified @@ -1196,4 +1156,4 @@ rec { `debDistros' sets. */ diskImages = lib.mapAttrs (name: f: f {}) diskImageFuns; -} // import ./windows pkgs +} diff --git a/pkgs/build-support/vm/windows/bootstrap.nix b/pkgs/build-support/vm/windows/bootstrap.nix deleted file mode 100644 index 3b06d8f4749..00000000000 --- a/pkgs/build-support/vm/windows/bootstrap.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ stdenv, fetchurl, vmTools, writeScript, writeText, runCommand, makeInitrd -, python, perl, coreutils, dosfstools, gzip, mtools, netcat-gnu, openssh, qemu -, samba, socat, vde2, cdrkit, pathsFromGraph, gnugrep -}: - -{ isoFile, productKey, arch ? null }: - -with stdenv.lib; - -let - controller = import ./controller { - inherit stdenv writeScript vmTools makeInitrd; - inherit samba vde2 openssh socat netcat-gnu coreutils gzip gnugrep; - }; - - mkCygwinImage = import ./cygwin-iso { - inherit stdenv fetchurl runCommand python perl cdrkit pathsFromGraph; - arch = let - defaultArch = if stdenv.is64bit then "x86_64" else "i686"; - in if arch == null then defaultArch else arch; - }; - - installer = import ./install { - inherit controller mkCygwinImage; - inherit stdenv runCommand openssh qemu writeText dosfstools mtools; - }; -in rec { - installedVM = installer { - inherit isoFile productKey; - }; - - runInVM = img: attrs: controller (attrs // { - inherit (installedVM) sshKey; - qemuArgs = attrs.qemuArgs or [] ++ [ - "-boot order=c" - "-drive file=${img},index=0,media=disk" - ]; - }); - - runAndSuspend = let - drives = { - s = { - source = "nixstore"; - target = "/nix/store"; - }; - x = { - source = "xchg"; - target = "/tmp/xchg"; - }; - }; - - genDriveCmds = letter: { source, target }: [ - "net use ${letter}: '\\\\192.168.0.2\\${source}' /persistent:yes" - "mkdir -p '${target}'" - "mount -o bind '/cygdrive/${letter}' '${target}'" - "echo '/cygdrive/${letter} ${target} none bind 0 0' >> /etc/fstab" - ]; - in runInVM "winvm.img" { - command = concatStringsSep " && " ([ - "net config server /autodisconnect:-1" - ] ++ concatLists (mapAttrsToList genDriveCmds drives)); - suspendTo = "state.gz"; - }; - - suspendedVM = stdenv.mkDerivation { - name = "cygwin-suspended-vm"; - buildCommand = '' - ${qemu}/bin/qemu-img create \ - -b "${installedVM}/disk.img" \ - -f qcow2 winvm.img - ${runAndSuspend} - mkdir -p "$out" - cp winvm.img "$out/disk.img" - cp state.gz "$out/state.gz" - ''; - }; - - resumeAndRun = command: runInVM "${suspendedVM}/disk.img" { - resumeFrom = "${suspendedVM}/state.gz"; - qemuArgs = singleton "-snapshot"; - inherit command; - }; -} diff --git a/pkgs/build-support/vm/windows/controller/default.nix b/pkgs/build-support/vm/windows/controller/default.nix deleted file mode 100644 index 9d13983a283..00000000000 --- a/pkgs/build-support/vm/windows/controller/default.nix +++ /dev/null @@ -1,263 +0,0 @@ -{ stdenv, writeScript, vmTools, makeInitrd -, samba, vde2, openssh, socat, netcat-gnu, coreutils, gnugrep, gzip -, runtimeShell -}: - -{ sshKey -, qemuArgs ? [] -, command ? "sync" -, suspendTo ? null -, resumeFrom ? null -, installMode ? false -}: - -with stdenv.lib; - -let - preInitScript = writeScript "preinit.sh" '' - #!${vmTools.initrdUtils}/bin/ash -e - export PATH=${vmTools.initrdUtils}/bin - mount -t proc none /proc - mount -t sysfs none /sys - for arg in $(cat /proc/cmdline); do - if [ "x''${arg#command=}" != "x$arg" ]; then - command="''${arg#command=}" - fi - done - - for i in $(cat ${modulesClosure}/insmod-list); do - insmod $i - done - - mkdir -p /dev /fs - - mount -t tmpfs none /dev - mknod /dev/null c 1 3 - mknod /dev/zero c 1 5 - mknod /dev/random c 1 8 - mknod /dev/urandom c 1 9 - mknod /dev/tty c 5 0 - - ifconfig lo up - ifconfig eth0 up 192.168.0.2 - - mount -t tmpfs none /fs - mkdir -p /fs/nix/store /fs/xchg /fs/dev /fs/sys /fs/proc /fs/etc /fs/tmp - - mount -o bind /dev /fs/dev - mount -t sysfs none /fs/sys - mount -t proc none /fs/proc - - mount -t 9p \ - -o trans=virtio,version=9p2000.L,cache=loose \ - store /fs/nix/store - - mount -t 9p \ - -o trans=virtio,version=9p2000.L \ - xchg /fs/xchg - - echo root:x:0:0::/root:/bin/false > /fs/etc/passwd - - set +e - chroot /fs $command $out - echo $? > /fs/xchg/in-vm-exit - - poweroff -f - ''; - - initrd = makeInitrd { - contents = singleton { - object = preInitScript; - symlink = "/init"; - }; - }; - - loopForever = "while :; do ${coreutils}/bin/sleep 1; done"; - - initScript = writeScript "init.sh" ('' - #!${runtimeShell} - ${coreutils}/bin/cp -L "${sshKey}" /ssh.key - ${coreutils}/bin/chmod 600 /ssh.key - '' + (if installMode then '' - echo -n "Waiting for Windows installation to finish..." - while ! ${netcat-gnu}/bin/netcat -z 192.168.0.1 22; do - echo -n . - # Print a dot every 10 seconds only to shorten line length. - ${coreutils}/bin/sleep 10 - done - ${coreutils}/bin/touch /xchg/waiting_done - echo " success." - # Loop forever, because this VM is going to be killed. - ${loopForever} - '' else '' - ${coreutils}/bin/mkdir -p /etc/samba /etc/samba/private \ - /var/lib/samba /var/log /var/run - ${coreutils}/bin/cat > /etc/samba/smb.conf <<CONFIG - [global] - security = user - map to guest = Bad User - guest account = root - workgroup = cygwin - netbios name = controller - server string = %h - log level = 1 - max log size = 1000 - log file = /var/log/samba.log - - [nixstore] - path = /nix/store - writable = yes - guest ok = yes - - [xchg] - path = /xchg - writable = yes - guest ok = yes - CONFIG - - ${samba}/sbin/nmbd -D - ${samba}/sbin/smbd -D - - echo -n "Waiting for Windows VM to become available..." - while ! ${netcat-gnu}/bin/netcat -z 192.168.0.1 22; do - echo -n . - ${coreutils}/bin/sleep 1 - done - ${coreutils}/bin/touch /xchg/waiting_done - echo " success." - - ${openssh}/bin/ssh \ - -o UserKnownHostsFile=/dev/null \ - -o StrictHostKeyChecking=no \ - -i /ssh.key \ - -l Administrator \ - 192.168.0.1 -- ${lib.escapeShellArg command} - '') + optionalString (suspendTo != null) '' - ${coreutils}/bin/touch /xchg/suspend_now - ${loopForever} - ''); - - kernelAppend = concatStringsSep " " [ - "panic=1" - "loglevel=4" - "console=tty1" - "console=ttyS0" - "command=${initScript}" - ]; - - controllerQemuArgs = concatStringsSep " " (maybeKvm64 ++ [ - "-pidfile $CTRLVM_PIDFILE" - "-nographic" - "-no-reboot" - "-virtfs local,path=/nix/store,security_model=none,mount_tag=store" - "-virtfs local,path=$XCHG_DIR,security_model=none,mount_tag=xchg" - "-kernel ${modulesClosure.kernel}/bzImage" - "-initrd ${initrd}/initrd" - "-append \"${kernelAppend}\"" - "-net nic,vlan=0,macaddr=52:54:00:12:01:02,model=virtio" - "-net vde,vlan=0,sock=$QEMU_VDE_SOCKET" - ]); - - maybeKvm64 = optional (stdenv.hostPlatform.system == "x86_64-linux") "-cpu kvm64"; - - cygwinQemuArgs = concatStringsSep " " (maybeKvm64 ++ [ - "-monitor unix:$MONITOR_SOCKET,server,nowait" - "-pidfile $WINVM_PIDFILE" - "-nographic" - "-net nic,vlan=0,macaddr=52:54:00:12:01:01" - "-net vde,vlan=0,sock=$QEMU_VDE_SOCKET" - "-rtc base=2010-01-01,clock=vm" - ] ++ qemuArgs ++ optionals (resumeFrom != null) [ - "-incoming 'exec: ${gzip}/bin/gzip -c -d \"${resumeFrom}\"'" - ]); - - modulesClosure = overrideDerivation vmTools.modulesClosure (o: { - rootModules = o.rootModules ++ singleton "virtio_net"; - }); - - preVM = '' - (set; declare -p) > saved-env - XCHG_DIR="$(${coreutils}/bin/mktemp -d nix-vm.XXXXXXXXXX --tmpdir)" - ${coreutils}/bin/mv saved-env "$XCHG_DIR/" - - eval "$preVM" - - QEMU_VDE_SOCKET="$(pwd)/vde.ctl" - MONITOR_SOCKET="$(pwd)/monitor" - WINVM_PIDFILE="$(pwd)/winvm.pid" - CTRLVM_PIDFILE="$(pwd)/ctrlvm.pid" - ${vde2}/bin/vde_switch -s "$QEMU_VDE_SOCKET" --dirmode 0700 & - echo 'alive?' | ${socat}/bin/socat - \ - UNIX-CONNECT:$QEMU_VDE_SOCKET/ctl,retry=20 - ''; - - vmExec = '' - ${vmTools.qemuProg} ${controllerQemuArgs} & - ${vmTools.qemuProg} ${cygwinQemuArgs} & - echo -n "Waiting for VMs to start up..." - timeout=60 - while ! test -e "$WINVM_PIDFILE" -a -e "$CTRLVM_PIDFILE"; do - timeout=$(($timeout - 1)) - echo -n . - if test $timeout -le 0; then - echo " timed out." - exit 1 - fi - ${coreutils}/bin/sleep 1 - done - echo " done." - ''; - - checkDropOut = '' - if ! test -e "$XCHG_DIR/waiting_done" && - ! kill -0 $(< "$WINVM_PIDFILE"); then - echo "Windows VM has dropped out early, bailing out!" >&2 - exit 1 - fi - ''; - - toMonitor = "${socat}/bin/socat - UNIX-CONNECT:$MONITOR_SOCKET"; - - postVM = if suspendTo != null then '' - while ! test -e "$XCHG_DIR/suspend_now"; do - ${checkDropOut} - ${coreutils}/bin/sleep 1 - done - ${toMonitor} <<CMD - stop - migrate_set_speed 4095m - migrate "exec:${gzip}/bin/gzip -c > '${suspendTo}'" - CMD - echo -n "Waiting for memory dump to finish..." - while ! echo info migrate | ${toMonitor} | \ - ${gnugrep}/bin/grep -qi '^migration *status: *complete'; do - ${coreutils}/bin/sleep 1 - echo -n . - done - echo " done." - echo quit | ${toMonitor} - wait $(< "$WINVM_PIDFILE") - eval "$postVM" - exit 0 - '' else if installMode then '' - wait $(< "$WINVM_PIDFILE") - eval "$postVM" - exit 0 - '' else '' - while kill -0 $(< "$CTRLVM_PIDFILE"); do - ${checkDropOut} - done - if ! test -e "$XCHG_DIR/in-vm-exit"; then - echo "Virtual machine didn't produce an exit code." - exit 1 - fi - eval "$postVM" - exit $(< "$XCHG_DIR/in-vm-exit") - ''; - -in writeScript "run-cygwin-vm.sh" '' - #!${stdenv.shell} -e - ${preVM} - ${vmExec} - ${postVM} -'' diff --git a/pkgs/build-support/vm/windows/cygwin-iso/default.nix b/pkgs/build-support/vm/windows/cygwin-iso/default.nix deleted file mode 100644 index 76cd41a75bc..00000000000 --- a/pkgs/build-support/vm/windows/cygwin-iso/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ stdenv, fetchurl, runCommand, python, perl, xorriso, pathsFromGraph -, arch ? "x86_64" -}: - -{ packages ? [] -, mirror ? "http://ftp.gwdg.de/pub/linux/sources.redhat.com/cygwin" -, extraContents ? [] -}: - -let - cygPkgList = if arch == "x86_64" then fetchurl { - url = "${mirror}/x86_64/setup.ini"; - sha256 = "0arrxvxbl85l82iy648snx5cl952w791p45p0dfg1xpiaf96cbkj"; - } else fetchurl { - url = "${mirror}/x86/setup.ini"; - sha256 = "1fayx34868vd5h2nah7chiw65sl3i9qzrwvs7lrlv2h8k412vb69"; - }; - - cygwinCross = (import ../../../../.. { - localSystem = stdenv.hostPlatform; - crossSystem = { - libc = "msvcrt"; - platform = {}; - inherit arch; - config = "${arch}-w64-mingw32"; - }; - }).windows.cygwinSetup; - - makeCygwinClosure = { packages, packageList }: let - expr = import (runCommand "cygwin.nix" { buildInputs = [ python ]; } '' - python ${./mkclosure.py} "${packages}" ${toString packageList} > "$out" - ''); - gen = { url, hash }: { - source = fetchurl { - url = "${mirror}/${url}"; - sha512 = hash; - }; - target = url; - }; - in map gen expr; - -in import ../../../../../nixos/lib/make-iso9660-image.nix { - inherit stdenv perl xorriso pathsFromGraph; - syslinux = null; - contents = [ - { source = "${cygwinCross}/bin/setup.exe"; - target = "setup.exe"; - } - { source = cygPkgList; - target = "setup.ini"; - } - ] ++ makeCygwinClosure { - packages = cygPkgList; - packageList = packages; - } ++ extraContents; -} diff --git a/pkgs/build-support/vm/windows/cygwin-iso/mkclosure.py b/pkgs/build-support/vm/windows/cygwin-iso/mkclosure.py deleted file mode 100644 index 4c0d67c43ba..00000000000 --- a/pkgs/build-support/vm/windows/cygwin-iso/mkclosure.py +++ /dev/null @@ -1,78 +0,0 @@ -# Ugliest Python code I've ever written. -- aszlig -import sys - -def get_plist(path): - in_pack = False - in_str = False - current_key = None - buf = "" - packages = {} - package_name = None - package_attrs = {} - with open(path, 'r') as setup: - for line in setup: - if in_str and line.rstrip().endswith('"'): - package_attrs[current_key] = buf + line.rstrip()[:-1] - in_str = False - continue - elif in_str: - buf += line - continue - - if line.startswith('@'): - in_pack = True - package_name = line[1:].strip() - package_attrs = {} - elif in_pack and ':' in line: - key, value = line.split(':', 1) - if value.lstrip().startswith('"'): - if value.lstrip()[1:].rstrip().endswith('"'): - value = value.strip().strip('"') - else: - in_str = True - current_key = key.strip().lower() - buf = value.lstrip()[1:] - continue - package_attrs[key.strip().lower()] = value.strip() - elif in_pack: - in_pack = False - packages[package_name] = package_attrs - return packages - -def main(): - packages = get_plist(sys.argv[1]) - to_include = set() - - def traverse(package): - to_include.add(package) - attrs = packages.get(package, {}) - deps = attrs.get('requires', '').split() - for new_dep in set(deps) - to_include: - traverse(new_dep) - - map(traverse, sys.argv[2:]) - - sys.stdout.write('[\n') - for package, attrs in packages.iteritems(): - if package not in to_include: - cats = [c.lower() for c in attrs.get('category', '').split()] - if 'base' not in cats: - continue - - install_line = attrs.get('install') - if install_line is None: - continue - - url, size, hash = install_line.split(' ', 2) - - pack = [ - ' {', - ' url = "{0}";'.format(url), - ' hash = "{0}";'.format(hash), - ' }', - ]; - sys.stdout.write('\n'.join(pack) + '\n') - sys.stdout.write(']\n') - -if __name__ == '__main__': - main() diff --git a/pkgs/build-support/vm/windows/default.nix b/pkgs/build-support/vm/windows/default.nix deleted file mode 100644 index 309241c36de..00000000000 --- a/pkgs/build-support/vm/windows/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -#note: the hardcoded /bin/sh is required for the VM's cygwin shell -pkgs: - -let - bootstrapper = import ./bootstrap.nix { - inherit (pkgs) stdenv vmTools writeScript writeText runCommand makeInitrd; - inherit (pkgs) coreutils dosfstools gzip mtools netcat-gnu openssh qemu samba; - inherit (pkgs) socat vde2 fetchurl python perl cdrkit pathsFromGraph; - inherit (pkgs) gnugrep; - }; - - builder = '' - source /tmp/xchg/saved-env 2> /dev/null || true - export NIX_STORE=/nix/store - export NIX_BUILD_TOP=/tmp - export TMPDIR=/tmp - export PATH=/empty - cd "$NIX_BUILD_TOP" - exec $origBuilder $origArgs - ''; - -in { - runInWindowsVM = drv: pkgs.lib.overrideDerivation drv (attrs: let - bootstrap = bootstrapper attrs.windowsImage; - in { - requiredSystemFeatures = [ "kvm" ]; - builder = pkgs.stdenv.shell; - args = ["-e" (bootstrap.resumeAndRun builder)]; - windowsImage = bootstrap.suspendedVM; - origArgs = attrs.args; - origBuilder = if attrs.builder == attrs.stdenv.shell - then "/bin/sh" - else attrs.builder; - - postHook = '' - PATH=/usr/bin:/bin:/usr/sbin:/sbin - SHELL=/bin/sh - eval "$origPostHook" - ''; - - origPostHook = attrs.postHook or ""; - fixupPhase = ":"; - }); -} diff --git a/pkgs/build-support/vm/windows/install/default.nix b/pkgs/build-support/vm/windows/install/default.nix deleted file mode 100644 index fe8e8f61de0..00000000000 --- a/pkgs/build-support/vm/windows/install/default.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ 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 = '' - mkdir -p "$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} - mkdir -p "$out" - cp winvm.img "$out/disk.img" - ''; - passthru = { - inherit sshKey; - }; -} diff --git a/pkgs/build-support/vm/windows/install/unattended-image.nix b/pkgs/build-support/vm/windows/install/unattended-image.nix deleted file mode 100644 index 5b1ff84cf44..00000000000 --- a/pkgs/build-support/vm/windows/install/unattended-image.nix +++ /dev/null @@ -1,123 +0,0 @@ -{ stdenv, writeText, dosfstools, mtools }: - -{ productKey -, shExecAfterwards ? "E:\\bootstrap.sh" -, cygwinRoot ? "C:\\cygwin" -, cygwinSetup ? "E:\\setup.exe" -, cygwinRepository ? "E:\\" -, cygwinPackages ? [ "openssh" ] -}: - -let - afterSetup = [ - cygwinSetup - "-L -n -q" - "-l ${cygwinRepository}" - "-R ${cygwinRoot}" - "-C base" - ] ++ map (p: "-P ${p}") cygwinPackages; - - winXpUnattended = writeText "winnt.sif" '' - [Data] - AutoPartition = 1 - AutomaticUpdates = 0 - MsDosInitiated = 0 - UnattendedInstall = Yes - - [Unattended] - DUDisable = Yes - DriverSigningPolicy = Ignore - Hibernation = No - OemPreinstall = No - OemSkipEula = Yes - Repartition = Yes - TargetPath = \WINDOWS - UnattendMode = FullUnattended - UnattendSwitch = Yes - WaitForReboot = No - - [GuiUnattended] - AdminPassword = "nopasswd" - AutoLogon = Yes - AutoLogonCount = 1 - OEMSkipRegional = 1 - OemSkipWelcome = 1 - ServerWelcome = No - TimeZone = 85 - - [UserData] - ComputerName = "cygwin" - FullName = "cygwin" - OrgName = "" - ProductKey = "${productKey}" - - [Networking] - InstallDefaultComponents = Yes - - [Identification] - JoinWorkgroup = cygwin - - [NetAdapters] - PrimaryAdapter = params.PrimaryAdapter - - [params.PrimaryAdapter] - InfID = * - - [params.MS_MSClient] - - [NetProtocols] - MS_TCPIP = params.MS_TCPIP - - [params.MS_TCPIP] - AdapterSections=params.MS_TCPIP.PrimaryAdapter - - [params.MS_TCPIP.PrimaryAdapter] - DHCP = No - IPAddress = 192.168.0.1 - SpecificTo = PrimaryAdapter - SubnetMask = 255.255.255.0 - WINS = No - - ; Turn off all components - [Components] - ${stdenv.lib.concatMapStrings (comp: "${comp} = Off\n") [ - "AccessOpt" "Appsrv_console" "Aspnet" "BitsServerExtensionsISAPI" - "BitsServerExtensionsManager" "Calc" "Certsrv" "Certsrv_client" - "Certsrv_server" "Charmap" "Chat" "Clipbook" "Cluster" "Complusnetwork" - "Deskpaper" "Dialer" "Dtcnetwork" "Fax" "Fp_extensions" "Fp_vdir_deploy" - "Freecell" "Hearts" "Hypertrm" "IEAccess" "IEHardenAdmin" "IEHardenUser" - "Iis_asp" "Iis_common" "Iis_ftp" "Iis_inetmgr" "Iis_internetdataconnector" - "Iis_nntp" "Iis_serversideincludes" "Iis_smtp" "Iis_webdav" "Iis_www" - "Indexsrv_system" "Inetprint" "Licenseserver" "Media_clips" "Media_utopia" - "Minesweeper" "Mousepoint" "Msmq_ADIntegrated" "Msmq_Core" - "Msmq_HTTPSupport" "Msmq_LocalStorage" "Msmq_MQDSService" - "Msmq_RoutingSupport" "Msmq_TriggersService" "Msnexplr" "Mswordpad" - "Netcis" "Netoc" "OEAccess" "Objectpkg" "Paint" "Pinball" "Pop3Admin" - "Pop3Service" "Pop3Srv" "Rec" "Reminst" "Rootautoupdate" "Rstorage" "SCW" - "Sakit_web" "Solitaire" "Spider" "TSWebClient" "Templates" - "TerminalServer" "UDDIAdmin" "UDDIDatabase" "UDDIWeb" "Vol" "WMAccess" - "WMPOCM" "WbemMSI" "Wms" "Wms_admin_asp" "Wms_admin_mmc" "Wms_isapi" - "Wms_server" "Zonegames" - ]} - - [WindowsFirewall] - Profiles = WindowsFirewall.TurnOffFirewall - - [WindowsFirewall.TurnOffFirewall] - Mode = 0 - - [SetupParams] - UserExecute = "${stdenv.lib.concatStringsSep " " afterSetup}" - - [GuiRunOnce] - Command0 = "${cygwinRoot}\bin\bash -l ${shExecAfterwards}" - ''; - -in stdenv.mkDerivation { - name = "unattended-floppy.img"; - buildCommand = '' - dd if=/dev/zero of="$out" count=1440 bs=1024 - ${dosfstools}/sbin/mkfs.msdos "$out" - ${mtools}/bin/mcopy -i "$out" "${winXpUnattended}" ::winnt.sif - ''; -} |