about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/displaylink/default.nix
blob: 016ec76efcdce51680276d5c7d36e152232dd104 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
  stdenv,
  lib,
  unzip,
  util-linux,
  libusb1,
  evdi,
  makeBinaryWrapper,
  requireFile,
}:

let
  bins =
    if stdenv.hostPlatform.system == "x86_64-linux" then
      "x64-ubuntu-1604"
    else if stdenv.hostPlatform.system == "i686-linux" then
      "x86-ubuntu-1604"
    else if stdenv.hostPlatform.system == "aarch64-linux" then
      "aarch64-linux-gnu"
    else
      throw "Unsupported architecture";
  libPath = lib.makeLibraryPath [
    stdenv.cc.cc
    util-linux
    libusb1
    evdi
  ];
in
stdenv.mkDerivation (finalAttrs: {
  pname = "displaylink";
  version = "6.0.0-24";

  src = requireFile rec {
    name = "displaylink-600.zip";
    sha256 = "1ixrklwk67w25cy77n7l0pq6j9i4bp4lkdr30kp1jsmyz8daaypw";
    message = ''
      In order to install the DisplayLink drivers, you must first
      comply with DisplayLink's EULA and download the binaries and
      sources from here:

      https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu-6.0

      Once you have downloaded the file, please use the following
      commands and re-run the installation:

      mv \$PWD/"DisplayLink USB Graphics Software for Ubuntu6.0-EXE.zip" \$PWD/${name}
      nix-prefetch-url file://\$PWD/${name}
    '';
  };

  nativeBuildInputs = [
    makeBinaryWrapper
    unzip
  ];

  unpackPhase = ''
    runHook preUnpack
    unzip $src
    chmod +x displaylink-driver-${finalAttrs.version}.run
    ./displaylink-driver-${finalAttrs.version}.run --target . --noexec --nodiskspace
    runHook postUnpack
  '';

  installPhase = ''
    runHook preInstall
    install -Dt $out/lib/displaylink *.spkg
    install -Dm755 ${bins}/DisplayLinkManager $out/bin/DisplayLinkManager
    mkdir -p $out/lib/udev/rules.d $out/share
    cp ${./99-displaylink.rules} $out/lib/udev/rules.d/99-displaylink.rules
    patchelf \
      --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
      --set-rpath ${libPath} \
      $out/bin/DisplayLinkManager
    wrapProgram $out/bin/DisplayLinkManager \
      --chdir "$out/lib/displaylink"

    # We introduce a dependency on the source file so that it need not be redownloaded everytime
    echo $src >> "$out/share/workspace_dependencies.pin"
    runHook postInstall
  '';

  dontStrip = true;
  dontPatchELF = true;

  meta = with lib; {
    description = "DisplayLink DL-7xxx, DL-6xxx, DL-5xxx, DL-41xx and DL-3x00 Driver for Linux";
    homepage = "https://www.displaylink.com/";
    hydraPlatforms = [ ];
    license = licenses.unfree;
    mainProgram = "DisplayLinkManager";
    maintainers = with maintainers; [ abbradar ];
    platforms = [
      "x86_64-linux"
      "i686-linux"
      "aarch64-linux"
    ];
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
  };
})