Skip to content
  1. Feb 27, 2014
  2. Feb 26, 2014
    • Shea Levy's avatar
      D'oh · efb18d9a
      Shea Levy authored
      efb18d9a
    • Shea Levy's avatar
      Document mysql changes · c9f9835d
      Shea Levy authored
      c9f9835d
    • Shea Levy's avatar
      Merge mysql55 module into mysql · 1ce6fff4
      Shea Levy authored
      This also removes the default for services.mysql.package, as this should
      not generally be updated automatically if we change the mysql attribute
      1ce6fff4
    • Shea Levy's avatar
      Add graph-wrapper haskell package · 2fd60ee9
      Shea Levy authored
      2fd60ee9
    • aszlig's avatar
      Merge branch 'vmtools-windows-vm'. · b5de8156
      aszlig authored
      This adds a new function in vmTools, called runInWindowsVM, which allows
      to run a derivation within a Windows + Cygwin environment.
      
      To use it, you need to pass a Windows ISO and product key, for example:
      
      ------------------------------------------------------
      vmTools.runInWindowsVM (stdenv.mkDerivation {
        name = "hello-from-windows";
      
        windowsImage = {
          isoFile = /path/to/windows/image.iso;
          productKey = "ABCDE-FGHIJ-KLMNO-PQRST-UVWXY";
        };
      
        buildCommand = ''
          echo 'Look, I am running inside Windoze!'
          uname -a > "$out"
        '';
      })
      ------------------------------------------------------
      
      The derivation is then run within a special build process, which roughly
      does something like this:
      
                      ____________
                     |            |
                     | controller |
                     |____________|
                    /      |       \
        _________ /    ____|____     \___________      _______
       |         |    |         |    |           |    |       |
       | install | -> | suspend | -> | suspended | -> | build |
       |_________|    |_________|    |___________|    |_______|
      
      There are three steps necessary to produce the builder, which in the end
      is just a suspended Windows VM, running Cygwin and OpenSSH.
      
      Those steps are essentially:
      
       * install: Install the base Windows VM with Cygwin and OpenSSH.
       * suspend: Run the installed VM and dump the memory into a state file.
       * suspended: Resume from the state file and execute the build.
      
      Every build is based on the "suspended" step, which throws away all
      changes except to the resulting output store path(s).
      
      All of these steps are based on the controller, which is described in
      greater detail in commit 276b72fb.
      
      The reason I'm merging this right in is because it actually adds a
      feature that doesn't break existing functionality and only hooks into
      vmTools with a single line.
      
      To the contrary it even duplicates a bit of the code from vmTools, which
      might be a good start for refactoring. I didn't do that within that
      branch, because it otherwise *could* break existing functionality - VM
      tests in particular.
      
      Also, this implementation currently *only* supports Windows XP, because
      the implementation was originally made for building a Software where the
      majority of the users are using Windows XP and we need to do extensive
      testing on that platform.
      
      However, adding support for more recent versions is rather trivial. All
      there needs to be done is adding a new unattended installation config in
      unattended-image.nix.
      b5de8156
    • aszlig's avatar
      vmTools: Hook in runInWindowsVM function. · 88ea1728
      aszlig authored
      
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      88ea1728
    • aszlig's avatar
      vm/windows: Add setup.ini for 32bit architecture. · 895a683d
      aszlig authored
      
      
      Also update 64bit setup.ini and check whether we have a 64 bit stdenv in
      order to choose the proper Cygwin version. Otherwise we now have the
      setup.ini for 32bit available as well.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      895a683d
    • aszlig's avatar
      vm/windows: Make list of dependencies explicit. · 623f1940
      aszlig authored
      
      
      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: default avataraszlig <aszlig@redmoonstudios.org>
      623f1940
    • aszlig's avatar
      vm/windows: Factor out bootstrapping process. · d8e66722
      aszlig authored
      
      
      This now isolates the vmTools integration from the bootstrap process and
      thus removes our fixed Windows ISO and product key. The latter can now
      be provided by an attribute "windowsImage" to runInWindowsVM.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      d8e66722
    • aszlig's avatar
      vm/windows: Collect exit code from xchg. · e40f41e5
      aszlig authored
      
      
      This is the last item that was missing to get a fully working
      runInWindowsVM function. Apart from checking exit codes, we also now
      have preVM/postVM hooks which we can use to write arbitrary constructs
      around this architecture, without the need to worry about specific
      details.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      e40f41e5
    • aszlig's avatar
      vm/windows: Add new runInWindowsVM function. · b01c9624
      aszlig authored
      
      
      This function is quite similar to runInLinuxVM, but also ensures that
      the builder is run decoupled of the Nix store and using the userland
      inside the VM.
      
      We're now picking up the environment variables saved in the previous
      commit.
      
      The reason we suppress all errors from the source operation is that it
      would emit a ton of errors because we're trying to set read-only
      variables.
      
      Also, detecting whether the origBuilder is using the default builder
      from the stdenv is currently a bit of a workaround until we have a
      specialized pseudo-cross-stdenv someday in the future[TM].
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      b01c9624
    • aszlig's avatar
      vm/windows: Save envirenoment before running VM. · dd8b0fcf
      aszlig authored
      
      
      Later, when we start the actual builder, we're going to restore those
      environment variables. We're using "(set; declare -p)", here, because
      the former is just printing _all_ environment variables, even those not
      supported, and the latter only lists specifically declared variables,
      which also encludes exports.
      
      The "declare -p" command also emits those variables in a format similar
      to the "export" command.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      dd8b0fcf
    • aszlig's avatar
      vm/windows: Generate mounts from an attribute set. · 707b7ad1
      aszlig authored
      
      
      This is mainly to make it easier to quickly change mappings, without
      making room for errors such as typos.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      707b7ad1
    • aszlig's avatar
      vm/windows: Create fstab entries in suspended VM. · 5258bbe4
      aszlig authored
      
      
      Cygwin initializes mounts on _every_ login via SSH and doesn't keep them
      consistently like on Unix systems, that's why we need to also add fstab
      entries for the bind mounts to the store and xchg shares.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      5258bbe4
    • aszlig's avatar
      vm/windows: Use &&, not set -e in runAndSuspend. · d16dae8d
      aszlig authored
      
      
      We now have proper quoting, so we no longer need the workaround using
      "set -e".
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      d16dae8d
    • aszlig's avatar
      vm/windows: Fix perms of the Samba shares. · 084238c6
      aszlig authored
      
      
      We now map all guest accounts to the root user, because in the end the
      permissions of the current user boil down to the build user of the Nix
      builder of the host. That way it's not possible to gain more permissions
      at all and just makes the VM communication a lot easier.
      
      However, setting "writable" to yes instead of "read only" to no doesn't
      change anything here, I just found it to be clearer.
      
      Also, we now no longer need to have a "nobody" user.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      084238c6
    • aszlig's avatar
      vm/windows: Avoid shadowing the Nix store. · 5241bb1d
      aszlig authored
      
      
      This is done by putting the non-initrd /nix/store into a subdirectory,
      which we then chroot to and pass along the SSH command.
      
      Also, we now collect the exit code after the chroot command and power
      off the VM thereafter, because the store is no longer shadowed and we
      have still access to the busybox inside the initrd.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      5241bb1d
    • aszlig's avatar
      vm/windows: Remove Samba from installMode. · a1d7974a
      aszlig authored
      
      
      This should trim down possible dependencies on the base installation and
      hereby reduce the need for reinstallation of the damn VM to only changes
      that affect the Windows installation and the base Cygwin + OpenSSH
      setup.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      a1d7974a
    • aszlig's avatar
      vm/windows: Implement and use "xchg" share. · fedf13e6
      aszlig authored
      
      
      This now finally introduces our xchg share and also uses it for
      exchanging state while suspending a VM. However, accessing the _real_
      Nix store still isn't possible because we're shadowing the directory in
      the initrd.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      fedf13e6
    • aszlig's avatar
      vm/windows: Reintroduce setting up /nix/store. · 0ce1fd07
      aszlig authored
      
      
      Now we're doing this at the point where we're saving the VM state.
      Unfortunately it's not quite right, because the controller VM is shut
      down _before_ we're saving the state, so the share gets disconnected
      despite autodisconnect being deactivated during setup.
      
      We can get around this issue by finally introducing the xchg share,
      which is the last item to be implemented before we can merge to master.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      0ce1fd07
    • aszlig's avatar
      vm/windows: Properly escape shell command. · aa65a705
      aszlig authored
      
      
      Security-wise it's not a big issue because we're still sandboxed, but I
      really don't want to write something like \\\\\\\\192.168.0.2\\\\share
      in order to set up network shares.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      aa65a705
    • aszlig's avatar
      vm/windows: Don't init /nix/store on install. · cfa859d7
      aszlig authored
      
      
      We're going to do this during the suspendedVM phase, so we're able to
      more easily change the shares without reinstalling the whole VM.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      cfa859d7
    • aszlig's avatar
      vm/windows: Wait for VDE switch to startup. · 3e91192f
      aszlig authored
      
      
      This could possibly cause flapping whenever qemu is too fast in starting
      up. As we are running with the shell's -e flag, the socat check also
      ensures that the VDE switch is properly started and causes the whole
      build to fail, should it not start up within 20 seconds.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      3e91192f
    • aszlig's avatar
      vm/windows: Split install into several stages. · c731467e
      aszlig authored
      These stages are in particular:
      
       * Install of the bare Windows VM with Cygwin and shut down.
       * Boot up the same VM again without the installation media and dump the
         VMs memory to state.gz.
       * Resume from state.gz and build whatever we want to build.
      
      Every single stage involves a new "controller", which is more like an
      abstraction on the Nix side that constructs the madness described in
      276b72fb
      
      .
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      c731467e
    • aszlig's avatar
      vm/windows: Update sha256 of Cygwin's setup.ini. · 5105e7f0
      aszlig authored
      
      
      This is kinda stupid to do every little time the file is automatically
      regenerated upstream. But let's see how often that happens and whether
      it will become a major annoyance or not, and if yes, we might be forced
      to include it in our source tree.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      5105e7f0
    • aszlig's avatar
      vm/windows: Move creating SSH key into install/. · 9b1862ca
      aszlig authored
      
      
      This SSH key is specifically only for accessing the installed Cygwin
      within the Windows VM, so we only need to expose the private key. Yes,
      you heard right, the private key. It's not security-relevant because the
      machine is completely read-only, only exposed to the filesystem and
      networking is not available.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      9b1862ca
    • aszlig's avatar
      vm/windows: Move the installer into install/. · 4e21215d
      aszlig authored
      
      
      At least the largest portion of the installer, because in the end we
      don't want the installer to *actually* save the state but only prepare
      the base image.
      
      Signed-off-by: default avataraszlig <aszlig@redmoonstudios.org>
      4e21215d
    • aszlig's avatar
      vm: Introduce new Windows VM installer for Cygwin. · 276b72fb
      aszlig authored
      
      
      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: default avataraszlig <aszlig@redmoonstudios.org>
      276b72fb
  3. Feb 25, 2014
  4. Feb 24, 2014