From 3a201ef6a78cfcd6a98a1c136543fd38711dbbbe Mon Sep 17 00:00:00 2001
From: Shea Levy <shea@shealevy.com>
Date: Wed, 28 Sep 2011 22:43:53 +0000
Subject: [PATCH] Enable building ISOs for aufs3 kernels

svn path=/nixos/trunk/; revision=29538
---
 modules/installer/cd-dvd/iso-image.nix | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/installer/cd-dvd/iso-image.nix b/modules/installer/cd-dvd/iso-image.nix
index d565435ffd2..daeebde76cf 100644
--- a/modules/installer/cd-dvd/iso-image.nix
+++ b/modules/installer/cd-dvd/iso-image.nix
@@ -154,12 +154,15 @@ in
   # We need squashfs in the initrd to mount the compressed Nix store,
   # and aufs to make the root filesystem appear writable.
   boot.extraModulePackages =
-    optional
-      (! ( config.boot.kernelPackages.kernel.features ? aufs || config.boot.kernelPackages.kernel.features ? aufs2_1 ) )
+    let features = config.boot.kernelPackages.kernel.features; in
+
+    pkgs.stdenv.lib.singleton (if features ? aufs2 && features.aufs2 then
       config.boot.kernelPackages.aufs2
-    ++ optional
-      ( config.boot.kernelPackages.kernel.features ? aufs2_1 )
-      config.boot.kernelPackages.aufs2_1;
+    else if features ? aufs2_1 && features.aufs2_1 then
+      config.boot.kernelPackages.aufs2_1
+    else if features ? aufs3 && features.aufs3 then
+      config.boot.kernelPackages.aufs3
+    else abort "This kernel doesn't have aufs enabled");
 
   boot.initrd.availableKernelModules = [ "aufs" "squashfs" "iso9660" ];