Displaylink: Difference between revisions

Mention that pre-sleep.service has the potential to block suspend
Cobalt (talk | contribs)
update swaywm instructions for NixOS 25.11
 
(3 intermediate revisions by one other user not shown)
Line 10: Line 10:
  displaylink
  displaylink
];
];
</syntaxhighlight>Then add the videoDrivers:<syntaxhighlight lang="nixos">services.xserver.videoDrivers = [ "displaylink" "modesetting" ];</syntaxhighlight>The module <code>nixos/modules/hardware/video/displaylink.nix</code> should also work for wlroots compositors.
</syntaxhighlight>Then add the videoDrivers:<syntaxhighlight lang="nix">services.xserver.videoDrivers = [ "displaylink" "modesetting" ];</syntaxhighlight>The module <code>nixos/modules/hardware/video/displaylink.nix</code> should also work for wlroots compositors.


====<big>Xserver</big>====
====<big>Xserver</big>====
Line 29: Line 29:


You probably will need the `evdi` module
You probably will need the `evdi` module
{{bc|<nowiki>
<syntaxhighlight lang="nix">
boot = {
boot = {
   extraModulePackages = [ config.boot.kernelPackages.evdi ];
   extraModulePackages = [ config.boot.kernelPackages.evdi ];
Line 39: Line 39:
   };
   };
};
};
</nowiki>}}
</syntaxhighlight>


====='''Gnome Wayland'''=====
====='''Gnome Wayland'''=====
Line 45: Line 45:
Install displayLink package
Install displayLink package


{{bc|<nowiki>
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
   displaylink
   displaylink
];
];
</nowiki>}}
</syntaxhighlight>


Define videoDrivers
Define videoDrivers
Line 57: Line 57:


Add dlm service
Add dlm service
{{bc|<nowiki>
<syntaxhighlight lang="nix">
systemd.services.dlm.wantedBy = [ "multi-user.target" ];
systemd.services.dlm.wantedBy = [ "multi-user.target" ];
</nowiki>}}
</syntaxhighlight>
====='''KDE Plasma'''=====
====='''KDE Plasma'''=====


Line 66: Line 66:
Esnure you properly enabled wayland session  
Esnure you properly enabled wayland session  


{{bc|<nowiki>
<syntaxhighlight lang="nix">
environment.variables = {
environment.variables = {
   KWIN_DRM_PREFER_COLOR_DEPTH = "24";
   KWIN_DRM_PREFER_COLOR_DEPTH = "24";
Line 84: Line 84:


};
};
</nowiki>}}
</syntaxhighlight>


Install displayLink package
Install displayLink package


{{bc|<nowiki>
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
   displaylink
   displaylink
];
];
</nowiki>}}
</syntaxhighlight>


Instead of dlm setup display-link server as follows:
Instead of dlm setup display-link server as follows:


{{bc|<nowiki>
<syntaxhighlight lang="nix">
# --- THIS IS THE CRUCIAL PART FOR ENABLING THE SERVICE ---
systemd.services.displaylink-server = {
systemd.services.displaylink-server = {
   enable = true;
   enable = true;
  # Ensure it starts after udev has done its work
   requires = [ "systemd-udevd.service" ];
   requires = [ "systemd-udevd.service" ];
   after = [ "systemd-udevd.service" ];
   after = [ "systemd-udevd.service" ];
   wantedBy = [ "multi-user.target" ]; # Start at boot
   wantedBy = [ "multi-user.target" ];
  # *** THIS IS THE CRITICAL 'serviceConfig' BLOCK ***
   serviceConfig = {
   serviceConfig = {
     Type = "simple"; # Or "forking" if it forks (simple is common for daemons)
     Type = "simple";
    # The ExecStart path points to the DisplayLinkManager binary provided by the package
     ExecStart = "${pkgs.displaylink}/bin/DisplayLinkManager";
     ExecStart = "${pkgs.displaylink}/bin/DisplayLinkManager";
    # User and Group to run the service as (root is common for this type of daemon)
     User = "root";
     User = "root";
     Group = "root";
     Group = "root";
    # Environment variables that the service itself might need
    # Environment = [ "DISPLAY=:0" ]; # Might be needed in some cases, but generally not for this
     Restart = "on-failure";
     Restart = "on-failure";
     RestartSec = 5; # Wait 5 seconds before restarting
     RestartSec = 5; # Wait 5 seconds before restarting
   };
   };
};
};
</nowiki>}}
</syntaxhighlight>
 


==Sway==
==Sway==
Line 148: Line 140:
];
];
services.xserver.videoDrivers = [ "displaylink" ];
services.xserver.videoDrivers = [ "displaylink" ];
# only for NixOS 25.05 and earlier
systemd.services.dlm.wantedBy = [ "multi-user.target" ];
systemd.services.dlm.wantedBy = [ "multi-user.target" ];
</syntaxhighlight>
</syntaxhighlight>


Note as of [https://github.com/NixOS/nixpkgs/pull/351752 2024-10-30] nixos-unstable sway uses <code>wlroots_0_18</code>. The patch above applies correctly but you will need to invoke sway with the <code>--unsupported-gpu</code> flag.
Note as of [https://github.com/NixOS/nixpkgs/pull/351752 2024-10-30] nixos-unstable sway uses <code>wlroots_0_18</code> and as of NixOS 25.11 sway uses <code>wlroots_0_19</code>. The patch above applies correctly but you will need to invoke sway with the <code>--unsupported-gpu</code> flag.


For NixOS 25.11 and later you also will not have to add a dependency on the dlm service but instead use <code>displaylink-server</code> like KDE Plasma.


You can also test if your setup is working without this service (you will still require the patch for wlroots and sway with the <code>--unsupported-gpu</code> flag) by invoking the DisplayLinkManager executable (provided by the displaylink package) as root. If the setup is working, sway should at this point recognize the new display(s).
[https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1823#note_2146862 Source]
[https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1823#note_2146862 Source]