infra/nix/pkgs/mfcl3770cdw.nix

87 lines
2.7 KiB
Nix
Raw Normal View History

2023-02-07 18:24:28 +01:00
{
pkgsi686Linux,
stdenv,
fetchurl,
dpkg,
makeWrapper,
coreutils,
ghostscript,
gnugrep,
gnused,
which,
perl,
lib,
}: let
2019-01-26 12:19:05 +01:00
model = "mfcl3770cdw";
version = "1.0.2-0";
src = fetchurl {
2023-02-07 18:24:28 +01:00
url = "https://download.brother.com/welcome/dlf103935/${model}pdrv-${version}.i386.deb";
2019-01-26 12:19:05 +01:00
sha256 = "09fhbzhpjymhkwxqyxzv24b06ybmajr6872yp7pri39595mhrvay";
};
reldir = "opt/brother/Printers/${model}/";
2022-10-31 11:04:38 +01:00
in rec {
2019-01-26 12:19:05 +01:00
driver = stdenv.mkDerivation rec {
inherit src version;
name = "${model}drv-${version}";
2023-02-07 18:24:28 +01:00
nativeBuildInputs = [dpkg makeWrapper];
2019-01-26 12:19:05 +01:00
unpackPhase = "dpkg-deb -x $src $out";
installPhase = ''
2022-10-31 11:04:38 +01:00
dir="$out/${reldir}"
substituteInPlace $dir/lpd/filter_${model} \
--replace /usr/bin/perl ${perl}/bin/perl \
--replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$dir\"; #" \
--replace "PRINTER =~" "PRINTER = \"${model}\"; #"
wrapProgram $dir/lpd/filter_${model} \
--prefix PATH : ${
2023-02-07 18:24:28 +01:00
lib.makeBinPath [coreutils ghostscript gnugrep gnused which]
}
2022-10-31 11:04:38 +01:00
# need to use i686 glibc here, these are 32bit proprietary binaries
interpreter=${pkgsi686Linux.glibc}/lib/ld-linux.so.2
patchelf --set-interpreter "$interpreter" $dir/lpd/brmfcl3770cdwfilter
2019-01-26 12:19:05 +01:00
'';
meta = {
description = "Brother ${lib.strings.toUpper model} driver";
2022-10-31 11:04:38 +01:00
homepage = "http://www.brother.com/";
2021-06-08 12:39:01 +02:00
license = lib.licenses.unfree;
2023-02-07 18:24:28 +01:00
platforms = ["x86_64-linux" "i686-linux"];
maintainers = [lib.maintainers.steveej];
2019-01-26 12:19:05 +01:00
};
};
cupswrapper = stdenv.mkDerivation rec {
inherit version src;
name = "${model}cupswrapper-${version}";
2023-02-07 18:24:28 +01:00
nativeBuildInputs = [dpkg makeWrapper];
2019-01-26 12:19:05 +01:00
unpackPhase = "dpkg-deb -x $src $out";
installPhase = ''
basedir=${driver}/${reldir}
dir=$out/${reldir}
substituteInPlace $dir/cupswrapper/brother_lpdwrapper_${model} \
--replace /usr/bin/perl ${perl}/bin/perl \
--replace "basedir =~" "basedir = \"$basedir\"; #" \
--replace "PRINTER =~" "PRINTER = \"${model}\"; #"
wrapProgram $dir/cupswrapper/brother_lpdwrapper_${model} \
2023-02-07 18:24:28 +01:00
--prefix PATH : ${lib.makeBinPath [coreutils gnugrep gnused]}
2019-01-26 12:19:05 +01:00
mkdir -p $out/lib/cups/filter
mkdir -p $out/share/cups/model
ln $dir/cupswrapper/brother_lpdwrapper_${model} $out/lib/cups/filter
ln $dir/cupswrapper/brother_${model}_printer_en.ppd $out/share/cups/model
'';
meta = {
description = "Brother ${lib.strings.toUpper model} CUPS wrapper driver";
2022-10-31 11:04:38 +01:00
homepage = "http://www.brother.com/";
2021-06-08 12:39:01 +02:00
license = lib.licenses.gpl2;
2023-02-07 18:24:28 +01:00
platforms = ["x86_64-linux" "i686-linux"];
maintainers = [lib.maintainers.steveej];
2019-01-26 12:19:05 +01:00
};
};
}