nixpkgs/nixos/modules/hardware/video/displaylink.nix

77 lines
1.8 KiB
Nix
Raw Normal View History

2017-05-01 13:23:41 +01:00
{ config, lib, pkgs, ... }:
2016-08-27 17:55:56 +01:00
with lib;
let
enabled = elem "displaylink" config.services.xserver.videoDrivers;
2017-05-01 13:23:41 +01:00
evdi = config.boot.kernelPackages.evdi;
displaylink = pkgs.displaylink.override {
inherit evdi;
};
2016-08-27 17:55:56 +01:00
in
{
config = mkIf enabled {
2017-05-01 13:23:41 +01:00
boot.extraModulePackages = [ evdi ];
boot.kernelModules = [ "evdi" ];
environment.etc."X11/xorg.conf.d/40-displaylink.conf".text = ''
Section "OutputClass"
Identifier "DisplayLink"
MatchDriver "evdi"
Driver "modesetting"
Option "AccelMethod" "none"
EndSection
'';
# make the device available
services.xserver.displayManager.sessionCommands = ''
${lib.getBin pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource 1 0
'';
2016-08-27 17:55:56 +01:00
# Those are taken from displaylink-installer.sh and from Arch Linux AUR package.
2017-05-01 13:23:41 +01:00
services.udev.packages = [ displaylink ];
2016-08-27 17:55:56 +01:00
powerManagement.powerDownCommands = ''
#flush any bytes in pipe
while read -n 1 -t 1 SUSPEND_RESULT < /tmp/PmMessagesPort_out; do : ; done;
#suspend DisplayLinkManager
echo "S" > /tmp/PmMessagesPort_in
#wait until suspend of DisplayLinkManager finish
2017-05-01 13:23:41 +01:00
if [ -f /tmp/PmMessagesPort_out ]; then
#wait until suspend of DisplayLinkManager finish
read -n 1 -t 10 SUSPEND_RESULT < /tmp/PmMessagesPort_out
fi
2016-08-27 17:55:56 +01:00
'';
powerManagement.resumeCommands = ''
#resume DisplayLinkManager
echo "R" > /tmp/PmMessagesPort_in
'';
2017-05-01 13:23:41 +01:00
systemd.services.dlm = {
2016-08-27 17:55:56 +01:00
description = "DisplayLink Manager Service";
after = [ "display-manager.service" ];
2017-05-01 13:23:41 +01:00
conflicts = [ "getty@tty7.service" ];
2016-08-27 17:55:56 +01:00
serviceConfig = {
ExecStart = "${displaylink}/bin/DisplayLinkManager";
Restart = "always";
RestartSec = 5;
LogsDirectory = "displaylink";
2016-08-27 17:55:56 +01:00
};
};
};
}