2023-04-25 22:06:14 +02:00
|
|
|
{
|
|
|
|
pkgsi686Linux,
|
|
|
|
stdenv,
|
|
|
|
fetchurl,
|
|
|
|
dpkg,
|
|
|
|
makeWrapper,
|
|
|
|
coreutils,
|
|
|
|
ghostscript,
|
|
|
|
gnugrep,
|
|
|
|
gnused,
|
|
|
|
which,
|
|
|
|
lib,
|
|
|
|
cups,
|
|
|
|
a2ps,
|
|
|
|
gawk,
|
|
|
|
file,
|
|
|
|
proot,
|
|
|
|
bash,
|
2024-11-15 10:17:56 +01:00
|
|
|
}:
|
|
|
|
let
|
2023-04-25 22:06:14 +02:00
|
|
|
model = "dcpj4110dw";
|
|
|
|
version = "3.0.1-1";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://download.brother.com/welcome/dlf005595/${model}lpr-${version}.i386.deb";
|
|
|
|
sha256 = "sha256-ryKDsSkabAD2X3WLmeqjdB3+4DXdJ0qUz3O64DV+ixw=";
|
|
|
|
};
|
|
|
|
reldir = "opt/brother/Printers/${model}/";
|
2024-11-15 10:17:56 +01:00
|
|
|
in
|
|
|
|
rec {
|
2023-04-25 22:06:14 +02:00
|
|
|
driver = pkgsi686Linux.stdenv.mkDerivation rec {
|
|
|
|
inherit src version;
|
|
|
|
name = "${model}drv-${version}";
|
|
|
|
|
2024-11-15 10:17:56 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
dpkg
|
|
|
|
makeWrapper
|
|
|
|
];
|
2023-04-25 22:06:14 +02:00
|
|
|
|
|
|
|
unpackPhase = "dpkg-deb -x $src $out";
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
# need to use i686 glibc here, these are 32bit proprietary binaries
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
|
|
|
$out/${reldir}/lpd/br${model}filter
|
|
|
|
|
|
|
|
mkdir -p $out/lib/cups/filter/
|
|
|
|
ln -s $out/${reldir}/lpd/filter${model} $out/lib/cups/filter/brother_lpdwrapper_${model}
|
|
|
|
|
|
|
|
# use proot to bind /opt for the filter
|
|
|
|
mv $out/${reldir}/lpd/filter${model} $out/${reldir}/lpd/.wrapped_filter${model}
|
|
|
|
|
|
|
|
cat <<-EOF >$out/${reldir}/lpd/.wrapper_inner_filter${model}
|
2024-11-15 10:17:56 +01:00
|
|
|
export PATH=\$PATH:${
|
|
|
|
lib.makeBinPath [
|
|
|
|
gawk
|
|
|
|
file
|
|
|
|
a2ps
|
|
|
|
coreutils
|
|
|
|
ghostscript
|
|
|
|
gnugrep
|
|
|
|
gnused
|
|
|
|
which
|
|
|
|
]
|
|
|
|
}
|
2023-04-25 22:06:14 +02:00
|
|
|
exec $out/${reldir}/lpd/.wrapped_filter${model}
|
|
|
|
EOF
|
|
|
|
chmod +x $out/${reldir}/lpd/.wrapper_inner_filter${model}
|
|
|
|
|
|
|
|
cat <<-EOF >$out/${reldir}/lpd/filter${model}
|
|
|
|
#!${bash}/bin/bash
|
|
|
|
exec ${proot}/bin/proot \
|
|
|
|
-b /nix/store:/nix/store \
|
|
|
|
-b $out/opt:/opt \
|
|
|
|
-b ${cups}/share:/usr/share/cups \
|
|
|
|
$out/${reldir}/lpd/.wrapper_inner_filter${model}
|
|
|
|
EOF
|
|
|
|
chmod +x $out/${reldir}/lpd/filter${model}
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Brother ${lib.strings.toUpper model} driver";
|
|
|
|
homepage = "http://www.brother.com/";
|
2024-11-15 10:17:56 +01:00
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2023-04-25 22:06:14 +02:00
|
|
|
# license = lib.licenses.unfree;
|
2024-11-15 10:17:56 +01:00
|
|
|
platforms = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"i686-linux"
|
|
|
|
];
|
|
|
|
maintainers = [ lib.maintainers.steveej ];
|
2023-04-25 22:06:14 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
cupswrapper = stdenv.mkDerivation rec {
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://download.brother.com/welcome/dlf005597/${model}cupswrapper-${version}.i386.deb";
|
|
|
|
sha256 = "sha256-nwpuuXqBrEh5tye14gFLrezktTz6kq7HtnGqdBbgGkk=";
|
|
|
|
};
|
|
|
|
|
|
|
|
name = "${model}cupswrapper-${version}";
|
|
|
|
|
2024-11-15 10:17:56 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
dpkg
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
cups
|
|
|
|
ghostscript
|
|
|
|
a2ps
|
|
|
|
gawk
|
|
|
|
];
|
2023-04-25 22:06:14 +02:00
|
|
|
|
|
|
|
unpackPhase = "dpkg-deb -x $src $out";
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
wrapProgram $out/${reldir}/cupswrapper/cupswrapper${model} \
|
2024-11-15 10:17:56 +01:00
|
|
|
--prefix PATH : ${
|
|
|
|
lib.makeBinPath [
|
|
|
|
coreutils
|
|
|
|
ghostscript
|
|
|
|
gnugrep
|
|
|
|
gnused
|
|
|
|
]
|
|
|
|
}
|
2023-04-25 22:06:14 +02:00
|
|
|
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
|
|
|
$out/${reldir}/cupswrapper/brcupsconfpt1
|
|
|
|
|
|
|
|
mkdir -p $out/share/cups/model
|
|
|
|
ln -s $out/${reldir}/cupswrapper/brother_${model}_printer_en.ppd $out/share/cups/model/
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Brother ${lib.strings.toUpper model} CUPS wrapper driver";
|
|
|
|
homepage = "http://www.brother.com/";
|
2024-11-15 10:17:56 +01:00
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2023-04-25 22:06:14 +02:00
|
|
|
license = lib.licenses.gpl2;
|
2024-11-15 10:17:56 +01:00
|
|
|
platforms = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"i686-linux"
|
|
|
|
];
|
|
|
|
maintainers = [ lib.maintainers.steveej ];
|
2023-04-25 22:06:14 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|