texstudio: 4.8.4 -> 4.8.5 (#365076)
[NixPkgs.git] / pkgs / misc / cups / drivers / hll3230cdw / default.nix
blob3e7893b36cf84e4bb047bbc5a6c962c658108d8f
2   stdenv,
3   lib,
4   fetchurl,
5   perl,
6   gnused,
7   dpkg,
8   makeWrapper,
9   autoPatchelfHook,
10   libredirect,
13 stdenv.mkDerivation rec {
14   pname = "cups-brother-hll3230cdw";
15   version = "1.0.2";
16   src = fetchurl {
17     url = "https://download.brother.com/welcome/dlf103925/hll3230cdwpdrv-${version}-0.i386.deb";
18     sha256 = "9d49abc584bf22bc381510618a34107ead6ab14562b51831fefd6009947aa5a9";
19   };
21   nativeBuildInputs = [
22     dpkg
23     makeWrapper
24     autoPatchelfHook
25   ];
27   buildInputs = [
28     perl
29     gnused
30     libredirect
31   ];
33   unpackPhase = "dpkg-deb -x $src .";
35   installPhase = ''
36     runHook preInstall
38     mkdir -p "$out"
39     cp -pr opt "$out"
40     cp -pr usr/bin "$out/bin"
41     rm "$out/opt/brother/Printers/hll3230cdw/cupswrapper/cupswrapperhll3230cdw"
43     mkdir -p "$out/lib/cups/filter" "$out/share/cups/model"
45     ln -s "$out/opt/brother/Printers/hll3230cdw/cupswrapper/brother_lpdwrapper_hll3230cdw" \
46       "$out/lib/cups/filter/brother_lpdwrapper_hll3230cdw"
47     ln -s "$out/opt/brother/Printers/hll3230cdw/cupswrapper/brother_hll3230cdw_printer_en.ppd" \
48       "$out/share/cups/model/brother_hll3230cdw_printer_en.ppd"
50     runHook postInstall
51   '';
53   # Fix global references and replace auto discovery mechanism
54   # with hardcoded values.
55   #
56   # The configuration binary 'brprintconf_hll3230cdw' and lpd filter
57   # 'brhll3230cdwfilter' has hardcoded /opt format strings.  There isn't
58   # sufficient space in the binaries to substitute a path in the store, so use
59   # libredirect to get it to see the correct path.  The configuration binary
60   # also uses this format string to print configuration locations.  Here the
61   # wrapper output is processed to point into the correct location in the
62   # store.
64   postFixup = ''
65     substituteInPlace $out/opt/brother/Printers/hll3230cdw/lpd/filter_hll3230cdw \
66       --replace "my \$BR_PRT_PATH =" "my \$BR_PRT_PATH = \"$out/opt/brother/Printers/hll3230cdw/\"; #" \
67       --replace "PRINTER =~" "PRINTER = \"hll3230cdw\"; #"
69     substituteInPlace $out/opt/brother/Printers/hll3230cdw/cupswrapper/brother_lpdwrapper_hll3230cdw \
70       --replace "PRINTER =~" "PRINTER = \"hll3230cdw\"; #" \
71       --replace "my \$basedir = \`readlink \$0\`" "my \$basedir = \"$out/opt/brother/Printers/hll3230cdw/\""
73     wrapProgram $out/bin/brprintconf_hll3230cdw \
74       --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
75       --set NIX_REDIRECTS /opt=$out/opt
77     wrapProgram $out/opt/brother/Printers/hll3230cdw/lpd/brhll3230cdwfilter \
78       --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \
79       --set NIX_REDIRECTS /opt=$out/opt
81     substituteInPlace $out/bin/brprintconf_hll3230cdw \
82       --replace \"\$"@"\" \"\$"@\" | LD_PRELOAD= ${gnused}/bin/sed -E '/^(function list :|resource file :).*/{s#/opt#$out/opt#}'"
83   '';
85   meta = with lib; {
86     description = "Brother HL-L3230CDW printer driver";
87     license = licenses.unfree;
88     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
89     maintainers = with maintainers; [ aplund ];
90     platforms = [
91       "x86_64-linux"
92       "i686-linux"
93     ];
94     homepage = "http://www.brother.com/";
95     downloadPage = "https://support.brother.com/g/b/downloadend.aspx?c=us&lang=en&prod=hll3230cdw_us_eu_as&os=128&dlid=dlf103925_000&flang=4&type3=10283";
96   };