{ nixos ? <nixpkgs/nixos>
, system ? builtins.currentSystem
}:

let

  host-configuration = import ./host-configuration-nixops.nix;

  host = import nixos {
    inherit system;
    configuration = host-configuration;
  };

  # TODO: Not yet sure if using the local packages is the best approach
  pkgs = import <nixpkgs> { };

in
rec {

  ova = host.config.system.build.virtualBoxOVA;

  nixos-disk = pkgs.stdenv.mkDerivation rec {
    name = "nixops-${version}.vmdk";
    version = host.config.system.nixos.release;
    phases = [ "installPhase" ];
    nativeBuildInputs = [ ova ];
    installPhase = ''
      mkdir ova
      tar -xf ${ova}/*.ova -C ova
      mkdir -p $out
      mv ova/nixos*.vmdk $out/nixops-${version}.vmdk
      ln -s nixops-${version}.vmdk $out/nixops.vmdk
    '';
  };

}