From 3a7ffa5c58a18439e9c05e81f1f5d94ee75b787d Mon Sep 17 00:00:00 2001
From: Michael Raskin <7c6f434c@mail.ru>
Date: Sat, 4 Oct 2008 15:24:08 +0000
Subject: [PATCH] Some of preparation work for adding Xen. Troubles: 1. Xen
 Dom0 support not complete in mainline. 2. Xen's love to check for headers in
 /usr/include. To do afterwards: We need to change bootloading setup a bit.

svn path=/nixpkgs/trunk/; revision=12941
---
 .../virtualization/xen/default.nix            | 36 +++++++++++++++++++
 pkgs/os-specific/linux/kernel/linux.nix       |  4 +++
 pkgs/top-level/all-packages.nix               | 17 +++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 pkgs/applications/virtualization/xen/default.nix

diff --git a/pkgs/applications/virtualization/xen/default.nix b/pkgs/applications/virtualization/xen/default.nix
new file mode 100644
index 000000000000..1bbdedcb4baa
--- /dev/null
+++ b/pkgs/applications/virtualization/xen/default.nix
@@ -0,0 +1,36 @@
+args :  
+let 
+  lib = args.lib;
+  fetchurl = args.fetchurl;
+  FullDepEntry = args.FullDepEntry;
+
+  version = lib.getAttr ["version"] "3.3.0" args; 
+  _buildInputs = with args; [
+    python e2fsprogs gnutls pkgconfig libjpeg 
+    ncurses SDL libvncserver zlib graphviz ghostscript 
+    texLive
+  ];
+in
+rec {
+  src = fetchurl {
+    url = "http://bits.xensource.com/oss-xen/release/${version}/xen-${version}.tar.gz";
+    sha256 = "0vghm31pqq8sc6x81jass2h5s22jlvv582xb8aq4j4cbcc5qixc9";
+  };
+
+  buildInputs = lib.filter (x: x != null) _buildInputs;
+  configureFlags = [];
+
+  /* doConfigure should be specified separately */
+  phaseNames = ["makeTools" "makeXen"];
+
+  makeTools = FullDepEntry (''make -C tools install PREFIX=$out '') 
+    ["minInit" "addInputs" "doUnpack"];
+      
+  makeXen = FullDepEntry (''make -C xen install PREFIX=$out '') 
+    ["minInit" "addInputs" "doUnpack"];
+      
+  name = "xen-" + version;
+  meta = {
+    description = "Xen paravirtualization tools";
+  };
+}
diff --git a/pkgs/os-specific/linux/kernel/linux.nix b/pkgs/os-specific/linux/kernel/linux.nix
index dc1996c0b9fc..788d54583426 100644
--- a/pkgs/os-specific/linux/kernel/linux.nix
+++ b/pkgs/os-specific/linux/kernel/linux.nix
@@ -16,6 +16,9 @@
 , # Whether to build a User-Mode Linux kernel.
   userModeLinux ? false
 
+, # Whether to build a Xen kernel.
+  xen ? false
+
 , # Allows you to set your own kernel version for output
   version ? "unknown"
 
@@ -72,6 +75,7 @@ stdenv.mkDerivation {
   
   arch =
     if userModeLinux then "um" else
+    if xen then "xen" else
     if stdenv.system == "i686-linux" then "i386" else
     if stdenv.system == "x86_64-linux" then "x86_64" else
     abort "Platform ${stdenv.system} is not supported.";
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 0f415e0c9efc..7268efaaae86 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -3260,6 +3260,13 @@ let
     inherit fetchurl stdenv;
   };
 
+  libvncserver = builderDefsPackage (import ../development/libraries/libvncserver) {
+    inherit libtool libjpeg openssl zlib;
+    inherit (xlibs) xproto libX11 damageproto libXdamage 
+      libXext xextproto fixesproto libXfixes xineramaproto
+      libXinerama libXrandr randrproto libXtst;
+  };
+
   libvorbis = import ../development/libraries/libvorbis {
     inherit fetchurl stdenv libogg;
   };
@@ -7010,6 +7017,16 @@ let
     inherit fetchurl stdenv wxGTK chmlib;
   };
 
+  /* Doesn't work yet
+  
+  xen = builderDefsPackage (import ../applications/virtualization/xen) {
+    inherit python e2fsprogs gnutls pkgconfig libjpeg
+      ncurses SDL libvncserver zlib;
+    texLive = if (getConfig ["xen" "texLive"] false) then texLive else null;
+    graphviz = if (getConfig ["xen" "graphviz"] false) then graphviz else null;
+    ghostscript = if (getConfig ["xen" "ghostscript"] false) then ghostscript else null;
+  }; */
+
   xfig = import ../applications/graphics/xfig {
     stdenv = overrideGCC stdenv gcc34;
     inherit fetchurl makeWrapper x11 Xaw3d libpng libjpeg;