Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 rpmextract, 6}: 7 8stdenv.mkDerivation rec { 9 pname = "libsane-dsseries"; 10 version = "1.0.5-1"; 11 12 src = fetchurl { 13 url = "https://download.brother.com/welcome/dlf100974/${pname}-${version}.x86_64.rpm"; 14 sha256 = "1wfdbfbf51cc7njzikdg48kwpnpc0pg5s6p0s0y3z0q7y59x2wbq"; 15 }; 16 17 nativeBuildInputs = [ rpmextract ]; 18 19 unpackCmd = '' 20 mkdir ${pname}-${version} && pushd ${pname}-${version} 21 rpmextract $curSrc 22 popd 23 ''; 24 25 patchPhase = '' 26 substituteInPlace etc/udev/rules.d/50-Brother_DSScanner.rules \ 27 --replace 'GROUP="users"' 'GROUP="scanner", ENV{libsane_matched}="yes"' 28 29 mkdir -p etc/sane.d/dll.d 30 echo "dsseries" > etc/sane.d/dll.d/dsseries.conf 31 ''; 32 33 installPhase = '' 34 mkdir -p $out 35 cp -dr etc $out 36 cp -dr usr/lib64 $out/lib 37 ''; 38 39 preFixup = '' 40 for f in `find $out/lib/sane/ -type f`; do 41 # Make it possible to find libstdc++.so.6 42 patchelf --set-rpath ${lib.getLib stdenv.cc.cc}/lib:$out/lib/sane $f 43 44 # Horrible kludge: The driver hardcodes /usr/lib/sane/ as a dlopen path. 45 # We can directly modify the binary to force a relative lookup instead. 46 # The new path is NULL-padded to the same length as the original path. 47 sed -i "s|/usr/lib/sane/%s|%s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|g" $f 48 done 49 ''; 50 51 meta = { 52 description = "Brother DSSeries SANE backend driver"; 53 homepage = "http://www.brother.com"; 54 platforms = lib.platforms.linux; 55 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 56 license = lib.licenses.unfree; 57 maintainers = with lib.maintainers; [ callahad ]; 58 }; 59}