Hi all
Can anyone help please? I have a Brother MFC-J5340DW printer which I have been trying to build a driver for from the .deb
It’s the last obstacle to me using NixOS as my daily-driver as without the .deb package, I’m missing a lot of options.
I’ve copied a driver from a different printer and made some changes but still can’t get it to work, can anyone help please?
{
pkgsi686Linux,
stdenv,
fetchurl,
dpkg,
makeWrapper,
coreutils,
ghostscript,
gnugrep,
gnused,
which,
perl,
lib,
}:
let
model = "mfcj5340dw";
version = "3.5.0-1";
src = fetchurl {
url = "https://download.brother.com/welcome/dlf105455/${model}pdrv-${version}.i386.deb";
sha256 = "sha256-VVq5Urcdaag3rAfsWDtr8/HhLSxOiXScawhxmyS4GEM=";
};
reldir = "opt/brother/Printers/${model}";
in
rec {
driver = pkgsi686Linux.stdenv.mkDerivation rec {
inherit src version;
name = "${model}drv-${version}";
nativeBuildInputs = [
dpkg
makeWrapper
];
unpackPhase = "dpkg-deb -x $src $out";
installPhase = ''
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 : ${
lib.makeBinPath [
coreutils
ghostscript
gnugrep
gnused
which
]
}
# need to use i686 glibc here, these are 32bit proprietary binaries
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
$dir/lpd/filter_mfcj5340dw
'';
};
cupswrapper = stdenv.mkDerivation rec {
inherit version src;
name = "${model}cupswrapper-${version}";
nativeBuildInputs = [
dpkg
makeWrapper
];
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} \
--prefix PATH : ${
lib.makeBinPath [
coreutils
gnugrep
gnused
]
}
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
'';
};
}
and tried to build with this command:
nix-build -E 'with import <nixpkgs> { }; callPackage ./tryme.nix { }'
but got the following error:
these 2 derivations will be built:
/nix/store/i1dqdqz74klb01jdyc12ca706avpps5d-mfcj5340dwdrv-3.5.0-1.drv
/nix/store/lqi73h86blj1j34x5494al0wkk61v049-mfcj5340dwcupswrapper-3.5.0-1.drv
building '/nix/store/i1dqdqz74klb01jdyc12ca706avpps5d-mfcj5340dwdrv-3.5.0-1.drv'...
Running phase: unpackPhase
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
substituteStream() in derivation mfcj5340dwdrv-3.5.0-1: WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. (file '/nix/store/wf2xa21782vsjsvqmcmb7cd5y32lkn58-mfcj5340dwdrv-3.5.0-1/opt/brother/Printers/mfcj5340dw/lpd/filter_mfcj5340dw')
patchelf: not an ELF executable
error: builder for '/nix/store/i1dqdqz74klb01jdyc12ca706avpps5d-mfcj5340dwdrv-3.5.0-1.drv' failed with exit code 1;
last 10 log lines:
> Running phase: unpackPhase
> Running phase: patchPhase
> Running phase: updateAutotoolsGnuConfigScriptsPhase
> Running phase: configurePhase
> no configure script, doing nothing
> Running phase: buildPhase
> no Makefile or custom buildPhase, doing nothing
> Running phase: installPhase
> substituteStream() in derivation mfcj5340dwdrv-3.5.0-1: WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. (file '/nix/store/wf2xa21782vsjsvqmcmb7cd5y32lkn58-mfcj5340dwdrv-3.5.0-1/opt/brother/Printers/mfcj5340dw/lpd/filter_mfcj5340dw')
> patchelf: not an ELF executable
For full logs, run:
nix-store -l /nix/store/i1dqdqz74klb01jdyc12ca706avpps5d-mfcj5340dwdrv-3.5.0-1.drv
error: build of '/nix/store/i1dqdqz74klb01jdyc12ca706avpps5d-mfcj5340dwdrv-3.5.0-1.drv', '/nix/store/lqi73h86blj1j34x5494al0wkk61v049-mfcj5340dwcupswrapper-3.5.0-1.drv' failed
can someone please help?