1{ stdenv
2, lib
3, unzip
4, util-linux
5, libusb1
6, evdi
7, systemd
8, makeWrapper
9, requireFile
10, substituteAll
11}:
12let
13 arch =
14 if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
15 else if stdenv.hostPlatform.system == "i686-linux" then "x86"
16 else throw "Unsupported architecture";
17 bins = "${arch}-ubuntu-1604";
18 libPath = lib.makeLibraryPath [ stdenv.cc.cc util-linux libusb1 evdi ];
19
20in
21stdenv.mkDerivation rec {
22 pname = "displaylink";
23 version = "5.6.1-59.184";
24
25 src = requireFile rec {
26 name = "displaylink-561.zip";
27 sha256 = "1hihsz35ccydzx04r8r9kz0hvqwj5fgr8zpzvwyhfxp2m549f9w9";
28 message = ''
29 In order to install the DisplayLink drivers, you must first
30 comply with DisplayLink's EULA and download the binaries and
31 sources from here:
32
33 https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu-5.6.1
34
35 Once you have downloaded the file, please use the following
36 commands and re-run the installation:
37
38 mv \$PWD/"DisplayLink USB Graphics Software for Ubuntu5.6.1-EXE.zip" \$PWD/${name}
39 nix-prefetch-url file://\$PWD/${name}
40 '';
41 };
42
43 nativeBuildInputs = [ unzip makeWrapper ];
44
45 unpackPhase = ''
46 unzip $src
47 chmod +x displaylink-driver-${version}.run
48 ./displaylink-driver-${version}.run --target . --noexec --nodiskspace
49 '';
50
51 installPhase = ''
52 install -Dt $out/lib/displaylink *.spkg
53 install -Dm755 ${bins}/DisplayLinkManager $out/bin/DisplayLinkManager
54 mkdir -p $out/lib/udev/rules.d $out/share
55 cp ${./99-displaylink.rules} $out/lib/udev/rules.d/99-displaylink.rules
56 patchelf \
57 --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
58 --set-rpath ${libPath} \
59 $out/bin/DisplayLinkManager
60 wrapProgram $out/bin/DisplayLinkManager \
61 --chdir "$out/lib/displaylink"
62
63 # We introduce a dependency on the source file so that it need not be redownloaded everytime
64 echo $src >> "$out/share/workspace_dependencies.pin"
65 '';
66
67 dontStrip = true;
68 dontPatchELF = true;
69
70 meta = with lib; {
71 description = "DisplayLink DL-5xxx, DL-41xx and DL-3x00 Driver for Linux";
72 homepage = "https://www.displaylink.com/";
73 license = licenses.unfree;
74 maintainers = with maintainers; [ abbradar peterhoeg eyjhb ];
75 platforms = [ "x86_64-linux" "i686-linux" ];
76 hydraPlatforms = [];
77 };
78}