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