about summary refs log tree commit diff
path: root/pkgs/by-name/le/lexmark-aex/package.nix
blob: cfb02f70d6f3e5fabf990960c06035ad4b4523c0 (plain) (blame)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{ lib
, stdenv
, cups
, fetchurl
, patchPpdFilesHook
, autoPatchelfHook
, dpkg
, perl
, avahi
}:

stdenv.mkDerivation {
  pname = "lexmark-aex";
  version = "1.0";

  dontPatchELF = true;
  dontStrip = true;

  src = fetchurl {
    url = "https://downloads.lexmark.com/downloads/drivers/Lexmark-AEX-PPD-Files-1.0-01242019.amd64.deb";
    hash = "sha256-igrJEeFLArGbncOwk/WttnWfPjOokD0/IzpJ4VSOtHk=";
  };

  strictDeps = true;

  nativeBuildInputs = [
    autoPatchelfHook
    patchPpdFilesHook
    dpkg
  ];

  buildInputs = [
    # Needed for autoPatchelfHook.
    avahi
    cups
    # Needed for patchShebangs.
    perl
  ];

  # Needed for autoPatchelfHook.
  runtimeDependencies = [ (lib.getLib cups) ];

  ppdFileCommands = [ "CommandFileFilterG2" "rerouteprintoption" ];

  installPhase = let
    libdir =
      if stdenv.system == "x86_64-linux"    then "lib64"
      else if stdenv.system == "i686_linux" then "lib"
      else throw "other platforms than i686_linux and x86_64-linux are not yet supported";
  in ''
    runHook preInstall

    prefix=usr/local/Lexmark/ppd/Lexmark-AEX-PPD-Files/GlobalPPD_1.4

    # Install raster image filter.
    install -Dm755 "$prefix/rerouteprintoption" "$out/lib/cups/filter/rerouteprintoption"
    patchShebangs "$out/lib/cups/filter/rerouteprintoption"

    # Install additional binary filters.
    for i in CommandFileFilterG2 LexHBPFilter; do
      install -Dm755 "$prefix/${libdir}/$i" "$out/lib/cups/filter/$i"
    done

    # Install PPD.
    install -Dm 0644 -t "$out/share/cups/model/Lexmark" "$prefix"/*.ppd

    runHook postInstall
  '';

  meta = with lib; {
    description = "CUPS drivers for Lexmark B2200 and MB2200 Series printers";
    homepage = "https://support.lexmark.com/en_xm/drivers-downloads.html";
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    maintainers = [ maintainers.tobim ];
    platforms = [ "x86_64-linux" "i686-linux" ];
  };
}