summary refs log tree commit diff
path: root/pkgs/tools/misc/grub
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-05-03 19:59:47 -0500
committerWilliam A. Kennington III <william@wkennington.com>2014-08-28 13:35:37 -0700
commitdd18e67cfb27515791620a0e69e4e427b77e2670 (patch)
tree00cef18d074596f4325cf10113d94c0a942e8fd4 /pkgs/tools/misc/grub
parent2ea1433b77755b954df979307525fa6578f241b8 (diff)
downloadnixlib-dd18e67cfb27515791620a0e69e4e427b77e2670.tar
nixlib-dd18e67cfb27515791620a0e69e4e427b77e2670.tar.gz
nixlib-dd18e67cfb27515791620a0e69e4e427b77e2670.tar.bz2
nixlib-dd18e67cfb27515791620a0e69e4e427b77e2670.tar.lz
nixlib-dd18e67cfb27515791620a0e69e4e427b77e2670.tar.xz
nixlib-dd18e67cfb27515791620a0e69e4e427b77e2670.tar.zst
nixlib-dd18e67cfb27515791620a0e69e4e427b77e2670.zip
grub: Cleanup efi support
Diffstat (limited to 'pkgs/tools/misc/grub')
-rw-r--r--pkgs/tools/misc/grub/2.0x.nix37
1 files changed, 18 insertions, 19 deletions
diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix
index 2c150f8ec96f..028ec5657529 100644
--- a/pkgs/tools/misc/grub/2.0x.nix
+++ b/pkgs/tools/misc/grub/2.0x.nix
@@ -1,15 +1,20 @@
 { stdenv, fetchurl, autogen, flex, bison, python, autoconf, automake
 , gettext, ncurses, libusb, freetype, qemu, devicemapper
 , linuxPackages ? null
-, EFIsupport ? false
+, efiSupport ? false
 , zfsSupport ? false
 }:
 
-assert zfsSupport -> linuxPackages != null && linuxPackages.zfs != null;
-
+with stdenv.lib;
 let
+  efiSystems = {
+    "i686-linux".target = "i386";
+    "x86_64-linux".target = "x86_64";
+  };
 
-  prefix = "grub${if EFIsupport then "-efi" else ""}";
+  canEfi = any (system: stdenv.system == system) (mapAttrsToList (name: _: name) efiSystems);
+
+  prefix = "grub${if efiSupport then "-efi" else ""}";
 
   version = "2.02-beta2";
 
@@ -17,8 +22,10 @@ let
     url = "http://unifoundry.com/unifont-5.1.20080820.bdf.gz";
     sha256 = "0s0qfff6n6282q28nwwblp5x295zd6n71kl43xj40vgvdqxv0fxx";
   };
+in (
 
-in
+assert efiSupport -> canEfi;
+assert zfsSupport -> linuxPackages != null && linuxPackages.zfs != null;
 
 stdenv.mkDerivation rec {
   name = "${prefix}-${version}";
@@ -31,8 +38,8 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ autogen flex bison python autoconf automake ];
   buildInputs = [ ncurses libusb freetype gettext devicemapper ]
-    ++ stdenv.lib.optional doCheck qemu
-    ++ stdenv.lib.optional zfsSupport linuxPackages.zfs;
+    ++ optional doCheck qemu
+    ++ optional zfsSupport linuxPackages.zfs;
 
   preConfigure =
     '' for i in "tests/util/"*.in
@@ -62,13 +69,8 @@ stdenv.mkDerivation rec {
 
   patches = [ ./fix-bash-completion.patch ];
 
-  configureFlags =
-    let arch = if stdenv.system == "i686-linux" then "i386"
-               else if stdenv.system == "x86_64-linux" then "x86_64"
-               else throw "unsupported EFI firmware architecture";
-    in stdenv.lib.optional zfsSupport "--enable-libzfs"
-      ++ stdenv.lib.optionals EFIsupport
-        [ "--with-platform=efi" "--target=${arch}" "--program-prefix=" ];
+  configureFlags = optional zfsSupport "--enable-libzfs"
+    ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystems.${stdenv.system}.target}" "--program-prefix=" ];
 
   doCheck = false;
   enableParallelBuilding = true;
@@ -96,9 +98,6 @@ stdenv.mkDerivation rec {
 
     license = licenses.gpl3Plus;
 
-    platforms = if EFIsupport then
-      [ "i686-linux" "x86_64-linux" ]
-    else
-      platforms.gnu;
+    platforms = platforms.gnu;
   };
-}
+})