1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-20 12:42:24 +00:00
nixpkgs/pkgs/build-support
aszlig 276b72fb93
vm: Introduce new Windows VM installer for Cygwin.
After quite a lot of fighting against Windows and its various
limitations, this new is the base architecture for installing and
accessing the Windows VM and thus the Cygwin environment inside it:

                .------------.
          .---> | vde_switch |
          |     `-[#]----[#]-'
          |        |      |
         ,'       .'      `---.___
       ,'    192.168.0.1          `.
       |          |            192.168.0.2
      ,'    _____[#]____           |
    ,'     |            |   ______[#]______
    |      | Windows VM |  |    .--'       |
    |      |____________|  |    |          |
    |             |  /|\   |  .-|          |
    | .---------. |   |    |  | |          |
  .-|-| manager |-'   |    |  | |          |
  | | `---------'     |    |  | |          |
  | |                 |    |  | |          |
  | | .-------------. |    | Samba         |
  | | | BOOTSTRAP   | |    |  | |          |
  | | |-------------| |    |  | |   .------|
  | `-| spawn VMs   |-+--> |  | `---| xchg | <-------.
  |   |-------------|      |  | .---^------|         |
  |   | install     |---.  |  `-| nixstore | <----.  |
  |   |-------------|   |  |    `----------|      |  |
  |---| suspend VM  |   |  |               |      |  |
  |   `------.------'   |  | Controller VM |      |  |
  |          |          |  |_______________|      |  |
  |       .--'          |         /|\            VirtIO
  |       |           __|__________:____________  |  |
  |      \|/         |  |          `.           | |  |
  | .------------.   |  |           :           | |  |
  | | REAL BUILD |   |  |   .-------^--------.  | |  |
  | |------------|   |  `-> | serial console |  | |  |
  `-| revive VM  |   |      `----------------'  | |  |
    |------------|   |------------.             | |  |
    | build      |-->| /nix/store >>>-----------|-'  |
    |------------|   |------------|             |    |
    | collect    |<--| xchg       >>>-----------|----'
    `-----.------'   |------------'             |
          |          |                          |
         \|/         |    |  |  __   ___  |     |
                     |    |--| |  | (__  -|-    |
    F I N I S H E D  |    |  | |__| ___)  |     |
                     |__________________________|

This might look a bit overwhelming, but let me try to explain:

We're starting at the base derivation ("BOOTSTRAP" above), where we
actually install the Cygwin envirenment. Over there we basically fire up
a vde_switch process and two virtual machines: One is the Windows
machine, the other is a NixOS machine, which serves as some kind of
proxy between the host and the Windows machine.

The reason we're doing this, is because we don't have a lot of options
for sharing files between a stock Windows machine and the host. In
earlier experiments, I've tried to communicate with the Windows guest by
using pipes and OpenSSH, but obviously this wasn't a big speed rush (or
to say it bluntly: It was fucking slow).

Using TCP/IP directly for accessing the guest would have been another
option, but it could lead to possible errors when the port or a range of
ports are in use at the Host system. Also, we would need to punch a hole
into the sandbox of the Nix builder (as it doesn't allow networking),
which in turn will possibly undermine deterministic builds/runs (well,
at least as deterministic as it can be, we're running Windows,
remember?).

So, let's continue: The responsibility of the NixOS (controller) VM is
to just wait until an SSH port becomes available on the Windows VM,
whereas the Windows VM itself is installed using an unattended
installation file provided via a virtual floppy image.

With the installation of the basic Windows OS, we directly install
Cygwin and start up an OpenSSH service.

At this point the bootstrapping is almost finished and as soon as the
port is available, the controller VM sets up Samba shares and makes it
available as drive letters within Windows and as bind mounts (for
example /nix/store) within Cygwin.

Finally we're making a snapshot of the memory of the Windows VM in order
to revive it within a few seconds when we want to build something.

Now, the build process itself is fairly straightforward: Revive VM and
build based on existing store derivations and collect the result _and_
the exit code from the xchg share/directory.

Conclusion: This architecture may sound a bit complicated, but we're
trying to achieve deterministic and reproducable builds and/or test
runs.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-02-26 04:50:53 +01:00
..
build-fhs-chrootenv My attempt to get Steam working in NixOS. It uses a function called buildFHSChrootEnv {} that composed chroot environments. In such a chroot environment, I could run Steam without much problem 2013-09-13 23:58:59 +02:00
buildenv buildEnv: don't warn about collisions in propagated packages 2012-07-25 23:18:39 -04:00
builder-defs Updating TeXLive to 2013 using updated Debian snapshots. 2013-10-14 10:58:54 +04:00
cabal Generate hoogle databases beside HTML haddock documentation for Haskell packages 2014-02-04 18:11:57 +01:00
clang-wrapper preferLocalBuild: set to true for wrappers and fetchers 2014-02-10 21:04:17 +01:00
dotnetenv * "ensureDir" -> "mkdir -p". "ensureDir" is a rather pointless 2012-01-18 20:16:00 +00:00
fetchbower Add fetchbower function to go along with bower2nix 2014-01-06 08:20:22 -05:00
fetchbzr - fetchbzr and nix-prefetch-bzr now only export, instead of cloning 2013-03-31 19:16:18 -07:00
fetchcvs * "ensureDir" -> "mkdir -p". "ensureDir" is a rather pointless 2012-01-18 20:16:00 +00:00
fetchdarcs Remove deprecated option --ephemeral from fetchdarcs 2012-10-22 15:02:33 +02:00
fetchfile
fetchgit fetchgit: Require a content hash 2014-02-18 19:13:07 +01:00
fetchgitrevision
fetchhg fetchhg: allow untrusted certs (merge #540) 2013-05-20 21:24:25 +02:00
fetchmtn Fix a few typos 2013-08-11 10:55:53 +00:00
fetchsvn preferLocalBuild: set to true for wrappers and fetchers 2014-02-10 21:04:17 +01:00
fetchsvnrevision
fetchsvnssh
fetchurl fetchurl: Ensure that ‘urls’ is a list 2014-02-19 13:58:42 +01:00
gcc-cross-wrapper Merge branch 'stdenv-updates' into pi-stdenv-updates 2012-12-28 20:14:01 +00:00
gcc-wrapper preferLocalBuild: revert a stdenv change 2014-02-10 23:33:49 +01:00
kdewrapper preferLocalBuild: set to true for wrappers and fetchers 2014-02-10 21:04:17 +01:00
kernel makeModulesClosure: Use kmod instead of module-init-tools 2013-08-07 22:46:11 +02:00
make-desktopitem * "ensureDir" -> "mkdir -p". "ensureDir" is a rather pointless 2012-01-18 20:16:00 +00:00
make-startupitem Added an optional parameter to "make-startupitem" to provide a prefix to the ".desktop" file. 2012-02-29 12:50:17 +00:00
make-symlinks
mono-dll-fixer
native-darwin-cctools-wrapper Darwin: Add mig', lipo', etc. to `stdenvNative'. 2012-04-23 15:47:31 +00:00
nuke-references * "ensureDir" -> "mkdir -p". "ensureDir" is a rather pointless 2012-01-18 20:16:00 +00:00
release debBuild: Allow setting a maintainer address 2014-02-06 14:36:50 +01:00
setup-hooks lcov: Filter out /nix/store/* by default 2014-02-05 19:18:33 +01:00
src-only
substitute * Set preferLocalBuild on a few more trivial builders. 2012-04-26 15:17:43 +00:00
upstream-updater Updating SlimerJS to Git version for compatibility with fresh xulrunner 2013-10-31 02:59:45 +04:00
vm vm: Introduce new Windows VM installer for Cygwin. 2014-02-26 04:50:53 +01:00
vsenv * "ensureDir" -> "mkdir -p". "ensureDir" is a rather pointless 2012-01-18 20:16:00 +00:00
replace-dependency.nix replace-dependency: Eelco has ruled, lowerCamelCase > dash-case :( 2013-01-13 11:15:01 -05:00
source-from-head-fun.nix Remove getConfig helper function 2012-09-19 13:56:56 -04:00
trivial-builders.nix Rename buildNativeInputs -> nativeBuildInputs 2012-12-28 19:20:09 +01:00