Skip to content

Commit

Permalink
displaylink: manually activate dlm.service
Browse files Browse the repository at this point in the history
The shell script coming with the vendor-provided udev rule simply
starts dlm.service (and sets up some symlinks), and stops dlm.service if
that was the last card plugged in.

On NixOS, some of the cat/grep/sed commands are not available, causing
the script to fail.

Turns out, the symlinks aren't needed at all. Archlinux ships their own
script
(https://aur.archlinux.org/cgit/aur.git/plain/udev.sh?h=displaylink),
which only starts and stops dlm.service, depending on whether there's
cards left or not.

We can further optimize this by simply starting dlm.service on the first
card, and not stopping it at all. Considering dlm won't get stopped if
one of multiple cards is unplugged, it seems to handle disconnects.
  • Loading branch information
flokli committed Dec 20, 2020
1 parent 132894d commit 43f7479
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 33 deletions.
1 change: 1 addition & 0 deletions pkgs/os-specific/linux/displaylink/99-displaylink.rules
@@ -0,0 +1 @@
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTRS{idVendor}=="17e9", ATTR{bInterfaceClass}=="ff", ATTR{bInterfaceProtocol}=="03", TAG+="systemd", ENV{SYSTEMD_WANTS}="dlm.service"
30 changes: 15 additions & 15 deletions pkgs/os-specific/linux/displaylink/default.nix
@@ -1,6 +1,14 @@
{ stdenv, lib, unzip, util-linux,
libusb1, evdi, systemd, makeWrapper, requireFile, substituteAll }:

{ stdenv
, lib
, unzip
, util-linux
, libusb1
, evdi
, systemd
, makeWrapper
, requireFile
, substituteAll
}:
let
arch =
if stdenv.hostPlatform.system == "x86_64-linux" then "x64"
Expand All @@ -9,7 +17,8 @@ let
bins = "${arch}-ubuntu-1604";
libPath = lib.makeLibraryPath [ stdenv.cc.cc util-linux libusb1 evdi ];

in stdenv.mkDerivation rec {
in
stdenv.mkDerivation rec {
pname = "displaylink";
version = "5.3.1.34";

Expand Down Expand Up @@ -39,20 +48,11 @@ in stdenv.mkDerivation rec {
./displaylink-driver-${version}.run --target . --noexec --nodiskspace
'';

patches = [ (substituteAll {
src = ./udev-installer.patch;
inherit systemd;
})];

installPhase = ''
sed -i "s,/opt/displaylink/udev.sh,$out/lib/udev/displaylink.sh,g" udev-installer.sh
( source udev-installer.sh
mkdir -p $out/lib/udev/rules.d
main systemd "$out/lib/udev/rules.d/99-displaylink.rules" "$out/lib/udev/displaylink.sh"
)
install -Dt $out/lib/displaylink *.spkg
install -Dm755 ${bins}/DisplayLinkManager $out/bin/DisplayLinkManager
mkdir -p $out/lib/udev/rules.d
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} \
Expand Down
18 changes: 0 additions & 18 deletions pkgs/os-specific/linux/displaylink/udev-installer.patch

This file was deleted.

0 comments on commit 43f7479

Please sign in to comment.