Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

displaylink: 1.3.52 -> 4.1.9 and refactor #34194

Closed
wants to merge 1 commit into from
Closed

displaylink: 1.3.52 -> 4.1.9 and refactor #34194

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 23, 2018

While this commit updates displaylink, it also refactors the package to
use a FHS env. This is because the binary of displaylink breaks when
modifying the RPATH with patchelf. So a little wrapper is created around
it, running the binary in the chroot.

This is the first time I use an FHS env, so please look at this accurately.

Motivation for this change

The current version of displaylink doesn't work because patchelf breaks the RPATH.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@joachifm
Copy link
Contributor

@GrahamcOfBorg build displaylink

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Partial log (click to expand)

Package ‘displaylink-4.1.9’ in /var/lib/gc-of-borg/nix-test-rs-2/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-2/pkgs/os-specific/linux/displaylink/default.nix:62 has an unfree license (‘unfree’), refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Partial log (click to expand)

Package ‘displaylink-4.1.9’ in /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/ogden/pkgs/os-specific/linux/displaylink/default.nix:62 has an unfree license (‘unfree’), refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.

@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Partial log (click to expand)

Package ‘chrootenv’ in /private/var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/lnl7-mac/pkgs/build-support/build-fhs-userenv/chrootenv/default.nix:14 is not supported on ‘x86_64-darwin’, refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowBroken = true; }
to ~/.config/nixpkgs/config.nix.

@joachifm
Copy link
Contributor

Ah, it's unfree, ignore the build errors :)

Copy link
Member

@abbradar abbradar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't build for me; probably needs hardeningDisable = [ "format" ]; because of kernel module errors.

Before you fix my other comments -- are you sure FHS environment is really necessary? Binary corruption can be possibly fixed with just dontStrip = true;.

P.S.: I don't have hardware to test this, so I rely on you saying that it works.

@@ -48,9 +48,10 @@ in
after = [ "display-manager.service" ];
conflicts = [ "getty@tty7.service" ];
path = [ pkgs.kmod ];
wantedBy = [ "multi-user.target" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My memory is hazy but I think this service is started automatically by udev rules, so no need for that.

executable = true;
text = ''
#!${bash}/bin/bash
exec ${fhsEnv}/bin/displaylink-fhs-env "${displaylink}/bin/DisplayLinkManager"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use runScript in fhsEnv.

};
in writeTextFile {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't other files, like udev rules, be hidden in package because of that indirection?


let
version = "4.1.9";
libPath = lib.makeLibraryPath [ stdenv.cc.cc utillinux libusb1 evdi ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not used in code anymore.

@ghost
Copy link
Author

ghost commented Feb 21, 2018

@abbradar Thank you for your review! As you can see, I'm a Nix(OS) newbie so your hints are highly appreciated.
With help of @Lassulus I entirely rebuilt this PR from scratch.

This doesn't build for me; probably needs hardeningDisable = [ "format" ]; because of kernel module errors.

Um, it works here without hardeningDisable. Have you enabled any special hardening options that I can enable as well to see if it still works?

Before you fix my other comments -- are you sure FHS environment is really necessary? Binary corruption can be possibly fixed with just dontStrip = true;.

Sadly, yes. When creating the PR from scratch, I tried again with dontStrip. However, the binary is already stripped so I doubt that strip would do anything. Also, it only works when removing --set-rpath from patchelf, so I think that patchelf causes the binary corruption. When using ldd, it cannot read the rpath when it's patched.
So yes, the FHS env seems to be required.

P.S.: I don't have hardware to test this, so I rely on you saying that it works.

It works here, but of course, it's better to have more testers. I'll ask a friend of mine who also runs NixOS to test it, too, but that's all I can do. EDIT: It works for him

My memory is hazy but I think this service is started automatically by udev rules, so no need for that.

Your memory is correct ;) I removed the RequiredBy

Won't other files, like udev rules, be hidden in package because of that indirection?

Yes, but that should be fixed now with the symlinkJoin.

While this commit updates displaylink, it also refactors the package to
use a FHS env. This is because the binary of displaylink breaks when
modifying the RPATH with patchelf. So a little wrapper is created
around it, running the binary in the chroot
@abbradar
Copy link
Member

@Scarmiglione Very strange, I just now tried to bump DisplayLink's version in our existing package and the binary (DisplayLinkManager) works. About hardening: I guess that's because I try to build the package on master which has newer something. I've fixed it with disabling fortify hardening for evdi (DisplayLink's kernel driver).

Can you try building https://github.com/abbradar/nixpkgs/commits/displaylink and verifying if resulting binary fails for you?

@ghost
Copy link
Author

ghost commented Feb 23, 2018

@abbradar It seems to run with your branch, but my two monitors are not detected. So what are we going to do with this? Do you know any other troubleshooting methods?

@abbradar
Copy link
Member

Does daemon run and is evdi module loaded?

@ghost
Copy link
Author

ghost commented Feb 23, 2018

Yes, the daemon is running and the evdi module is loaded

@abbradar
Copy link
Member

Maybe /tmp/DisplayLinkManager.log says something?

If we won't be able to solve this in a reasonable amount of time let's use your FHS implementation instead.

@ghost
Copy link
Author

ghost commented Feb 23, 2018

Probably you mean /var/log/displaylink/DisplaylinkManager.log? It just contains base64-encoded lines. If I decode one, it's binary gibberish.

@abbradar
Copy link
Member

@schuppentier I think I fixed that, can you try if it works now?

@ttuegel ttuegel removed their request for review February 24, 2018 14:20
@ghost
Copy link
Author

ghost commented Feb 26, 2018

@abbradar Yes! This really fixes it! This message is typed on a browser on my DisplayLink monitor, running your branch. Do you want to create a new PR that replaces this one?

@abbradar
Copy link
Member

Awesome ;) I'll just push to master then after one more evaluation test (I'll close this one when I push). Thank you!

@ghost
Copy link
Author

ghost commented Feb 26, 2018

Thank you very much for your help :) Will this be part of the next NixOS release btw?

@abbradar
Copy link
Member

Yeah, I still have plenty of time to push that. I'll backport this to 17.09 too.

@ghost
Copy link
Author

ghost commented Feb 26, 2018

Alright, thank you for your time and effort 👍

@ghost
Copy link
Author

ghost commented Feb 26, 2018

Do you also backport evdi? It's required for DisplayLink and broken on the current kernel.

@abbradar
Copy link
Member

@schuppentier Yeah, plan to do so. Generally our policy is that it's okay to backport version changes to stable releases if it's needed to fix something.

@abbradar abbradar closed this in 4db787b Feb 27, 2018
abbradar added a commit that referenced this pull request Feb 27, 2018
Closes #34194.

(cherry picked from commit 4db787b)
@azdle
Copy link

azdle commented Apr 1, 2018

@schuppentier is there anything required to use this other than adding it to displayDrivers? I've been trying to get this to work for a few months now and your fix has solved the segfault issue, but am still not getting anything on my external displays.

My config: https://github.com/azdle/my-nixos-config/blob/master/desktop-configuration.nix#L31

@ghost ghost deleted the displaylink branch April 2, 2018 16:30
@ghost
Copy link
Author

ghost commented Apr 2, 2018

@azdle Try something like xrandr --listproviders and xrandr --setprovideroutputsource 0 1

@azdle
Copy link

azdle commented Apr 2, 2018

Dang, that did it. You rock.

I ran:

xrandr --setprovideroutputsource 2 0
xrandr --setprovideroutputsource 3 0

and both of my external displays then showed up in gnome's "displays" settings pane as turned off. Turned each one and they're both working now.

It's somehow making firefox really laggy (multiple seconds of lag) and the whole UI goes laggy when I close the lid, but this is a whole lot closer than I've gotten before and this is something that should be much more googleable.

Again, thanks, so much.

Edit: resetting layers.acceleration.force-enabled back to false fixed the lag issue in firefox.

@FRidh FRidh removed their request for review April 8, 2018 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants