aboutsummaryrefslogtreecommitdiff
path: root/packages/mfcj995dw_driver.nix
blob: 42b6529716eb1e9ddd116be94b6f417263089eae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ pkgs, lib, ... }:
let
  myPatchElf = file: ''
    patchelf --set-interpreter \
      ${pkgs.stdenv.cc.libc}/lib/ld-linux${lib.optionalString pkgs.stdenv.hostPlatform.is64bit "-x86-64"}.so.2 \
      ${file}
  '';
in
pkgs.stdenv.mkDerivation rec {
  pname = "mfcj995dw";
  version = "1.0.5-0";
  src = pkgs.fetchurl {
    url = "https://download.brother.com/welcome/dlf103811/mfcj995dwpdrv-${version}-0.i386.deb"
    hash = "";
  };
  unpackPhase = ''
    ar x $src
    tar xfvz data.tar.gz
  '';
  buildInputs = with pkgs; [
    cups
    perl
    stdenv.cc.libc
    ghostscript
    which
  ];
  dontBuild=true;
  
  patchPhase = ''
    INFDIR=opt/brother/Printers/mfcj995dw/inf
    LPDDIR=opt/brother/Printers/mfcj995dw/lpd

    substituteInPlace $LPDDIR/filter_BrGenML1 \
      --replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$out/opt/brother/Printers/mfcj995dw\"; #"

    ${myPatchElf "usr/bin/brprintconf_mfcj995dw"}
  '';

  installPhase = ''
    INFDIR=opt/brother/Printers/mfcj995dw/inf
    LPDDIR=opt/brother/Printers/mfcj995dw/lpd

    mkdir -p $out/$INFDIR
    cp -rp $INFDIR/* $out/$INFDIR
    mkdir -p $out/$LPDDIR
    cp -rp $LPDDIR/* $out/LPDDIR

    mkdir -p $out/bin
    cp -r usr/bin/brprintconf_mfcj995dw $out/bin""

    mkdir -p $out/share/cups/model/
    cp ./opt/brother/Printer/brother/mfcj995dw/cupswrapper/brother_mfcj995dw_printer_en.ppd $out/share/cups/model
  '';

  meta = {
    description = "Brother Mfcj995dw drivers";
    homepage = "http://www.brother.com";
  };
}