summaryrefslogtreecommitdiff
path: root/derivations/xerox-workcentre-7800-series-driver/default.nix
blob: cfdaaae3f9c14b3c41cbab1723ea3a6788a1cee4 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
  stdenv,
  lib,
  fetchurl,
  dpkg,
  autoPatchelfHook,
  cups,
  xorg,
}:
let
  debPlatform =
    if stdenv.hostPlatform.system == "x86_64-linux" then
      "x86_64"
    else if stdenv.hostPlatform.system == "i686-linux" then
      "i686"
    else
      throw "Unsupported system: ${stdenv.hostPlatform.system}";
in
stdenv.mkDerivation rec {
  pname = "xerox-workcentre-7800-series-driver";
  version = "5.20.661.4684";
  debpkg = "XeroxOfficev5Pkg-Linux${debPlatform}-${version}.deb";

  src = fetchurl {
    url = "https://download.support.xerox.com/pub/drivers/CQ8580/drivers/linux/pt_BR/${debpkg}";
    sha256 = "014k0r9ij3401mnab1qzv96bjl9x7rf11aw1ibf0q370pk9jqqjb";  # TODO correct hash for i686
  };

  nativeBuildInputs = [ dpkg autoPatchelfHook ];
  # TODO add support for disable xorg
  buildInputs = [
    cups
    stdenv.cc.cc.lib
    xorg.libX11
    xorg.libXrender
    xorg.libXfixes
    xorg.libXdamage
    xorg.libXcomposite
    xorg.libXcursor
    xorg.libXrandr
    xorg.libXext
    xorg.libXinerama
  ];

  sourceRoot = ".";
  unpackCmd = "dpkg-deb -x $curSrc .";

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out

    # Copy and patch the binaries and libraries
    cp -r opt $out/
    cp -r usr $out/

    # Move the PPD to CUPS model dir
    mkdir -p $out/share/cups/model
    cp opt/XeroxOffice/prtsys/ppd/*.ppd $out/share/cups/model/

    # Install the CUPS filters
    mkdir -p $out/lib/cups/filter
    cp usr/lib/cups/filter/* $out/lib/cups/filter/

    # Install man pages
    mkdir -p $out/share/man
    cp -r usr/share/man/* $out/share/man/

    runHook postInstall
  '';

  meta = with lib; {
    description = "Xerox WorkCentre 7800 Series Linux Printer Driver";
    longDescription = ''
      WorkCentre 7830/7835/7845/7855
    '';
    homepage = "https://www.support.xerox.com/en-us/product/workcentre-7800-series/downloads?platform=linux";
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
			#license = licenses.unfree;
    maintainers = [];
    platforms = platforms.linux;
  };
}