feat: add printer driver
This commit is contained in:
parent
610e399cff
commit
7692303804
3 changed files with 129 additions and 2 deletions
|
|
@ -3,5 +3,13 @@
|
||||||
experimental-features = [ "nix-command" "flakes" ];
|
experimental-features = [ "nix-command" "flakes" ];
|
||||||
auto-optimise-store = true;
|
auto-optimise-store = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(self: super: {
|
||||||
|
mfcl3750cdwlpr = (super.callPackage ../overlays/mfcl3750cdw.nix {}).driver;
|
||||||
|
mfcl3750cdwcupswrapper = (super.callPackage ../overlays/mfcl3750cdw.nix {}).cupswrapper;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
system.stateVersion = "23.05";
|
system.stateVersion = "23.05";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
{ ... }: {
|
{ pkgs, config, ... }: {
|
||||||
# Enable CUPS to print documents.
|
# Enable CUPS to print documents.
|
||||||
services.printing.enable = true;
|
services.printing = {
|
||||||
|
enable = true;
|
||||||
|
drivers = [
|
||||||
|
pkgs.mfcl3750cdwcupswrapper
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
services.avahi = {
|
services.avahi = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -8,4 +13,20 @@
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
hardware.printers = {
|
||||||
|
ensurePrinters = [
|
||||||
|
{
|
||||||
|
name = "Brother MFC-L3750CDW series";
|
||||||
|
location = "Home";
|
||||||
|
deviceUri = "ipp://BROTHER-ETH.local.:631/ipp/print";
|
||||||
|
model =
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; with config.bchmnn; lib.optionals (gui.enable) [
|
||||||
|
system-config-printer
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
98
overlays/mfcl3750cdw.nix
Normal file
98
overlays/mfcl3750cdw.nix
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
{ pkgsi686Linux
|
||||||
|
, stdenv
|
||||||
|
, fetchurl
|
||||||
|
, dpkg
|
||||||
|
, makeWrapper
|
||||||
|
, coreutils
|
||||||
|
, ghostscript
|
||||||
|
, gnugrep
|
||||||
|
, gnused
|
||||||
|
, which
|
||||||
|
, perl
|
||||||
|
, lib
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
model = "mfcl3750cdw";
|
||||||
|
version = "1.0.2-0";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://download.brother.com/welcome/dlf103934/${model}pdrv-${version}.i386.deb";
|
||||||
|
sha256 = "3a0d5f09a265208fdd1b8266ef36286ec294c7a4befa327be81141efabe8590b";
|
||||||
|
};
|
||||||
|
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/brmfcl3750cdwfilter
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Brother ${lib.strings.toUpper model} driver";
|
||||||
|
homepage = "http://www.brother.com/";
|
||||||
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||||
|
license = lib.licenses.unfree;
|
||||||
|
platforms = [ "x86_64-linux" "i686-linux" ];
|
||||||
|
maintainers = [ lib.maintainers.bchmnn ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
chmod 755 $out/lib/cups/filter/brother_lpdwrapper_${model}
|
||||||
|
|
||||||
|
ln $dir/cupswrapper/brother_${model}_printer_en.ppd $out/share/cups/model
|
||||||
|
chmod 644 $dir/cupswrapper/brother_${model}_printer_en.ppd
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Brother ${lib.strings.toUpper model} CUPS wrapper driver";
|
||||||
|
homepage = "http://www.brother.com/";
|
||||||
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||||
|
license = lib.licenses.gpl2;
|
||||||
|
platforms = [ "x86_64-linux" "i686-linux" ];
|
||||||
|
maintainers = [ lib.maintainers.bchmnn ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue