about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2010-06-14 18:42:18 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2010-06-14 18:42:18 +0000
commit98dff00f52fb6fba08574ee09d1d64748d25799b (patch)
tree4744f83c0d22169935c4b675dbb9913a793bdf8d /pkgs/build-support
parent5be3acda2d56db72f795c3e6b3dfcd150046eff9 (diff)
* Clean up diskImages/diskImageFuns/diskImageExtraFuns.
svn path=/nixpkgs/trunk/; revision=22265
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/vm/default.nix300
1 files changed, 162 insertions, 138 deletions
diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix
index 7cc1b843f0670..cc4ad1572fd19 100644
--- a/pkgs/build-support/vm/default.nix
+++ b/pkgs/build-support/vm/default.nix
@@ -4,7 +4,6 @@ with pkgs;
 
 rec {
 
-
   inherit (linuxPackages_2_6_32) kernel;
 
   kvm = pkgs.qemu_kvm;
@@ -12,7 +11,9 @@ rec {
 
   modulesClosure = makeModulesClosure {
     inherit kernel;
-    rootModules = [ "cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "nls_utf8" "ext2" "ext3" "unix" "sd_mod" "ata_piix" ];
+    rootModules =
+      [ "cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon"
+        "nls_utf8" "ext2" "ext3" "unix" "sd_mod" "ata_piix" ];
   };
 
 
@@ -336,7 +337,7 @@ rec {
   '';
 
   
-  /* Run a command in a x86 virtual machine image containing an
+  /* Run a command in an x86 virtual machine image containing an
      arbitrary OS.  The VM should be configured to do the following:
 
      - Write log output to the serial port.
@@ -351,8 +352,7 @@ rec {
      - Write an exit code to "in-vm-exit" on the SMB share ("0"
        meaning success).
 
-     - Reboot to shutdown the machine (because Qemu doesn't seem
-       capable of a APM/ACPI VM shutdown).
+     - Power-off or reboot the machine.
   */
   runInGenericVM = drv: lib.overrideDerivation drv (attrs: {
     system = "i686-linux";
@@ -652,13 +652,16 @@ rec {
      names. */
      
   makeImageFromRPMDist =
-    { name, fullName, size ? 4096, urlPrefix, packagesList, packages
-    , preInstall ? "", postInstall ? "", archs ? ["noarch" "i386"], runScripts ? true}:
+    { name, fullName, size ? 4096, urlPrefix, packagesList
+    , packages, extraPackages ? []
+    , preInstall ? "", postInstall ? "", archs ? ["noarch" "i386"]
+    , runScripts ? true }:
 
     fillDiskWithRPMs {
       inherit name fullName size preInstall postInstall runScripts;
       rpms = import (rpmClosureGenerator {
-        inherit name packagesList urlPrefix packages archs;
+        inherit name packagesList urlPrefix archs;
+        packages = packages ++ extraPackages;
       }) {inherit fetchurl;};
     };
 
@@ -685,11 +688,13 @@ rec {
      names. */
      
   makeImageFromDebDist =
-    {name, fullName, size ? 4096, urlPrefix, packagesList, packages, postInstall ? ""}:
+    { name, fullName, size ? 4096, urlPrefix, packagesList
+    , packages, extraPackages ? [], postInstall ? "" }:
 
     let
       expr = debClosureGenerator {
-        inherit name packagesList urlPrefix packages;
+        inherit name packagesList urlPrefix;
+        packages = packages ++ extraPackages;
       };
     in
       (fillDiskWithDebs {
@@ -698,13 +703,11 @@ rec {
       }) // {inherit expr;};
 
 
-  /* A bunch of functions that build disk images of various Linux
-     distributions, given a set of top-level package names to be
-     installed in the image. */
-
-  diskImageFuns = {
+  /* The set of supported RPM-based distributions. */
+      
+  rpmDistros = {
 
-    fedora2i386 = args: makeImageFromRPMDist ({
+    fedora2i386 = {
       name = "fedora-core-2-i386";
       fullName = "Fedora Core 2 (i386)";
       packagesList = fetchurl {
@@ -713,9 +716,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/core/2/i386/os;
       runScripts = false;
-    } // args);
-    
-    fedora3i386 = args: makeImageFromRPMDist ({
+      packages = commonFedoraPackages;
+    };
+
+    fedora3i386 = {
       name = "fedora-core-3-i386";
       fullName = "Fedora Core 3 (i386)";
       packagesList = fetchurl {
@@ -725,9 +729,10 @@ rec {
       urlPrefix = mirror://fedora/linux/core/3/i386/os;
       archs = ["noarch" "i386" "i586"];
       runScripts = false;
-    } // args);
+      packages = commonFedoraPackages;
+    };
     
-    fedora5i386 = args: makeImageFromRPMDist ({
+    fedora5i386 = {
       name = "fedora-core-5-i386";
       fullName = "Fedora Core 5 (i386)";
       packagesList = fetchurl {
@@ -735,9 +740,10 @@ rec {
         sha256 = "0lfk4mzrpiyls8h7k9ckc3vgywbmg05zsr4ag6qakgnv9gljijig";
       };
       urlPrefix = mirror://fedora/linux/core/5/i386/os;
-    } // args);
+      packages = commonFedoraPackages ++ [ "util-linux" ];
+    };
     
-    fedora7i386 = args: makeImageFromRPMDist ({
+    fedora7i386 = {
       name = "fedora-7-i386";
       fullName = "Fedora 7 (i386)";
       packagesList = fetchurl {
@@ -745,9 +751,10 @@ rec {
         sha256 = "0zq7ifirj45wry7b2qkm12qhzzazal3hn610h5kwbrfr2xavs882";
       };
       urlPrefix = mirror://fedora/linux/releases/7/Fedora/i386/os;
-    } // args);
+      packages = commonFedoraPackages;
+    };
     
-    fedora8i386 = args: makeImageFromRPMDist ({
+    fedora8i386 = {
       name = "fedora-8-i386";
       fullName = "Fedora 8 (i386)";
       packagesList = fetchurl {
@@ -755,9 +762,10 @@ rec {
         sha256 = "0vr9345rrk0vhs4pc9cjp8npdkqz0xqyirv84vhyfn533m9ws36f";
       };
       urlPrefix = mirror://fedora/linux/releases/8/Fedora/i386/os;
-    } // args);
+      packages = commonFedoraPackages;
+    };
 
-    fedora9i386 = args: makeImageFromRPMDist ({
+    fedora9i386 = {
       name = "fedora-9-i386";
       fullName = "Fedora 9 (i386)";
       packagesList = fetchurl {
@@ -765,9 +773,10 @@ rec {
         sha256 = "18780xgyag5acx79warcpvzlfkm0mni8xawl6jjvgxg9n3lp6zg0";
       };
       urlPrefix = mirror://fedora/linux/releases/9/Fedora/i386/os;
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora9x86_64 = args: makeImageFromRPMDist ({
+    fedora9x86_64 = {
       name = "fedora-9-x86_64";
       fullName = "Fedora 9 (x86_64)";
       packagesList = fetchurl {
@@ -776,9 +785,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/9/Fedora/x86_64/os;
       archs = ["noarch" "x86_64"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora10i386 = args: makeImageFromRPMDist ({
+    fedora10i386 = {
       name = "fedora-10-i386";
       fullName = "Fedora 10 (i386)";
       packagesList = fetchurl {
@@ -786,9 +796,10 @@ rec {
         sha256 = "15ha8pxzvlch707mpy06c7pkr2ra2vpd5b8x30qhydvx8fgcqcx9";
       };
       urlPrefix = mirror://fedora/linux/releases/10/Fedora/i386/os;
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora10x86_64 = args: makeImageFromRPMDist ({
+    fedora10x86_64 = {
       name = "fedora-10-x86_64";
       fullName = "Fedora 10 (x86_64)";
       packagesList = fetchurl {
@@ -797,9 +808,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/10/Fedora/x86_64/os;
       archs = ["noarch" "x86_64"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora11i386 = args: makeImageFromRPMDist ({
+    fedora11i386 = {
       name = "fedora-11-i386";
       fullName = "Fedora 11 (i386)";
       packagesList = fetchurl {
@@ -808,9 +820,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/11/Fedora/i386/os;
       archs = ["noarch" "i386" "i586"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora11x86_64 = args: makeImageFromRPMDist ({
+    fedora11x86_64 = {
       name = "fedora-11-x86_64";
       fullName = "Fedora 11 (x86_64)";
       packagesList = fetchurl {
@@ -819,9 +832,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/11/Fedora/x86_64/os;
       archs = ["noarch" "x86_64"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora12i386 = args: makeImageFromRPMDist ({
+    fedora12i386 = {
       name = "fedora-12-i386";
       fullName = "Fedora 12 (i386)";
       packagesList = fetchurl {
@@ -830,9 +844,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/12/Fedora/i386/os;
       archs = ["noarch" "i386" "i586" "i686"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora12x86_64 = args: makeImageFromRPMDist ({
+    fedora12x86_64 = {
       name = "fedora-12-x86_64";
       fullName = "Fedora 12 (x86_64)";
       packagesList = fetchurl {
@@ -841,9 +856,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/12/Fedora/x86_64/os;
       archs = ["noarch" "x86_64"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora13i386 = args: makeImageFromRPMDist ({
+    fedora13i386 = {
       name = "fedora-13-i386";
       fullName = "Fedora 13 (i386)";
       packagesList = fetchurl {
@@ -852,9 +868,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/13/Fedora/i386/os;
       archs = ["noarch" "i386" "i586" "i686"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    fedora13x86_64 = args: makeImageFromRPMDist ({
+    fedora13x86_64 = {
       name = "fedora-13-x86_64";
       fullName = "Fedora 13 (x86_64)";
       packagesList = fetchurl {
@@ -863,9 +880,10 @@ rec {
       };
       urlPrefix = mirror://fedora/linux/releases/13/Fedora/x86_64/os;
       archs = ["noarch" "x86_64"];
-    } // args);
+      packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ];
+    };
 
-    opensuse103i386 = args: makeImageFromRPMDist ({
+    opensuse103i386 = {
       name = "opensuse-10.3-i586";
       fullName = "openSUSE 10.3 (i586)";
       packagesList = fetchurl {
@@ -874,9 +892,10 @@ rec {
       };
       urlPrefix = mirror://opensuse/distribution/10.3/repo/oss/suse/;
       archs = ["noarch" "i586"];
-    } // args);
+      packages = commonOpenSUSEPackages ++ [ "devs" ];
+    };
 
-    opensuse110i386 = args: makeImageFromRPMDist ({
+    opensuse110i386 = {
       name = "opensuse-11.0-i586";
       fullName = "openSUSE 11.0 (i586)";
       packagesList = fetchurl {
@@ -885,9 +904,10 @@ rec {
       };
       urlPrefix = mirror://opensuse/distribution/11.0/repo/oss/suse/;
       archs = ["noarch" "i586"];
-    } // args);
+      packages = commonOpenSUSEPackages;
+    };
 
-    opensuse110x86_64 = args: makeImageFromRPMDist ({
+    opensuse110x86_64 = {
       name = "opensuse-11.0-x86_64";
       fullName = "openSUSE 11.0 (x86_64)";
       packagesList = fetchurl {
@@ -896,9 +916,10 @@ rec {
       };
       urlPrefix = mirror://opensuse/distribution/11.0/repo/oss/suse/;
       archs = ["noarch" "x86_64"];
-    } // args);
+      packages = commonOpenSUSEPackages;
+    };
 
-    opensuse111i386 = args: makeImageFromRPMDist ({
+    opensuse111i386 = {
       name = "opensuse-11.1-i586";
       fullName = "openSUSE 11.1 (i586)";
       packagesList = fetchurl {
@@ -907,9 +928,10 @@ rec {
       };
       urlPrefix = mirror://opensuse/distribution/11.1/repo/oss/suse/;
       archs = ["noarch" "i586"];
-    } // args);
+      packages = commonOpenSUSEPackages;
+    };
 
-    opensuse111x86_64 = args: makeImageFromRPMDist ({
+    opensuse111x86_64 = {
       name = "opensuse-11.1-x86_64";
       fullName = "openSUSE 11.1 (x86_64)";
       packagesList = fetchurl {
@@ -918,13 +940,21 @@ rec {
       };
       urlPrefix = mirror://opensuse/distribution/11.1/repo/oss/suse/;
       archs = ["noarch" "x86_64"];
-    } // args);
+      packages = commonOpenSUSEPackages;
+    };
+
+  };
 
+
+  /* The set of supported Dpkg-based distributions. */
+      
+  debDistros = {
+  
     # Interestingly, the SHA-256 hashes provided by Ubuntu in
     # http://nl.archive.ubuntu.com/ubuntu/dists/{gutsy,hardy}/Release are
     # wrong, but the SHA-1 and MD5 hashes are correct.  Intrepid is fine.
 
-    ubuntu710i386 = args: makeImageFromDebDist ({
+    ubuntu710i386 = {
       name = "ubuntu-7.10-gutsy-i386";
       fullName = "Ubuntu 7.10 Gutsy (i386)";
       packagesList = fetchurl {
@@ -932,9 +962,10 @@ rec {
         sha1 = "8b52ee3d417700e2b2ee951517fa25a8792cabfd";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebianPackages;
+    };
         
-    ubuntu804i386 = args: makeImageFromDebDist ({
+    ubuntu804i386 = {
       name = "ubuntu-8.04-hardy-i386";
       fullName = "Ubuntu 8.04 Hardy (i386)";
       packagesList = fetchurl {
@@ -942,9 +973,10 @@ rec {
         sha1 = "db74581ee75cb3bee2a8ae62364e97956c723259";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebianPackages;
+    };
          
-    ubuntu804x86_64 = args: makeImageFromDebDist ({
+    ubuntu804x86_64 = {
       name = "ubuntu-8.04-hardy-amd64";
       fullName = "Ubuntu 8.04 Hardy (amd64)";
       packagesList = fetchurl {
@@ -952,9 +984,10 @@ rec {
         sha1 = "d1f1d2b3cc62533d6e4337f2696a5d27235d1f28";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebianPackages;
+    };
          
-    ubuntu810i386 = args: makeImageFromDebDist ({
+    ubuntu810i386 = {
       name = "ubuntu-8.10-intrepid-i386";
       fullName = "Ubuntu 8.10 Intrepid (i386)";
       packagesList = fetchurl {
@@ -962,9 +995,10 @@ rec {
         sha256 = "70483d40a9e9b74598f2faede7df5d5103ee60055af7374f8db5c7e6017c4cf6";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebianPackages;
+    };
  
-    ubuntu810x86_64 = args: makeImageFromDebDist ({
+    ubuntu810x86_64 = {
       name = "ubuntu-8.10-intrepid-amd64";
       fullName = "Ubuntu 8.10 Intrepid (amd64)";
       packagesList = fetchurl {
@@ -972,9 +1006,10 @@ rec {
         sha256 = "01b2f3842cbdd5834446ddf91691bcf60f59a726dcefa23fb5b93fdc8ea7e27f";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebianPackages;
+    };
 
-    ubuntu904i386 = args: makeImageFromDebDist ({
+    ubuntu904i386 = {
       name = "ubuntu-9.04-jaunty-i386";
       fullName = "Ubuntu 9.04 Jaunty (i386)";
       packagesList = fetchurl {
@@ -982,9 +1017,10 @@ rec {
         sha256 = "72c95e4901ad56ce8791723e2ae40bce2399f306f9956cac80e964011e1948d0";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebianPackages;
+    };
  
-    ubuntu904x86_64 = args: makeImageFromDebDist ({
+    ubuntu904x86_64 = {
       name = "ubuntu-9.04-jaunty-amd64";
       fullName = "Ubuntu 9.04 Jaunty (amd64)";
       packagesList = fetchurl {
@@ -992,9 +1028,10 @@ rec {
         sha256 = "af760ce04e43f066b8938b1abdeff979a642f940515659ede44f7877ca358ca8";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebianPackages;
+    };
 
-    ubuntu910i386 = args: makeImageFromDebDist ({
+    ubuntu910i386 = {
       name = "ubuntu-9.10-karmic-i386";
       fullName = "Ubuntu 9.10 Karmic (i386)";
       packagesList = fetchurl {
@@ -1002,9 +1039,10 @@ rec {
         sha256 = "6e3e813857496f2af6cd7e6ada06b3398fa067a7992c5fd7e8bd8fa92e3548b7";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebPackages ++ [ "diff" ];
+    };
  
-    ubuntu910x86_64 = args: makeImageFromDebDist ({
+    ubuntu910x86_64 = {
       name = "ubuntu-9.10-karmic-amd64";
       fullName = "Ubuntu 9.10 Karmic (amd64)";
       packagesList = fetchurl {
@@ -1012,9 +1050,10 @@ rec {
         sha256 = "3a604fcb0c135eeb8b95da3e90a8fd4cfeff519b858cd3c9e62ea808cb9fec40";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebPackages ++ [ "diff" ];
+    };
 
-    ubuntu1004i386 = args: makeImageFromDebDist ({
+    ubuntu1004i386 = {
       name = "ubuntu-10.04-lucid-i386";
       fullName = "Ubuntu 10.04 Lucid (i386)";
       packagesList = fetchurl {
@@ -1022,9 +1061,10 @@ rec {
         sha256 = "0e46596202a68caa754dfe0883f46047525309880c492cdd5e2d0970fcf626aa";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebPackages ++ [ "diffutils" ];
+    };
  
-    ubuntu1004x86_64 = args: makeImageFromDebDist ({
+    ubuntu1004x86_64 = {
       name = "ubuntu-10.04-lucid-amd64";
       fullName = "Ubuntu 10.04 Lucid (amd64)";
       packagesList = fetchurl {
@@ -1032,9 +1072,10 @@ rec {
         sha256 = "74a8f3192b0eda397d65316e0fa6cd34d5358dced41639e07d9f1047971bfef0";
       };
       urlPrefix = mirror://ubuntu;
-    } // args);
+      packages = commonDebPackages ++ [ "diffutils" ];
+    };
 
-    debian40i386 = args: makeImageFromDebDist ({
+    debian40i386 = {
       name = "debian-4.0r9-etch-i386";
       fullName = "Debian 4.0r9 Etch (i386)";
       packagesList = fetchurl {
@@ -1042,9 +1083,10 @@ rec {
         sha256 = "40eeeecc35e6895b6eb0bc601e38fe53fc985d1b1f3fea3766f34763d21f206f";
       };
       urlPrefix = mirror://debian;
-    } // args);
+      packages = commonDebianPackages;
+    };
         
-    debian40x86_64 = args: makeImageFromDebDist ({
+    debian40x86_64 = {
       name = "debian-4.0r9-etch-amd64";
       fullName = "Debian 4.0r9 Etch (amd64)";
       packagesList = fetchurl {
@@ -1052,9 +1094,10 @@ rec {
         sha256 = "cf1c4c7d72e0da45797b046011254d2bd83f5ecb7389c7f30d2561be3f5b2e49";
       };
       urlPrefix = mirror://debian;
-    } // args);
+      packages = commonDebianPackages;
+    };
 
-    debian50i386 = args: makeImageFromDebDist ({
+    debian50i386 = {
       name = "debian-5.0.4-lenny-i386";
       fullName = "Debian 5.0.4 Lenny (i386)";
       packagesList = fetchurl {
@@ -1062,9 +1105,10 @@ rec {
         sha256 = "6c5ca67fb401a5d29f02557c290bbaee35c457172d548583b510d49eadd0f9ff";
       };
       urlPrefix = mirror://debian;
-    } // args);
+      packages = commonDebianPackages;
+    };
         
-    debian50x86_64 = args: makeImageFromDebDist ({
+    debian50x86_64 = {
       name = "debian-5.0.4-lenny-amd64";
       fullName = "Debian 5.0.4 Lenny (amd64)";
       packagesList = fetchurl {
@@ -1072,7 +1116,8 @@ rec {
         sha256 = "c3b660b861ed257e82293a350ab868c2ce566bc084d35cc66b7388a881eaf3c5";
       };
       urlPrefix = mirror://debian;
-    } // args);
+      packages = commonDebianPackages;
+    };
 
   };
 
@@ -1100,6 +1145,7 @@ rec {
     "unzip"
   ];
 
+  
   /* Common packages for openSUSE images. */
   commonOpenSUSEPackages = [
     "aaa_base"
@@ -1125,12 +1171,11 @@ rec {
 
 
   /* Common packages for Debian/Ubuntu images. */
-  commonDebianPackages = [
+  commonDebPackages = [
     "base-passwd"
     "dpkg"
     "libc6-dev"
     "perl"
-    "sysvinit"
     "bash"
     "dash"
     "gzip"
@@ -1142,7 +1187,6 @@ rec {
     "make"
     "curl"
     "patch"
-    "diff"
     "locales"
     # Needed by checkinstall:
     "util-linux" 
@@ -1156,23 +1200,43 @@ rec {
     "mktemp"
   ];
 
+  commonDebianPackages = commonDebPackages ++ [ "sysvinit" "diff" ];
+  
 
-  # Ubuntu 9.10 no longer has sysvinit.
-  karmicPackages = lib.filter (x: x != "sysvinit") commonDebianPackages;
+  /* A set of functions that build the Linux distributions specified
+     in `rpmDistros' and `debDistros'.  For instance,
+     `diskImageFuns.ubuntu1004x86_64 { }' builds an Ubuntu 10.04 disk
+     image containing the default packages specified above.  Overrides
+     of the default image parameters can be given.  In particular,
+     `extraPackages' specifies the names of additional packages from
+     the distribution that should be included in the image; `packages'
+     allows the entire set of packages to be overriden; and `size'
+     sets the size of the disk in megabytes.  E.g.,
+     `diskImageFuns.ubuntu1004x86_64 { extraPackages = ["firefox"];
+     size = 8192; }' builds an 8 GiB image containing Firefox in
+     addition to the default packages. */
+  diskImageFuns = 
+    (lib.mapAttrs (name: as: as2: makeImageFromRPMDist (as // as2)) rpmDistros) //
+    (lib.mapAttrs (name: as: as2: makeImageFromDebDist (as // as2)) debDistros);
 
-  lucidPackages = (lib.filter (x: x != "sysvinit" && x != "diff") commonDebianPackages) ++ [ "diffutils" ];
-  
+    
+  /* Shorthand for `diskImageFuns.<attr> { extraPackages = ... }'. */
+  diskImageExtraFuns =
+    lib.mapAttrs (name: f: extraPackages: f { inherit extraPackages; }) diskImageFuns;
 
-  /* A bunch of disk images. */
+    
+  /* Default disk images generated from the `rpmDistros' and
+     `debDistros' sets (along with Red Hat 9 and SuSE 9.0 images). */
 
   diskImages =
-
+    lib.mapAttrs (name: f: f {}) diskImageFuns //
+    
     { redhat9i386 = fillDiskWithRPMs {
         name = "redhat-9-i386";
         fullName = "Red Hat Linux 9 (i386)";
         size = 1024;
         rpms = import ./rpm/redhat-9-i386.nix {inherit fetchurl;};
-     };
+      };
     
       suse90i386 = fillDiskWithRPMs {
         name = "suse-9.0-i386";
@@ -1193,47 +1257,7 @@ rec {
           echo 'video:x:33:' >> /mnt/etc/group
         '';
       };
-
-    } // lib.mapAttrs (name: f: f []) diskImageExtraFuns;
+      
+    };
     
-
-  diskImageExtraFuns = {
-    fedora2i386 = extraVirtualPackages : diskImageFuns.fedora2i386 { packages = commonFedoraPackages ++ extraVirtualPackages; };
-    fedora3i386 = extraVirtualPackages : diskImageFuns.fedora3i386 { packages = commonFedoraPackages ++ extraVirtualPackages; };
-    fedora5i386 = extraVirtualPackages : diskImageFuns.fedora5i386 { packages = commonFedoraPackages ++ ["util-linux"] ++ extraVirtualPackages; };
-    fedora7i386 = extraVirtualPackages : diskImageFuns.fedora7i386 { packages = commonFedoraPackages ++ extraVirtualPackages; };
-    fedora8i386 = extraVirtualPackages : diskImageFuns.fedora8i386 { packages = commonFedoraPackages ++ extraVirtualPackages; };
-    fedora9i386 = extraVirtualPackages : diskImageFuns.fedora9i386 { packages = commonFedoraPackages       ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora9x86_64 = extraVirtualPackages : diskImageFuns.fedora9x86_64 { packages = commonFedoraPackages   ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora10i386 = extraVirtualPackages : diskImageFuns.fedora10i386 { packages = commonFedoraPackages     ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora10x86_64 = extraVirtualPackages : diskImageFuns.fedora10x86_64 { packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora11i386 = extraVirtualPackages : diskImageFuns.fedora11i386 { packages = commonFedoraPackages     ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora11x86_64 = extraVirtualPackages : diskImageFuns.fedora11x86_64 { packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora12i386 = extraVirtualPackages : diskImageFuns.fedora12i386 { packages = commonFedoraPackages     ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora12x86_64 = extraVirtualPackages : diskImageFuns.fedora12x86_64 { packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora13i386 = extraVirtualPackages : diskImageFuns.fedora13i386 { packages = commonFedoraPackages     ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    fedora13x86_64 = extraVirtualPackages : diskImageFuns.fedora13x86_64 { packages = commonFedoraPackages ++ [ "cronie" "util-linux-ng" ] ++ extraVirtualPackages; };
-    opensuse103i386 = extraVirtualPackages : diskImageFuns.opensuse103i386 { packages = commonOpenSUSEPackages ++ ["devs"] ++ extraVirtualPackages; };
-    opensuse110i386 = extraVirtualPackages : diskImageFuns.opensuse110i386 { packages = commonOpenSUSEPackages ++ extraVirtualPackages; };
-    opensuse110x86_64 = extraVirtualPackages : diskImageFuns.opensuse110x86_64 { packages = commonOpenSUSEPackages ++ extraVirtualPackages; };
-    opensuse111i386 = extraVirtualPackages : diskImageFuns.opensuse111i386 { packages = commonOpenSUSEPackages ++ extraVirtualPackages; };
-    opensuse111x86_64 = extraVirtualPackages : diskImageFuns.opensuse111x86_64 { packages = commonOpenSUSEPackages ++ extraVirtualPackages; };
-
-    ubuntu710i386 = extraVirtualPackages : diskImageFuns.ubuntu710i386 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    ubuntu804i386 = extraVirtualPackages : diskImageFuns.ubuntu804i386 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    ubuntu804x86_64 = extraVirtualPackages : diskImageFuns.ubuntu804x86_64 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    ubuntu810i386 = extraVirtualPackages : diskImageFuns.ubuntu810i386 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    ubuntu810x86_64 = extraVirtualPackages : diskImageFuns.ubuntu810x86_64 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    ubuntu904i386 = extraVirtualPackages : diskImageFuns.ubuntu904i386 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    ubuntu904x86_64 = extraVirtualPackages : diskImageFuns.ubuntu904x86_64 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    ubuntu910i386 = extraVirtualPackages : diskImageFuns.ubuntu910i386 { packages = karmicPackages ++ extraVirtualPackages; };
-    ubuntu910x86_64 = extraVirtualPackages : diskImageFuns.ubuntu910x86_64 { packages = karmicPackages ++ extraVirtualPackages; };
-    ubuntu1004i386 = extraVirtualPackages : diskImageFuns.ubuntu1004i386 { packages = lucidPackages ++ extraVirtualPackages; };
-    ubuntu1004x86_64 = extraVirtualPackages : diskImageFuns.ubuntu1004x86_64 { packages = lucidPackages ++ extraVirtualPackages; };
-    debian40i386 = extraVirtualPackages : diskImageFuns.debian40i386 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    debian40x86_64 = extraVirtualPackages : diskImageFuns.debian40x86_64 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    debian50i386 = extraVirtualPackages : diskImageFuns.debian50i386 { packages = commonDebianPackages ++ extraVirtualPackages; };
-    debian50x86_64 = extraVirtualPackages : diskImageFuns.debian50x86_64 { packages = commonDebianPackages ++ extraVirtualPackages; };
-  };
-
 }