summary refs log tree commit diff
path: root/pkgs/applications/graphics
diff options
context:
space:
mode:
authorRyan Mulligan <ryan@ryantm.com>2019-03-14 21:17:31 -0700
committerGitHub <noreply@github.com>2019-03-14 21:17:31 -0700
commit4b6a41a939faf6d224d593af68f305fdb69b6ddc (patch)
tree86649d7459c070438050b459220970b6498c6b94 /pkgs/applications/graphics
parente59fe2084719a0db3d5dce896e42d2d4e8dbb746 (diff)
parentc80385d93469aeb2d4134ef0056cea330c48c251 (diff)
downloadnixpkgs-4b6a41a939faf6d224d593af68f305fdb69b6ddc.tar
nixpkgs-4b6a41a939faf6d224d593af68f305fdb69b6ddc.tar.gz
nixpkgs-4b6a41a939faf6d224d593af68f305fdb69b6ddc.tar.bz2
nixpkgs-4b6a41a939faf6d224d593af68f305fdb69b6ddc.tar.lz
nixpkgs-4b6a41a939faf6d224d593af68f305fdb69b6ddc.tar.xz
nixpkgs-4b6a41a939faf6d224d593af68f305fdb69b6ddc.tar.zst
nixpkgs-4b6a41a939faf6d224d593af68f305fdb69b6ddc.zip
Merge pull request #57077 from callahad/brother-dsseries
dsseries: init at 1.0.5-1
Diffstat (limited to 'pkgs/applications/graphics')
-rw-r--r--pkgs/applications/graphics/sane/backends/dsseries/default.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/pkgs/applications/graphics/sane/backends/dsseries/default.nix b/pkgs/applications/graphics/sane/backends/dsseries/default.nix
new file mode 100644
index 00000000000..01c203b407c
--- /dev/null
+++ b/pkgs/applications/graphics/sane/backends/dsseries/default.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchurl, rpmextract }:
+
+stdenv.mkDerivation rec {
+  name = "libsane-dsseries-${version}";
+  version = "1.0.5-1";
+
+  src = fetchurl {
+    url = "https://download.brother.com/welcome/dlf100974/${name}.x86_64.rpm";
+    sha256 = "1wfdbfbf51cc7njzikdg48kwpnpc0pg5s6p0s0y3z0q7y59x2wbq";
+  };
+
+  nativeBuildInputs = [ rpmextract ];
+
+  unpackCmd = ''
+    mkdir ${name} && pushd ${name}
+    rpmextract $curSrc
+    popd
+  '';
+
+  patchPhase = ''
+    substituteInPlace etc/udev/rules.d/50-Brother_DSScanner.rules \
+      --replace 'GROUP="users"' 'GROUP="scanner", ENV{libsane_matched}="yes"'
+
+    mkdir -p etc/sane.d/dll.d
+    echo "dsseries" > etc/sane.d/dll.d/dsseries.conf
+  '';
+
+  installPhase = ''
+    mkdir -p $out
+    cp -dr etc $out
+    cp -dr usr/lib64 $out/lib
+  '';
+
+  preFixup = ''
+    for f in `find $out/lib/sane/ -type f`; do
+      # Make it possible to find libstdc++.so.6
+      patchelf --set-rpath ${stdenv.cc.cc.lib}/lib:$out/lib/sane $f
+
+      # Horrible kludge: The driver hardcodes /usr/lib/sane/ as a dlopen path.
+      # We can directly modify the binary to force a relative lookup instead.
+      # The new path is NULL-padded to the same length as the original path.
+      sed -i "s|/usr/lib/sane/%s|%s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|g" $f
+    done
+  '';
+
+  meta = {
+    description = "Brother DSSeries SANE backend driver";
+    homepage = http://www.brother.com;
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.unfree;
+    maintainers = with stdenv.lib.maintainers; [ callahad ];
+  };
+}