summary refs log tree commit diff
path: root/pkgs/misc/drivers
diff options
context:
space:
mode:
authorLuca Bruno <lethalman88@gmail.com>2015-11-25 21:31:09 +0100
committerLuca Bruno <lethalman88@gmail.com>2015-11-25 21:37:30 +0100
commita41292792498e03024d682d092947c2153290073 (patch)
treeb937402b60ea79cfa0e5562dad3268127a491d81 /pkgs/misc/drivers
parent8a664fd5bc6b170bdf809030de6871fd6a454f5a (diff)
parentb34a6c96ee14518b82648c5a8c1b29225c15d9df (diff)
downloadnixlib-a41292792498e03024d682d092947c2153290073.tar
nixlib-a41292792498e03024d682d092947c2153290073.tar.gz
nixlib-a41292792498e03024d682d092947c2153290073.tar.bz2
nixlib-a41292792498e03024d682d092947c2153290073.tar.lz
nixlib-a41292792498e03024d682d092947c2153290073.tar.xz
nixlib-a41292792498e03024d682d092947c2153290073.tar.zst
nixlib-a41292792498e03024d682d092947c2153290073.zip
Merge remote-tracking branch 'origin/master' into closure-size
Diffstat (limited to 'pkgs/misc/drivers')
-rw-r--r--pkgs/misc/drivers/hplip/default.nix57
1 files changed, 32 insertions, 25 deletions
diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix
index e381ea6b3e3a..04ebb7a55ee9 100644
--- a/pkgs/misc/drivers/hplip/default.nix
+++ b/pkgs/misc/drivers/hplip/default.nix
@@ -1,7 +1,9 @@
-{ stdenv, fetchurl, automake, pkgconfig
+{ stdenv, fetchurl, substituteAll
+, pkgconfig
 , cups, zlib, libjpeg, libusb1, pythonPackages, saneBackends, dbus, usbutils
-, polkit, qtSupport ? true, qt4, pyqt4, net_snmp
-, withPlugin ? false, substituteAll, makeWrapper
+, net_snmp, polkit
+, qtSupport ? true, qt4, pyqt4
+, withPlugin ? false
 }:
 
 let
@@ -20,25 +22,31 @@ let
     sha256 = "1ahalw83xm8x0h6hljhnkknry1hny9flkrlzcymv8nmwgic0kjgs";
   };
 
-  hplip_state =
+  hplipState =
     substituteAll
       {
         inherit version;
         src = ./hplip.state;
       };
 
-  hplip_arch =
+  hplipPlatforms =
     {
-      "i686-linux" = "x86_32";
+      "i686-linux"   = "x86_32";
       "x86_64-linux" = "x86_64";
-      "arm6l-linux" = "arm32";
-      "arm7l-linux" = "arm32";
-    }."${stdenv.system}" or (abort "Unsupported platform ${stdenv.system}");
+      "armv6l-linux" = "arm32";
+      "armv7l-linux" = "arm32";
+    };
 
-    platforms = [ "i686-linux" "x86_64-linux" "armv6l-linux" "armv7l-linux" ];
+  hplipArch = hplipPlatforms."${stdenv.system}"
+    or (throw "HPLIP not supported on ${stdenv.system}");
+
+  pluginArches = [ "x86_32" "x86_64" ];
 
 in
 
+assert withPlugin -> builtins.elem hplipArch pluginArches
+  || throw "HPLIP plugin not supported on ${stdenv.system}";
+
 stdenv.mkDerivation {
   inherit name src;
 
@@ -51,7 +59,10 @@ stdenv.mkDerivation {
     saneBackends
     dbus
     net_snmp
-  ] ++ stdenv.lib.optional qtSupport qt4;
+  ] ++ stdenv.lib.optionals qtSupport [
+    qt4
+  ];
+
   nativeBuildInputs = [
     pkgconfig
   ];
@@ -63,7 +74,9 @@ stdenv.mkDerivation {
     recursivePthLoader
     reportlab
     usbutils
-  ] ++ stdenv.lib.optional qtSupport pyqt4;
+  ] ++ stdenv.lib.optionals qtSupport [
+    pyqt4
+  ];
 
   prePatch = ''
     # HPLIP hardcodes absolute paths everywhere. Nuke from orbit.
@@ -100,13 +113,7 @@ stdenv.mkDerivation {
 
   enableParallelBuilding = true;
 
-  postInstall =
-    (stdenv.lib.optionalString (withPlugin && builtins.elem stdenv.system platforms)
-    (let hplip_arch =
-          if stdenv.system == "i686-linux" then "x86_32"
-          else if stdenv.system == "x86_64-linux" then "x86_64"
-          else abort "Plugin platform must be i686-linux or x86_64-linux!";
-    in
+  postInstall = stdenv.lib.optionalString withPlugin
     ''
     sh ${plugin} --noexec --keep
     cd plugin_tmp
@@ -121,26 +128,26 @@ stdenv.mkDerivation {
 
     mkdir -p $out/share/hplip/prnt/plugins
     for plugin in lj hbpl1; do
-      cp $plugin-${hplip_arch}.so $out/share/hplip/prnt/plugins
-      ln -s $out/share/hplip/prnt/plugins/$plugin-${hplip_arch}.so \
+      cp $plugin-${hplipArch}.so $out/share/hplip/prnt/plugins
+      ln -s $out/share/hplip/prnt/plugins/$plugin-${hplipArch}.so \
         $out/share/hplip/prnt/plugins/$plugin.so
     done
 
     mkdir -p $out/share/hplip/scan/plugins
     for plugin in bb_soap bb_marvell bb_soapht fax_marvell; do
-      cp $plugin-${hplip_arch}.so $out/share/hplip/scan/plugins
-      ln -s $out/share/hplip/scan/plugins/$plugin-${hplip_arch}.so \
+      cp $plugin-${hplipArch}.so $out/share/hplip/scan/plugins
+      ln -s $out/share/hplip/scan/plugins/$plugin-${hplipArch}.so \
         $out/share/hplip/scan/plugins/$plugin.so
     done
 
     mkdir -p $out/var/lib/hp
-    cp ${hplip_state} $out/var/lib/hp/hplip.state
+    cp ${hplipState} $out/var/lib/hp/hplip.state
 
     mkdir -p $out/etc/sane.d/dll.d
     mv $out/etc/sane.d/dll.conf $out/etc/sane.d/dll.d/hpaio.conf
 
     rm $out/etc/udev/rules.d/56-hpmud.rules
-  ''));
+  '';
 
   fixupPhase = ''
     # Wrap the user-facing Python scripts in $out/bin without turning the