1{ stdenv, lib, fetchurl, unzip, utillinux,
2 libusb1, evdi, systemd, makeWrapper, requireFile }:
3
4let
5 arch =
6 if stdenv.system == "x86_64-linux" then "x64"
7 else if stdenv.system == "i686-linux" then "x86"
8 else throw "Unsupported architecture";
9 bins = "${arch}-ubuntu-1604";
10 libPath = lib.makeLibraryPath [ stdenv.cc.cc utillinux libusb1 evdi ];
11
12in stdenv.mkDerivation rec {
13 name = "displaylink-${version}";
14 version = "4.1.9";
15
16 src = requireFile rec {
17 name = "displaylink.zip";
18 sha256 = "d762145014df7fea8ca7af12206a077d73d8e7f2259c8dc2ce7e5fb1e69ef9a3";
19 message = ''
20 In order to install the DisplayLink drivers, you must first
21 comply with DisplayLink's EULA and download the binaries and
22 sources from here:
23
24 http://www.displaylink.com/downloads/file?id=1087
25
26 Once you have downloaded the file, please use the following
27 commands and re-run the installation:
28
29 mv \$PWD/"DisplayLink USB Graphics Software for Ubuntu ${version}.zip" \$PWD/${name}
30 nix-prefetch-url file://\$PWD/${name}
31 '';
32 };
33
34 nativeBuildInputs = [ unzip makeWrapper ];
35
36 buildCommand = ''
37 unzip $src
38 chmod +x displaylink-driver-${version}.run
39 ./displaylink-driver-${version}.run --target . --noexec
40
41 sed -i "s,/opt/displaylink/udev.sh,$out/lib/udev/displaylink.sh,g" udev-installer.sh
42 ( source udev-installer.sh
43 mkdir -p $out/lib/udev/rules.d
44 main systemd "$out/lib/udev/rules.d/99-displaylink.rules" "$out/lib/udev/displaylink.sh"
45 )
46 sed -i '2iPATH=${systemd}/bin:$PATH' $out/lib/udev/displaylink.sh
47
48 install -Dt $out/lib/displaylink *.spkg
49 install -Dm755 ${bins}/DisplayLinkManager $out/bin/DisplayLinkManager
50 patchelf \
51 --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
52 --set-rpath ${libPath} \
53 $out/bin/DisplayLinkManager
54 wrapProgram $out/bin/DisplayLinkManager \
55 --run "cd $out/lib/displaylink"
56
57 fixupPhase
58 '';
59
60 dontStrip = true;
61 dontPatchELF = true;
62
63 meta = with stdenv.lib; {
64 description = "DisplayLink DL-5xxx, DL-41xx and DL-3x00 Driver for Linux";
65 platforms = [ "x86_64-linux" "i686-linux" ];
66 license = licenses.unfree;
67 homepage = http://www.displaylink.com/;
68 };
69}