about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2008-03-14 13:51:01 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2008-03-14 13:51:01 +0000
commitbf5db34927154869c79eeb4ddd0e9a4f018b55e1 (patch)
tree3f039fb4195ef2a51befcee3a7b7597bfc8e5579
parent4624c8bc3f5b3aba4cdc048b755e11aba75f574c (diff)
downloadnixlib-bf5db34927154869c79eeb4ddd0e9a4f018b55e1.tar
nixlib-bf5db34927154869c79eeb4ddd0e9a4f018b55e1.tar.gz
nixlib-bf5db34927154869c79eeb4ddd0e9a4f018b55e1.tar.bz2
nixlib-bf5db34927154869c79eeb4ddd0e9a4f018b55e1.tar.lz
nixlib-bf5db34927154869c79eeb4ddd0e9a4f018b55e1.tar.xz
nixlib-bf5db34927154869c79eeb4ddd0e9a4f018b55e1.tar.zst
nixlib-bf5db34927154869c79eeb4ddd0e9a4f018b55e1.zip
* Move to Nixpkgs: support for building in VMs is more generally
  useful, probably.

svn path=/nixpkgs/trunk/; revision=11126
-rw-r--r--pkgs/build-support/vm/deb/deb-closure.nix73
-rw-r--r--pkgs/build-support/vm/deb/deb-closure.pl162
-rw-r--r--pkgs/build-support/vm/deb/debian-4.0r3-etch-i386.nix636
-rw-r--r--pkgs/build-support/vm/deb/ubuntu-7.10-gutsy-i386.nix660
-rw-r--r--pkgs/build-support/vm/vm.nix477
5 files changed, 2008 insertions, 0 deletions
diff --git a/pkgs/build-support/vm/deb/deb-closure.nix b/pkgs/build-support/vm/deb/deb-closure.nix
new file mode 100644
index 000000000000..64db0307ffa3
--- /dev/null
+++ b/pkgs/build-support/vm/deb/deb-closure.nix
@@ -0,0 +1,73 @@
+with import ../../../nixpkgs {};
+
+rec {
+
+  debClosureGenerator =
+    {name, packages, urlPrefix, toplevel}:
+    runCommand name {} ''
+      ensureDir $out
+      bunzip2 < ${packages} > ./Packages
+      ${perl}/bin/perl -I${dpkg} -w ${./deb-closure.pl} \
+        ./Packages ${urlPrefix} ${toString toplevel} > $out/${name}.nix
+    '';
+
+
+  commonPackages = [
+    "base-passwd"
+    "dpkg"
+    "libc6-dev"
+    "perl"
+    "sysvinit"
+    "bash"
+    "gzip"
+    "bzip2"
+    "tar"
+    "grep"
+    "findutils"
+    "g++"
+    "make"
+    "curl"
+    "patch"
+    "diff"
+  ];
+
+  
+  # Ubuntu 7.10 "Gutsy Gibbon", i386.
+
+  packagesUbuntuGutsyI386 = fetchurl {
+    url = mirror://ubuntu/dists/gutsy/main/binary-i386/Packages.bz2;
+    sha1 = "8b52ee3d417700e2b2ee951517fa25a8792cabfd";
+  };
+
+  debsUbuntuGutsyI386 = debClosureGenerator {
+    name = "ubuntu-7.10-gutsy-i386";
+    packages = packagesUbuntuGutsyI386;
+    urlPrefix = mirror://ubuntu;
+    toplevel = commonPackages;
+  };
+
+
+  # Debian 4.0r3 "Etch", i386.
+
+  packagesDebianEtchR3I386 = fetchurl {
+    url = mirror://debian/dists/etch/main/binary-i386/Packages.bz2;
+    sha256 = "7a8f2777315d71fd7321d1076b3bf5f76afe179fe66c2ce8e1ff4baed6424340";
+  };
+
+  debsDebianEtchR3I386 = debClosureGenerator {
+    name = "debian-4.0r3-etch-i386";
+    packages = packagesDebianEtchR3I386;
+    urlPrefix = mirror://debian;
+    toplevel = commonPackages;
+  };
+
+
+  # To update the Nix expressions for all distributions, do
+  # $ nix-build deb-closure.nix -A allDists
+  # $ cp -f result*/*.nix .
+  allDists = [
+    debsUbuntuGutsyI386
+    debsDebianEtchR3I386
+  ];
+
+}
diff --git a/pkgs/build-support/vm/deb/deb-closure.pl b/pkgs/build-support/vm/deb/deb-closure.pl
new file mode 100644
index 000000000000..f35af6ca2dad
--- /dev/null
+++ b/pkgs/build-support/vm/deb/deb-closure.pl
@@ -0,0 +1,162 @@
+use strict;
+use Dpkg::Cdata;
+use Dpkg::Deps;
+
+my $packagesFile = shift @ARGV;
+my $urlPrefix = shift @ARGV;
+my @toplevelPkgs = @ARGV;
+
+my %packages;
+
+
+# Parse the Packages file.
+open PACKAGES, "<$packagesFile" or die;
+
+while (1) {
+    my $cdata = parsecdata(\*PACKAGES, $packagesFile);
+    last unless defined $cdata;
+    #print $cdata->{Package}, "\n";
+    die unless defined $cdata->{Package};
+    $packages{$cdata->{Package}} = $cdata;
+}
+
+close PACKAGES;
+
+
+# Flatten a Dpkg::Deps dependency value into a list of package names.
+sub getDeps {
+    my $deps = shift;
+    #print "$deps\n";
+    if ($deps->isa('Dpkg::Deps::AND')) {
+        my @res = ();
+        foreach my $dep ($deps->get_deps()) {
+            push @res, getDeps($dep);
+        }
+        return @res;
+    } elsif ($deps->isa('Dpkg::Deps::OR')) {
+        # Arbitrarily pick the first alternative.
+        return getDeps(($deps->get_deps())[0]);
+    } elsif ($deps->isa('Dpkg::Deps::Simple')) {
+        return ($deps->{package});
+    } else {
+        die "unknown dep type";
+    }
+}
+
+
+# Process the "Provides" fields to be able to resolve virtual dependencies.
+my %provides;
+
+foreach my $cdata (values %packages) {
+    next unless defined $cdata->{Provides};
+    my @provides = getDeps(Dpkg::Deps::parse($cdata->{Provides}));
+    foreach my $name (@provides) {
+        #die "conflicting provide: $name\n" if defined $provides{$name};
+        $provides{$name} = $cdata->{Package};
+    }
+}
+
+
+# Determine the closure of a package.
+my %donePkgs;
+my %depsUsed;
+my @order = ();
+
+sub closePackage {
+    my $pkgName = shift;
+    print STDERR ">>> $pkgName\n";
+    my $cdata = $packages{$pkgName};
+    
+    if (!defined $cdata) {
+        die "unknown (virtual) package $pkgName"
+            unless defined $provides{$pkgName};
+        print STDERR "virtual $pkgName: using $provides{$pkgName}\n";
+        $pkgName = $provides{$pkgName};
+        $cdata = $packages{$pkgName};
+    }
+    
+    die "unknown package $pkgName" unless defined $cdata;
+    return if defined $donePkgs{$pkgName};
+    $donePkgs{$pkgName} = 1;
+
+    if (defined $cdata->{Provides}) {
+        foreach my $name (getDeps(Dpkg::Deps::parse($cdata->{Provides}))) {
+            $provides{$name} = $cdata->{Package};
+        }
+    }
+    
+    my @depNames = ();
+    
+    if (defined $cdata->{Depends}) {
+        print STDERR "    $pkgName: $cdata->{Depends}\n";
+        my $deps = Dpkg::Deps::parse($cdata->{Depends});
+        die unless defined $deps;
+        push @depNames, getDeps($deps);
+    }
+
+    if (defined $cdata->{'Pre-Depends'}) {
+        print STDERR "    $pkgName: $cdata->{'Pre-Depends'}\n";
+        my $deps = Dpkg::Deps::parse($cdata->{'Pre-Depends'});
+        die unless defined $deps;
+        push @depNames, getDeps($deps);
+    }
+
+    foreach my $depName (@depNames) {
+        closePackage($depName);
+    }
+
+    push @order, $pkgName;
+    $depsUsed{$pkgName} = \@depNames;
+}
+
+foreach my $pkgName (@toplevelPkgs) {
+    closePackage $pkgName;
+}
+
+
+# Generate the output Nix expression.
+print "# This is a generated file.  Do not modify!\n";
+print "# Following are the Debian packages constituting the closure of: @toplevelPkgs\n\n";
+print "{fetchurl}:\n\n";
+print "[\n\n";
+
+# Output the packages in strongly connected components.
+my %done;
+my %forward;
+my $newComponent = 1;
+foreach my $pkgName (@order) {
+    $done{$pkgName} = 1;
+    my $cdata = $packages{$pkgName};
+    my @deps = @{$depsUsed{$pkgName}};
+    foreach my $dep (@deps) {
+        $dep = $provides{$dep} if defined $provides{$dep};
+        $forward{$dep} = 1 unless defined $done{$dep};
+    }
+    delete $forward{$pkgName};
+
+    print "  [\n\n" if $newComponent;
+    $newComponent = 0;
+    
+    print "    (fetchurl {\n";
+    print "      url = $urlPrefix/$cdata->{Filename};\n";
+    print "      sha256 = \"$cdata->{SHA256}\";\n";
+    print "    })\n";
+    print "\n";
+
+    if (keys %forward == 0) {
+        print "  ]\n\n";
+        $newComponent = 1;
+    }
+}
+
+foreach my $pkgName (@order) {
+    my $cdata = $packages{$pkgName};
+}
+
+print "]\n";
+
+if ($newComponent != 1) {
+    print STDERR "argh: ", keys %forward, "\n";
+    exit 1;
+}
+    
diff --git a/pkgs/build-support/vm/deb/debian-4.0r3-etch-i386.nix b/pkgs/build-support/vm/deb/debian-4.0r3-etch-i386.nix
new file mode 100644
index 000000000000..1c1fd5c759a2
--- /dev/null
+++ b/pkgs/build-support/vm/deb/debian-4.0r3-etch-i386.nix
@@ -0,0 +1,636 @@
+# This is a generated file.  Do not modify!
+# Following are the Debian packages constituting the closure of: base-passwd dpkg libc6-dev perl sysvinit bash gzip bzip2 tar grep findutils g++ make curl patch diff
+
+{fetchurl}:
+
+[
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/t/tzdata/tzdata_2007j-1etch1_all.deb;
+      sha256 = "30f2dbef304a607186cdff70f941e206937c8436ef3879f09e1b650d65949044";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/glibc/libc6_2.3.6.ds1-13etch5_i386.deb;
+      sha256 = "569ccb57467f964545fcc273a6892f92b1dc63dbf54b4da5fccd3f4b6b0d4678";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/b/base-passwd/base-passwd_3.5.11_i386.deb;
+      sha256 = "5a8711f95673857089ed9593a66b466c846460aa917e11547e1ce896f28f78e4";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/a/attr/libattr1_2.4.32-1_i386.deb;
+      sha256 = "9aa43d126a99773423910c33192bd743e8a116956e08255709cff05fbf261f60";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/a/acl/libacl1_2.2.41-1_i386.deb;
+      sha256 = "322caa80ab62b2e7c37946caf1d8f45f21094e9419217000263536946106cf7b";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/libs/libsepol/libsepol1_1.14-2_i386.deb;
+      sha256 = "d1a0540ee9c0ebe5b182106015e2b26ed026bc53636a3b864e8c06c50c62f6c8";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/libs/libselinux/libselinux1_1.32-3_i386.deb;
+      sha256 = "eb3634aa668ab672511cbe0eb9759af05fd1de336997fe194b63f0489ae1255e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/c/coreutils/coreutils_5.97-5.3_i386.deb;
+      sha256 = "5715b547be835bd0ca6d030e692ebc7ba7f9062720a8b442aaab311d653165a9";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/d/dpkg/dpkg_1.13.25_i386.deb;
+      sha256 = "7764da2301834b4906b49cc98394abb72e5e7d13b893836c9364b0551ba6c358";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/l/linux-kernel-headers/linux-kernel-headers_2.6.18-7_i386.deb;
+      sha256 = "5d7fc0e4644b1b462f2629592346d3c3d14c74258f56d295f2e6901a5ab5818d";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/glibc/libc6-dev_2.3.6.ds1-13etch5_i386.deb;
+      sha256 = "f25d6cf99191d82d3cc98026aad9fa87c0ee01376b2ccf947d24d49d54fc3921";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/p/perl/perl-base_5.8.8-7etch1_i386.deb;
+      sha256 = "115bd8480b219ccb4dd404db0c963c3a81b749b95757f91fd00f823f45ed93d6";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/p/perl/perl-modules_5.8.8-7etch1_all.deb;
+      sha256 = "866f6a1349afd49fe3f5348e80f78832d873736f28b757ec6c82449a548d8b91";
+    })
+
+    (fetchurl {
+      url = mirror://debian/pool/main/d/db4.4/libdb4.4_4.4.20-8_i386.deb;
+      sha256 = "0bbfabc55d921bca3259b917606fe631d8bece325500c50cca82ddb6aec2a706";
+    })
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gdbm/libgdbm3_1.8.3-3_i386.deb;
+      sha256 = "3727e66c280186b80bc78b3d60227ed7d17e1654e0a631a9281694242c6a2eb5";
+    })
+
+    (fetchurl {
+      url = mirror://debian/pool/main/p/perl/perl_5.8.8-7etch1_i386.deb;
+      sha256 = "ddbdf0d42a23ab8c04f7072da1188378a42af50429c257fb44059d25c895d6ca";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/d/devmapper/libdevmapper1.02_1.02.08-1_i386.deb;
+      sha256 = "9450aac0602a129dec12ecd8f42996d620ee1257302ee267e4c0dc290c8d2a54";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/e/e2fsprogs/libblkid1_1.39+1.40-WIP-2006.11.14+dfsg-2etch1_i386.deb;
+      sha256 = "61b3c85a0aa1fb685afb1630e0913cbecf32951a170fb32ae0bea89cc4e8add4";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/e/e2fsprogs/libuuid1_1.39+1.40-WIP-2006.11.14+dfsg-2etch1_i386.deb;
+      sha256 = "d68dd88e728425c4b2363d3bc1ae88074cdf58c6348d98148c1ef18ff1cb7edf";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/u/util-linux/mount_2.12r-19etch1_i386.deb;
+      sha256 = "7ee5eb539d88cbbfa5c1a680301fe7b085d1c1f789b874e6ec731e9f99d5763e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/e/e2fsprogs/e2fslibs_1.39+1.40-WIP-2006.11.14+dfsg-2etch1_i386.deb;
+      sha256 = "52e47af4d5e3c535ae1138e65940da611127f20002ba6174eaa4d3570e472106";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/e/e2fsprogs/libcomerr2_1.39+1.40-WIP-2006.11.14+dfsg-2etch1_i386.deb;
+      sha256 = "1bda45c7432f33ae8d3f052d4cacb750e9f6bef76c694f1cf2546ebd59b0b5cf";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/e/e2fsprogs/libss2_1.39+1.40-WIP-2006.11.14+dfsg-2etch1_i386.deb;
+      sha256 = "26b536eb4b764d92c67c5b1d67c0e0852b963ea74b1969f24cd9cb6f967420b3";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/e/e2fsprogs/e2fsprogs_1.39+1.40-WIP-2006.11.14+dfsg-2etch1_i386.deb;
+      sha256 = "b321d84956924408889b6bf20d69eb497140224b5a6c76525086c8b3ad440a08";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/m/mktemp/mktemp_1.5-2_i386.deb;
+      sha256 = "52631c9c63e77477d7f25e375070a077f64e5a858ea04570edaa69def41f033a";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/d/debianutils/debianutils_2.17_i386.deb;
+      sha256 = "8e285bf5dca0a6ef34375eeafb04bf80d5e5fd9d76ff3fe30e136afa110b25ce";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/s/sed/sed_4.1.5-1_i386.deb;
+      sha256 = "e327372142755510308b96fb620f6696bb2154c152058da7c5ca0895e853d787";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/n/ncurses/libncurses5_5.5-5_i386.deb;
+      sha256 = "a130b26ee0dc1244a4901a614b2cbbf773c9facd90b1caf8cedc1ccb74c47c75";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/n/ncurses/ncurses-bin_5.5-5_i386.deb;
+      sha256 = "eb9000dc13baee9def447aa847542eadbaa2ab763aed54332e17f0fc77ab0e35";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/l/lsb/lsb-base_3.1-23.2etch1_all.deb;
+      sha256 = "5eab8ab6dc064f986a1e812cf42bc7a08c6fc37afddaab4589b50456318a9bc0";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/s/sysvinit/sysvinit-utils_2.86.ds1-38_i386.deb;
+      sha256 = "6d8969270e7743b4b714e1970d5c68da3bb0d90317c7fc5df3686d98e4b93ab1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/s/sysvinit/initscripts_2.86.ds1-38_i386.deb;
+      sha256 = "2b98a7d1c035b3d8b10be9c83f2336814e85d0c2180e9649b8f3d40b74cccc96";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/s/sysvinit/sysv-rc_2.86.ds1-38_all.deb;
+      sha256 = "e802d214aa6f1e892efe6192d37ddea4565db572af735777b1a1e5bbdb0583ca";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/s/sysvinit/sysvinit_2.86.ds1-38_i386.deb;
+      sha256 = "7e9320ec965f31126693e45814d1bb2da037e1e8b20503932ec7fa3baef730ef";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/o/original-awk/original-awk_2005-04-24-1_i386.deb;
+      sha256 = "ebd87e7280d7c1114ccf9811ada8885f5b2c27a456f5510937c5e0155851f27b";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/b/base-files/base-files_4_i386.deb;
+      sha256 = "755bcc19d7a69c02ebe629c6c0164cd0fead751b0f5f510d17898dbcf1331a90";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/b/bash/bash_3.1dfsg-8_i386.deb;
+      sha256 = "7dafebd6c7497b5fddfe31b015f54daac8016190d65512019f8a85813e4bcd9e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gzip/gzip_1.3.5-15_i386.deb;
+      sha256 = "69fa6bd9f481907a24de4c95518afa80d149413299f3747f466fc624004282b0";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/b/bzip2/libbz2-1.0_1.0.3-6_i386.deb;
+      sha256 = "5ba52d235bd7d8b275578b9d423eb326d81c47be9a0109bc957f077c249d2fb1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/b/bzip2/bzip2_1.0.3-6_i386.deb;
+      sha256 = "a842f7d3618bf8d3f841a26210a5eb25b4dbbdc7bda5ae58445566a777e526c9";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/t/tar/tar_1.16-2etch1_i386.deb;
+      sha256 = "a552aa6e9964383e1d206976921bedbc3f65538b63d2cd6878bf2d3ac5592ec0";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/grep/grep_2.5.1.ds2-6_i386.deb;
+      sha256 = "c1cd478952d465ae000e764dc0a3848611b74aaf08a8e9e287a779878b3810e1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/f/findutils/findutils_4.2.28-1etch1_i386.deb;
+      sha256 = "35247479b93f642280bc889f4ee68c159cc0acb65c3f85ba5d0bdb16e1788607";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/gcc-4.1-base_4.1.1-21_i386.deb;
+      sha256 = "17f2a157d633fab3607da8eb0c3880d1a17edf78088cbb03ad11a33a1a43751a";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/cpp-4.1_4.1.1-21_i386.deb;
+      sha256 = "b5cfe9647b3cc32290a35735b0d23f03c7496f601b583d9a45e6cd65a06671c1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-defaults/cpp_4.1.1-15_i386.deb;
+      sha256 = "fc3098e45d35ccbc686f9d64c0076e4e71e308afcc9860fde677cb57c538a631";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/b/binutils/binutils_2.17-3_i386.deb;
+      sha256 = "b4c9c803b11399b847520a947177120882a141154c262d956b8c64c95c14ae77";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/libgcc1_4.1.1-21_i386.deb;
+      sha256 = "7a8602535c66275d7737883b8341be5517cf24b4a0aacc2a6b9b7734951e373b";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/libssp0_4.1.1-21_i386.deb;
+      sha256 = "43bbb9a30c7a00be2f5284721fc7540368c096c7f7a08ee27249176a72692d8c";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/gcc-4.1_4.1.1-21_i386.deb;
+      sha256 = "ef14b1d2191088260ca58431461e22ae74cd79a10f526fa6378da3efeee0fd65";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-defaults/gcc_4.1.1-15_i386.deb;
+      sha256 = "881b0767478c84599627d3e4ca815976c01d7cb55645b2c2b44f3f0317a9efd1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/libstdc++6_4.1.1-21_i386.deb;
+      sha256 = "000cb49d99f8a26443e5ebcaa6a54d71d9bd048534a56b20f9aa296f80ff378d";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/libstdc++6-4.1-dev_4.1.1-21_i386.deb;
+      sha256 = "dc82b38311583beab6d3edf66440f6d83a4b7c22d6c6facb520624c3216e9bd3";
+    })
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-4.1/g++-4.1_4.1.1-21_i386.deb;
+      sha256 = "17b625ec86d1536076a3b471e8e4f6e42cf7f700427492ab2cc9cfbb6e3df4ed";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/g/gcc-defaults/g++_4.1.1-15_i386.deb;
+      sha256 = "22eb32986879b7ca6df155c304e24b04901659a0167517e73b579c854c437819";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/m/make-dfsg/make_3.81-2_i386.deb;
+      sha256 = "b0ee2643f055948711b0ab53acbed0a94763acdd376d10f790139b6caee7a2d0";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/libi/libidn/libidn11_0.6.5-1_i386.deb;
+      sha256 = "d79a4399740e1ed745d23215c6d9edb62a9954ca366b8e4005b85eb33af939ff";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/k/krb5/libkrb53_1.4.4-7etch4_i386.deb;
+      sha256 = "fc2b160e3d19d7983ff1ccf303523fe9ce87f74932ccdb0cf5dedc7f4708ccb4";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/z/zlib/zlib1g_1.2.3-13_i386.deb;
+      sha256 = "9487521ecaa382ff90789cc68866c6a78720b5ea9c1680baf49b7f70f699a5da";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/libl/liblocale-gettext-perl/liblocale-gettext-perl_1.05-1_i386.deb;
+      sha256 = "dc263b6c8e134deac509596eba3f7e2b02a99a789ae493c16dcd7f6d804e054f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/libt/libtext-iconv-perl/libtext-iconv-perl_1.4-3_i386.deb;
+      sha256 = "01e69dc4b8439f16b35e81e8e6304e1feb8ac5797fd2e9b064a22bc381a5b812";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/libt/libtext-charwidth-perl/libtext-charwidth-perl_0.04-4_i386.deb;
+      sha256 = "6c8edbaea5f6dd5d4d65ffcd5a624bd1a1612a14126044119b078f3f772aaf00";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/libt/libtext-wrapi18n-perl/libtext-wrapi18n-perl_0.06-5_all.deb;
+      sha256 = "8d303ff47b6b175b8eb8440451a85f867ffc663ca4bac521ae9a00d45dabbb1b";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/d/debconf/debconf-i18n_1.5.11etch1_all.deb;
+      sha256 = "bf996964e12d8922dd005d527383b2270dcba9051c2bf04478989e53c389e8c4";
+    })
+
+    (fetchurl {
+      url = mirror://debian/pool/main/d/debconf/debconf_1.5.11etch1_all.deb;
+      sha256 = "f1862a9e10ac8422f684e915b24593d510e82923859e071d0d538246727171bf";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/o/openssl/libssl0.9.8_0.9.8c-4etch1_i386.deb;
+      sha256 = "16d22c98928c6401d9c6522a3820e64169e39af4fd06ffb28918d58c83461e86";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/o/openssl/openssl_0.9.8c-4etch1_i386.deb;
+      sha256 = "c4ac1549f4e463f285631374f878c92913a8d14519fd555ac2242e311250124f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/c/ca-certificates/ca-certificates_20070303_all.deb;
+      sha256 = "ecef927c097fe08677c87799510f33efbf955f00120d74e347227731a1405f91";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/c/curl/libcurl3_7.15.5-1etch1_i386.deb;
+      sha256 = "0732b4d588219773090c39f8f4e7a4cd7a56111b15ab635d162682cd9bd39b6a";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/c/curl/curl_7.15.5-1etch1_i386.deb;
+      sha256 = "a4a5d65ed5193695eefd6c6bad8b80f395126970abcf85ab831de042c41c7b07";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/p/patch/patch_2.5.9-4_i386.deb;
+      sha256 = "5cc5fe81887a3aa0587357d3432b51cb3906556c2f28607b741db6bc71334c92";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://debian/pool/main/d/diffutils/diff_2.8.1-11_i386.deb;
+      sha256 = "29444f20c30c9f00bf0ea1b2d5958f164ecd6a553718847e1acb8d0a384f316f";
+    })
+
+  ]
+
+]
diff --git a/pkgs/build-support/vm/deb/ubuntu-7.10-gutsy-i386.nix b/pkgs/build-support/vm/deb/ubuntu-7.10-gutsy-i386.nix
new file mode 100644
index 000000000000..0a7a97b3ca48
--- /dev/null
+++ b/pkgs/build-support/vm/deb/ubuntu-7.10-gutsy-i386.nix
@@ -0,0 +1,660 @@
+# This is a generated file.  Do not modify!
+# Following are the Debian packages constituting the closure of: base-passwd dpkg libc6-dev perl sysvinit bash gzip bzip2 tar grep findutils g++ make curl patch diff
+
+{fetchurl}:
+
+[
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.2/gcc-4.2-base_4.2.1-5ubuntu4_i386.deb;
+      sha256 = "1f83b97053de65c9653a89ecb34f74127af0550e41ba11eed14252b404c3bb5a";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.2/libgcc1_4.2.1-5ubuntu4_i386.deb;
+      sha256 = "d7b993b2a67e9db8d774c9eb614d59005f5c7ab3fee465530ef9b36e91af4635";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/glibc/libc6_2.6.1-1ubuntu9_i386.deb;
+      sha256 = "cf019ce2db7463a5d80e28515aa4be7e7b764d54ba4e8d1075d3347a1bf91a6e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/b/base-passwd/base-passwd_3.5.11build1_i386.deb;
+      sha256 = "c1c94973b3f05a01142ab472d91a0b7c3984b72002657837ac6501dcd047ceda";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/a/attr/libattr1_2.4.32-1.1ubuntu1_i386.deb;
+      sha256 = "7d1d6cb090ce71246dfdbca6608732700eb6c760cce41953d317c73995ec3f42";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/a/acl/libacl1_2.2.42-1ubuntu1_i386.deb;
+      sha256 = "1afdc9f931a6b79eab7ebc8b46e3216d38882119ee11a75e24a0e93e1b6d0e78";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libs/libsepol/libsepol1_2.0.3-1_i386.deb;
+      sha256 = "10c806dcee03befb4d988a251f582fbc1a40d0297a694f64a779709d2abfb0d1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libs/libselinux/libselinux1_2.0.15-2ubuntu1_i386.deb;
+      sha256 = "3313baa7fae9875e449feb6acc98df620e4526a1303beb0a1b5620fa58e8acfc";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/c/coreutils/coreutils_5.97-5.3ubuntu3_i386.deb;
+      sha256 = "f2004475ed039ff3ea9f0de5e4564c791f420fd0a575d681e33676fd53ae4b42";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/dpkg/dpkg_1.14.5ubuntu16_i386.deb;
+      sha256 = "ed06c0ba98ac035cd277eb06054830796acb0a1a3e088985212a329115a41806";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/l/linux-source-2.6.22/linux-libc-dev_2.6.22-14.46_i386.deb;
+      sha256 = "c5852c7ce875b60b41f3ff35d9b1aab14363a6bf14bdbb66e819f07c027ea8da";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/glibc/libc6-dev_2.6.1-1ubuntu9_i386.deb;
+      sha256 = "280ee1685edcdcb0a39050a17e7e2027da216204481bafc15d9eefb6125be2fa";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/p/perl/perl-base_5.8.8-7ubuntu3_i386.deb;
+      sha256 = "b904ccfe30a529360c1950b683a03c725bf7a02ea3f3061906864085861a14ff";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/p/perl/perl-modules_5.8.8-7ubuntu3_all.deb;
+      sha256 = "ead07312e376ccd1e81baf668104d7549936526b42024bd463a7f14e75b861a9";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/db4.4/libdb4.4_4.4.20-8.1ubuntu3_i386.deb;
+      sha256 = "06ca10f0fe4a40b3a5728c767c3478c277d826acd8dc07c9efa365f39a4eed5e";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gdbm/libgdbm3_1.8.3-3_i386.deb;
+      sha256 = "48939f175e6fe9a49dcf7fc765b76d2ff870a4d218e6d0a1fbc03ad58f39e9e4";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/p/perl/perl_5.8.8-7ubuntu3_i386.deb;
+      sha256 = "145acad7ccb7c6a92c3f46301a635af2428bf2a01342181d3bffdf3181c8e4e2";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/u/util-linux/mount_2.13-8ubuntu1_i386.deb;
+      sha256 = "f7f97ce1c9d06422887740472321ea6c013c063f9a138dc08d56aee64ad269dc";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/e/e2fsprogs/e2fslibs_1.40.2-1ubuntu1_i386.deb;
+      sha256 = "0664ab855d297af6bc9fb5961173e6ea4e305f9e5d655edbbc20017994ac7640";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/devmapper/libdevmapper1.02.1_1.02.20-1ubuntu4_i386.deb;
+      sha256 = "912f4c76f74abddc3c4f48153416e61411cce73036975bebedcfce5de02bed9e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/e/e2fsprogs/libblkid1_1.40.2-1ubuntu1_i386.deb;
+      sha256 = "c244c2c08288daa4fb6a658d317938043b4028fc6360503e7c5cc7dbc9305352";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/e/e2fsprogs/libcomerr2_1.40.2-1ubuntu1_i386.deb;
+      sha256 = "81704b204d8d1ed573e97d57db09094db4719bc50a18aba16ed096d8291ba097";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/e/e2fsprogs/libss2_1.40.2-1ubuntu1_i386.deb;
+      sha256 = "f34f0e9cec977734271c0429395b42ee04f55dcabfd915c40f7dc80ca5faafaf";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/e/e2fsprogs/libuuid1_1.40.2-1ubuntu1_i386.deb;
+      sha256 = "d2f096e341554cc4105194d153e3e0ef2a318a2f72fb3b7d1feb6ab56bcc24a3";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/e/e2fsprogs/e2fsprogs_1.40.2-1ubuntu1_i386.deb;
+      sha256 = "d8c127697f7e32bf3c5dc5729cca4a1996be4f07c260e15cd551edb3835d4578";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/debianutils/debianutils_2.22.1_i386.deb;
+      sha256 = "d5887030d7f87e24faa2ad286b295afcb269442540beacd269abdc2c2b2ec9cf";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/s/sed/sed_4.1.5-2_i386.deb;
+      sha256 = "cab4ea7a45c4976ea5a50b90675916a1c11e231782def1b190f3988ddb873de5";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/n/ncurses/libncurses5_5.6+20070716-1ubuntu3_i386.deb;
+      sha256 = "b394501198467dfd3b7c71778b502570af4a1ec0ef5720985d72d6f1c3f6464f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/n/ncurses/ncurses-bin_5.6+20070716-1ubuntu3_i386.deb;
+      sha256 = "cabe0ee116bbabc478ae9902f27db59fbd597b5d5216816278652fc7a765a706";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/l/lsb/lsb-base_3.1-23.1ubuntu3_all.deb;
+      sha256 = "3c3fc72e2eb258faed465ce840c6c7601ed681cecb800df0885d741f8fd87d3f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/s/sysvinit/sysv-rc_2.86.ds1-14.1ubuntu31_all.deb;
+      sha256 = "84a6a91e69fe97bf04ad3776866f78ce71f8c24acb065b680489cc1fef879e35";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/s/sysvinit/sysvutils_2.86.ds1-14.1ubuntu31_i386.deb;
+      sha256 = "d1175000ffcd8dcc03346b0d137a3c6d084be84f9da1c707a27eceec3e973847";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libl/liblocale-gettext-perl/liblocale-gettext-perl_1.05-1build1_i386.deb;
+      sha256 = "47a54818c8250afa15570bd204902c39cd8598c61c13148d37052e5de86b9fe1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libt/libtext-iconv-perl/libtext-iconv-perl_1.4-3_i386.deb;
+      sha256 = "5d4ccb4620137da604c4718de8b27201e5b0a017ccc7f133b0b2a30c0e7c66d4";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libt/libtext-charwidth-perl/libtext-charwidth-perl_0.04-4build1_i386.deb;
+      sha256 = "aca57fcee4aafe7e7aab1d413f381c78322dc073a710184c0761be588d5c1385";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libt/libtext-wrapi18n-perl/libtext-wrapi18n-perl_0.06-5_all.deb;
+      sha256 = "ca9adfc2c06e195e2885aed70ad39dd2f170a148cbaecf1339accb3f1c1b4485";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/debconf/debconf-i18n_1.5.14ubuntu1_all.deb;
+      sha256 = "790f3285d46f87e885fd5b96bca1c2089aa5bfd3c163c45cef8c62663659204d";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/debconf/debconf_1.5.14ubuntu1_all.deb;
+      sha256 = "8f17e1f923f3fe5f56730a9cd44e4da401c50f3c988f3e54c5206fe1f2b96044";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libp/libpam-foreground/libpam-foreground_0.4-1_i386.deb;
+      sha256 = "6641690217fee4a91556104f68f5559f20ffa621d1992e9db231a44a2d3aea3f";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/p/pam/libpam-runtime_0.99.7.1-5ubuntu1_all.deb;
+      sha256 = "bcaa63e45942a9f153b77d277e38615000855d0555092a52a3c8d792415d2d37";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/p/pam/libpam0g_0.99.7.1-5ubuntu1_i386.deb;
+      sha256 = "5ae28b79dd5a388158a7da59ffc239d82f1d58bc98ed16a4281eb46e20019bac";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/db4.5/libdb4.5_4.5.20-5ubuntu3_i386.deb;
+      sha256 = "5d38fd34b914b4385e5b878d41bb120fd5116bda0402aab8e2d9cb2f0814158d";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/p/pam/libpam-modules_0.99.7.1-5ubuntu1_i386.deb;
+      sha256 = "d0bb0efbbeb33902abb2dd98cc937ad7998aab851b576abc07b95165758379a2";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/s/shadow/login_4.0.18.1-9_i386.deb;
+      sha256 = "3cf2eaa169d0548e6d837e19359a5c52626f482faab65864f0a3a72ef6a2f5d7";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/s/shadow/passwd_4.0.18.1-9_i386.deb;
+      sha256 = "1828cec14651446a7b6e847a64c5901df95746a3f8ca32265ae02c596cc3e04a";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/s/sysvinit/initscripts_2.86.ds1-14.1ubuntu31_i386.deb;
+      sha256 = "b6da59fc414fb7f10b794dc28dbd3f485e50157aa4908fa5ed49be20e775363f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/s/sysvinit/sysvinit_2.86.ds1-14.1ubuntu31_i386.deb;
+      sha256 = "799ab512915a69350ac3833d0a3b75425df25327b5b81c51babcd0011c04fd15";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gawk/gawk_3.1.5.dfsg-4ubuntu1_i386.deb;
+      sha256 = "c675a510af0441c34a6f78d37fbb8c620cf51cfc226aa88cffc494b4ed477c60";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/b/base-files/base-files_4.0.0ubuntu5_i386.deb;
+      sha256 = "8a175da4301a3f09ec25dc9e8e749de58bc2801a990d64b1857316e74481e088";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/b/bash/bash_3.2-0ubuntu11_i386.deb;
+      sha256 = "6b92923fa08c6ec695532b1b44e2c55c65a69c456ea4425308664e53a194c09e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gzip/gzip_1.3.12-2ubuntu1_i386.deb;
+      sha256 = "88e837eb4f9dc3b4748e5a11817c90ebc0724d84c75458187465f8390685e85e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/b/bzip2/libbz2-1.0_1.0.4-0ubuntu2_i386.deb;
+      sha256 = "58fa34ecf2ba0a8c249851dce0489f99732542a04f4b45c013ee30bf67d4f9c3";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/b/bzip2/bzip2_1.0.4-0ubuntu2_i386.deb;
+      sha256 = "a9757666c4162780e82ec9654651631f1c685356a5d79cd1c43b94329376a1b1";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/t/tar/tar_1.18-2ubuntu1_i386.deb;
+      sha256 = "235aec14e07bbcba4d0653f8a91fe8e13b563085818026ad9c300ec19460b0d7";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/grep/grep_2.5.1.ds2-6build1_i386.deb;
+      sha256 = "72731370e1cc92ee561f2964f988aa65b8083cb25daad5906d4a29efdce8b645";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/f/findutils/findutils_4.2.31-1ubuntu2_i386.deb;
+      sha256 = "09d1a0f98ecb913614da7d41e277501e209f04e2b5cc10cc92afb58acef5d20b";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.1/gcc-4.1-base_4.1.2-16ubuntu2_i386.deb;
+      sha256 = "79d72ef12a3be08b29d0ccd6ed4d1d2f4ef1c9ae91d46bd3d1df6febabdf6975";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.1/cpp-4.1_4.1.2-16ubuntu2_i386.deb;
+      sha256 = "ffd43fc1c0baf1c81f7cdc9ffbc86700f802f331be302805812b2f51e1b01724";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-defaults/cpp_4.1.2-9ubuntu2_i386.deb;
+      sha256 = "af640c8f9d3570233bcae7245ed9784d5e4f4dce6da4cfcec4b4662dc1c1986f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/b/binutils/binutils_2.18-0ubuntu3_i386.deb;
+      sha256 = "c862de3bdde2c87b45e2890c8d6731aeb7e745adc850d199b7cdf8c983aa50e2";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.1/gcc-4.1_4.1.2-16ubuntu2_i386.deb;
+      sha256 = "0256944b06ef762af1104fb863c122ba5677bf880e5cbbc2aa81cae63a0deefd";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-defaults/gcc_4.1.2-9ubuntu2_i386.deb;
+      sha256 = "f111c3dc0a7cd8cbac6abb6ce5d339762e50bfdac951c0ce145313dabb6e725f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.2/libstdc++6_4.2.1-5ubuntu4_i386.deb;
+      sha256 = "e93e0086aa89e5aa582f489a3adab7073c3b773d444c3235885dc6a9b6752791";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.1/libstdc++6-4.1-dev_4.1.2-16ubuntu2_i386.deb;
+      sha256 = "94439277d179d9eaa1a0bfcf6fd6d8cb21d824ba5b6dcfc434011777eacd5f30";
+    })
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-4.1/g++-4.1_4.1.2-16ubuntu2_i386.deb;
+      sha256 = "900720c345681780687865df9c18a38a7aac07a5efe482866f9ca880a408ab87";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/g/gcc-defaults/g++_4.1.2-9ubuntu2_i386.deb;
+      sha256 = "daf099c8b3ebc31c1f39cf0f2c0797660507ea1c1450dab1acd70de13d1d7ee8";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/m/make-dfsg/make_3.81-3build1_i386.deb;
+      sha256 = "ad9894a687a2d664203b929a92c20d8e2dc69a1d9e208439b76f4159ba452bdf";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/libi/libidn/libidn11_1.0-0_i386.deb;
+      sha256 = "e7d7fce3900135e83228f79a5f430e9967dd95432feacc8044a324e74554ff00";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/k/keyutils/libkeyutils1_1.2-3_i386.deb;
+      sha256 = "aec7a7e4c07bc7bbe7f528ba8ec1279b797ce571d8f9519d234702993d7f2747";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.1-7build1_i386.deb;
+      sha256 = "09b229f03e75f5a9f4e6e56b62140f9cdf0ec7a9c6fcb1f09b8f2e5c0757214e";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/z/zlib/zlib1g_1.2.3.3.dfsg-5ubuntu2_i386.deb;
+      sha256 = "867423cbabd4475d662911a8e1c7c0d3067efdebd0f02e7d07bbd5d0a0dee2a6";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/o/openssl/libssl0.9.8_0.9.8e-5ubuntu3_i386.deb;
+      sha256 = "b6fd370b9425c7e7fe5bcb5c09d164db953e55946ed99e308f8402afb54e7a01";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/c/curl/libcurl3_7.16.4-2ubuntu1_i386.deb;
+      sha256 = "db6d60ad95f8e4d9ae76f5f20ce976dfdadfc42b59b028851eb6665f0e80466f";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/c/curl/curl_7.16.4-2ubuntu1_i386.deb;
+      sha256 = "88092ff2b7aa518bf23eda4da9794dbdb722f386515a3714087ac204a213c8ad";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/p/patch/patch_2.5.9-4_i386.deb;
+      sha256 = "53b5ff26960abc3b00e3b2ad05098be2ffdff67829957cec0d63c7b798a4fa1d";
+    })
+
+  ]
+
+  [
+
+    (fetchurl {
+      url = mirror://ubuntu/pool/main/d/diffutils/diff_2.8.1-12ubuntu1_i386.deb;
+      sha256 = "bb1a9bb5d36c04d478da87f403c2f061137d5d5a0269caedb9cfd3e7da2e0ead";
+    })
+
+  ]
+
+]
diff --git a/pkgs/build-support/vm/vm.nix b/pkgs/build-support/vm/vm.nix
new file mode 100644
index 000000000000..02b022bc584b
--- /dev/null
+++ b/pkgs/build-support/vm/vm.nix
@@ -0,0 +1,477 @@
+with import ../../nixpkgs {};
+
+rec {
+
+  stdenvLinuxStuff = import ../../nixpkgs/pkgs/stdenv/linux {
+    system = stdenv.system;
+    allPackages = import ../../nixpkgs/pkgs/top-level/all-packages.nix;
+  };
+
+  
+  modulesClosure = import ../../nixos/helpers/modules-closure.nix {
+    inherit stdenv module_init_tools kernel;
+    #rootModules = ["cifs" "ne2k_pci" "nls_utf8" "ata_piix" "sd_mod"];
+    rootModules = ["cifs" "ne2k_pci" "nls_utf8" "ide_disk" "ide_generic"];
+  };
+
+  
+  klibcShrunk = stdenv.mkDerivation {
+    name = "${klibc.name}";
+    buildCommand = ''
+      ensureDir $out/lib
+      cp -prd ${klibc}/lib/klibc/bin $out/
+      cp -p ${klibc}/lib/*.so $out/lib/
+      chmod +w $out/*
+      old=$(echo ${klibc}/lib/klibc-*.so)
+      new=$(echo $out/lib/klibc-*.so)
+      for i in $out/bin/*; do
+        echo $i
+        sed "s^$old^$new^" -i $i
+        # !!! use patchelf
+        #patchelf --set-rpath /foo/bar $i
+      done
+    ''; # */
+    allowedReferences = ["out"];
+  };
+
+  
+  mountCifs = (makeStaticBinaries stdenv).mkDerivation {
+    name = "mount.cifs";
+    src = fetchurl {
+      name = "mount.cifs.c";
+      url = "http://websvn.samba.org/cgi-bin/viewcvs.cgi/*checkout*/branches/SAMBA_3_0/source/client/mount.cifs.c?rev=6103";
+      sha256 = "19205gd3pv8g519hlbjaw559wqgf0h2vkln9xgqaqip2h446qarp";
+    };
+    buildInputs = [nukeReferences];
+    buildCommand = ''
+      ensureDir $out/bin
+      gcc -Wall $src -o $out/bin/mount.cifs
+      strip $out/bin/mount.cifs
+      nuke-refs $out/bin/mount.cifs
+    '';
+    allowedReferences = []; # prevent accidents like glibc being included in the initrd
+  };
+
+  
+  stage1Init = writeScript "vm-run-stage1" ''
+    #! ${stdenvLinuxStuff.bootstrapTools.bash} -e
+    echo START
+
+    export PATH=${klibcShrunk}/bin:${mountCifs}/bin
+
+    mkdir /etc
+    echo -n > /etc/fstab
+
+    mount -t proc none /proc
+
+    for o in $(cat /proc/cmdline); do
+      case $o in
+        useTmpRoot=1)
+          useTmpRoot=1
+          ;;
+        command=*)
+          set -- $(IFS==; echo $o)
+          command=$2
+          ;;
+        tmpDir=*)
+          set -- $(IFS==; echo $o)
+          export tmpDir=$2
+          ;;
+        out=*)
+          set -- $(IFS==; echo $o)
+          export out=$2
+          ;;
+      esac
+    done
+
+    for i in $(cat ${modulesClosure}/insmod-list); do
+      args=
+      case $i in
+        */cifs.ko)
+          args="CIFSMaxBufSize=4194304"
+          ;;
+      esac
+      echo "loading module $i with args $args"
+      insmod $i $args
+    done
+
+    mount -t tmpfs none /dev
+    mknod /dev/null c 1 3
+    mknod /dev/zero c 1 5
+    mknod /dev/tty  c 5 0
+    mknod /dev/sda  b 8 0
+    mknod /dev/hda  b 3 0
+    
+    ipconfig 10.0.2.15:::::eth0:none
+
+    mkdir /fs
+
+    if test -n "$useTmpRoot"; then
+      mount -t tmpfs none /fs
+    else
+      mount -t ext2 /dev/hda /fs
+    fi
+    
+    mkdir -p /fs/hostfs
+    
+    mkdir -p /fs/dev
+    mount -o bind /dev /fs/dev
+
+    mount.cifs //10.0.2.4/qemu /fs/hostfs -o guest,username=nobody
+
+    mkdir -p /fs/nix/store
+    mount -o bind /fs/hostfs/nix/store /fs/nix/store
+    
+    mkdir -p /fs/tmp
+    mount -t tmpfs -o "mode=755" none /fs/tmp
+
+    mkdir -p /fs/proc
+    mount -t proc none /fs/proc
+
+    mkdir -p /fs/etc
+    ln -sf /proc/mounts /fs/etc/mtab
+    
+    echo "Now running: $command"
+    test -n "$command"
+
+    set +e
+    chroot /fs $command /tmp $out /hostfs/$tmpDir
+    echo $? > /fs/hostfs/$tmpDir/in-vm-exit
+
+    mount -o remount,ro dummy /fs
+
+    echo DONE
+    reboot
+  '';
+
+  
+  initrd = import ../../nixos/boot/make-initrd.nix {
+    inherit stdenv perl cpio;
+    contents = [
+      { object = stage1Init;
+        symlink = "/init";
+      }
+    ];
+  };
+
+  
+  stage2Init = writeScript "vm-run-stage2" ''
+    #! ${bash}/bin/sh
+    source $3/saved-env
+    
+    export NIX_STORE=/nix/store
+    export NIX_BUILD_TOP="$1"
+    export TMPDIR="$1"
+    export PATH=/empty
+    out="$2"
+    export ORIG_TMPDIR="$3"
+    cd "$NIX_BUILD_TOP"
+
+    if ! test -e /bin/sh; then
+      ${coreutils}/bin/mkdir -p /bin
+      ${coreutils}/bin/ln -s ${bash}/bin/sh /bin/sh
+    fi
+
+    # For debugging: if this is the second time this image is run,
+    # then don't start the build again, but instead drop the user into
+    # an interactive shell.
+    if test -n "$origBuilder" -a ! -e /.debug; then
+      ${coreutils}/bin/touch /.debug
+      exec $origBuilder $origArgs
+    else
+      export PATH=/bin:/usr/bin:${coreutils}/bin
+      echo "Starting interactive shell..."
+      echo "(To run the original builder: \$origBuilder \$origArgs)"
+      exec ${bash}/bin/sh
+    fi
+  '';
+
+
+  qemuCommand = ''
+    QEMU_SMBD_COMMAND=${samba}/sbin/smbd qemu-system-x86_64 \
+      -nographic -no-reboot \
+      -smb / -hda $diskImage \
+      -kernel ${kernel}/vmlinuz \
+      -initrd ${initrd}/initrd \
+      -append "console=ttyS0 panic=1 command=${stage2Init} tmpDir=$TMPDIR out=$out useTmpRoot=$useTmpRoot" \
+      $QEMU_OPTS
+  '';
+
+  
+  vmRunCommand = writeText "vm-run" ''
+    export > saved-env
+
+    PATH=${coreutils}/bin:${kvm}/bin
+
+    diskImage=/dev/null
+
+    eval "$preVM"
+
+    # Write the command to start the VM to a file so that the user can
+    # debug inside the VM if the build fails (when Nix is called with
+    # the -K option to preserve the temporary build directory).
+    cat > ./run-vm <<EOF
+    #! ${bash}/bin/sh
+    diskImage=$diskImage
+    TMPDIR=$TMPDIR
+    ${qemuCommand}
+    EOF
+
+    chmod +x ./run-vm
+    source ./run-vm
+    
+    if ! test -e in-vm-exit; then
+      echo "Virtual machine didn't produce an exit code."
+      exit 1
+    fi
+    
+    exit $(cat in-vm-exit)
+  '';
+
+  
+  # Modify the given derivation to perform it in a virtual machine.
+  runInLinuxVM = attrs: derivation (removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"] // {
+    builder = "${bash}/bin/sh";
+    args = ["-e" vmRunCommand];
+    origArgs = attrs.args;
+    origBuilder = attrs.builder;
+    QEMU_OPTS = "-m ${toString (if attrs ? memSize then attrs.memSize else 256)}";
+  });
+
+  
+  test = runInLinuxVM patchelf;
+
+
+  fillDiskWithRPMs =
+    {size ? 1024, rpms, name, fullName, postInstall ? null}:
+    
+    runInLinuxVM (stdenv.mkDerivation {
+      inherit name postInstall rpms;
+
+      useTmpRoot = true;
+    
+      preVM = ''
+        mkdir $out
+        diskImage=$out/image
+        qemu-img create -f qcow $diskImage "${toString size}M"
+      '';
+
+      buildCommand = ''
+        mkdir /mnt
+        ${e2fsprogs}/sbin/mke2fs -F /dev/hda
+        ${klibcShrunk}/bin/mount -t ext2 /dev/hda /mnt
+
+        mkdir /mnt/proc /mnt/dev /mnt/sys
+
+        echo "initialising RPM DB..."
+        rpm="${rpm}/bin/rpm --root /mnt --dbpath /var/lib/rpm"
+        $rpm --initdb
+
+        echo "installing RPMs..."
+        $rpm --noscripts --notriggers --nodeps -iv $rpms
+
+        # Get rid of the Berkeley DB environment so that older RPM versions
+        # (using older versions of BDB) will still work.
+        rm -f /mnt/var/lib/rpm/__db.*
+
+        if test -e /mnt/bin/rpm; then
+          chroot /mnt /bin/rpm --rebuilddb
+        fi
+
+        chroot /mnt /sbin/ldconfig
+
+        echo "running post-install script..."
+        eval "$postInstall"
+        
+        ${klibcShrunk}/bin/umount /mnt
+      '';
+    });
+
+
+  test2 = fillDiskWithRPMs {
+    size = 1024;
+    name = "test";
+    fullName = "Test Image";
+    rpms = import ../rpm/fedora-3-packages.nix {inherit fetchurl;};
+  };
+
+
+  # Generates a script that can be used to run an interactive session
+  # in the given image.
+  makeImageTestScript = image: writeScript "image-test" ''
+    #! ${bash}/bin/sh
+    if test -z "$1"; then
+      echo "Syntax: $0 <copy-on-write-temp-file>"
+      exit 1
+    fi
+    diskImage="$1"
+    if ! test -e "$diskImage"; then
+      qemu-img create -b ${image}/image -f qcow "$diskImage"
+    fi
+    export TMPDIR=$(mktemp -d)
+    export out=/dummy
+    export origBuilder=
+    export origArgs=
+    export > $TMPDIR/saved-env
+    ${qemuCommand}
+  '';
+
+  test3 = makeImageTestScript test2;
+
+
+  buildRPM = runInLinuxVM (stdenv.mkDerivation {
+    name = "rpm-test";
+  
+    preVM = ''
+      diskImage=$(pwd)/image
+      qemu-img create -b ${test2}/image -f qcow $diskImage
+    '';
+
+    src = patchelf.src;
+
+    buildCommand = ''
+      PATH=/usr/bin:/bin:/usr/sbin:/sbin
+
+      echo ${patchelf.src}
+
+      stripHash "$src"
+      srcName="$strippedName"
+      ln -s "$src" "$srcName"
+
+      rpmbuild -vv -ta "$srcName"
+
+      ensureDir $out/rpms
+      find /usr/src -name "*.rpm" -exec cp {} $out/rpms \;
+    '';
+  });
+
+
+  # !!! should probably merge this with fillDiskWithRPMs.
+  fillDiskWithDebs =
+    {size ? 1024, debs, name, fullName, postInstall ? null}:
+    
+    runInLinuxVM (stdenv.mkDerivation {
+      inherit name postInstall;
+
+      debs = (lib.intersperse "|" debs);
+
+      useTmpRoot = true;
+    
+      preVM = ''
+        mkdir $out
+        diskImage=$out/image
+        qemu-img create -f qcow $diskImage "${toString size}M"
+      '';
+
+      buildCommand = ''
+        mkdir /mnt
+        ${e2fsprogs}/sbin/mke2fs -F /dev/hda
+        ${klibcShrunk}/bin/mount -t ext2 /dev/hda /mnt
+
+        if test -e /mnt/.debug; then
+          exec ${bash}/bin/sh
+        fi
+        touch /mnt/.debug
+
+        mkdir /mnt/proc /mnt/dev /mnt/sys /mnt/bin
+
+        echo "initialising Debian DB..."
+        PATH=$PATH:${dpkg}/bin:${dpkg}/sbin:${glibc}/sbin
+
+        # Unpack the .debs.  We do this to prevent pre-install scripts
+        # (which have lots of circular dependencies) from barfing.
+        echo "unpacking Debs..."
+        
+        for deb in $debs; do
+          if test "$deb" != "|"; then
+            echo "$deb..."
+            dpkg-deb --extract "$deb" /mnt
+          fi
+        done
+
+        # Make the Nix store available in /mnt, because that's where the .debs live.
+        mkdir -p /mnt/inst/nix/store
+        ${klibcShrunk}/bin/mount -o bind /nix/store /mnt/inst/nix/store
+
+        ${klibcShrunk}/bin/mount -o bind /dev /mnt/dev
+        
+        # Misc. files/directories assumed by various packages.
+        touch /mnt/etc/shells
+        touch /mnt/var/lib/dpkg/status
+        touch /mnt/var/lib/dpkg/available
+        touch /mnt/var/lib/dpkg/diversions
+
+        # Now install the .debs.  This is basically just to register
+        # them with dpkg and to make their pre/post-install scripts
+        # run.
+        echo "installing Debs..."
+
+        export DEBIAN_FRONTEND=noninteractive
+        
+        oldIFS="$IFS"
+        IFS="|"
+        for component in $debs; do
+          IFS="$oldIFS"
+          echo
+          echo ">>> INSTALLING COMPONENT: $component"
+          debs=
+          for i in $component; do
+            debs="$debs /inst/$i";
+          done
+          chroot=$(type -tP chroot)
+          PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
+            /usr/bin/dpkg --install --force-all $debs < /dev/null
+        done
+        
+        echo "running post-install script..."
+        eval "$postInstall"
+        
+        rm /mnt/.debug
+        
+        ${klibcShrunk}/bin/umount /mnt/inst/nix/store
+        ${klibcShrunk}/bin/umount /mnt/dev
+        ${klibcShrunk}/bin/umount /mnt
+      '';
+    });
+
+
+  test4 = fillDiskWithDebs {
+    size = 256;
+    name = "deb-test";
+    fullName = "Ubuntu Test Image";
+    debs = import ./deb/ubuntu-7.10-gutsy-i386.nix {inherit fetchurl;};
+  };
+
+  test5 = makeImageTestScript test4;
+
+  
+  test6 = runInLinuxVM (stdenv.mkDerivation {
+    name = "deb-compile";
+  
+    preVM = ''
+      diskImage=$(pwd)/image
+      qemu-img create -b ${test7}/image -f qcow $diskImage
+    '';
+
+    src = nixUnstable.src;
+
+    postHook = ''
+      PATH=/usr/bin:/bin:/usr/sbin:/sbin
+      SHELL=/bin/sh
+    '';
+
+    fixupPhase = "true";
+
+    memSize = 512;
+  });
+  
+
+  test7 = fillDiskWithDebs {
+    size = 256;
+    name = "deb-test";
+    fullName = "Debian Test Image";
+    debs = import ./deb/debian-4.0r3-etch-i386.nix {inherit fetchurl;};
+  };
+
+  
+}