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

Packaging Request: Tuxedo Control Center #132206

Open
blitz opened this issue Jul 31, 2021 · 18 comments
Open

Packaging Request: Tuxedo Control Center #132206

blitz opened this issue Jul 31, 2021 · 18 comments

Comments

@blitz
Copy link
Contributor

blitz commented Jul 31, 2021

Project description

Tuxedo is a German laptop manufacturer that provides Linux-friendly laptops. Their system control is done via an app called "Tuxedo Control Center" (TCC). This open source app provides fan control settings among other things. Without this app, the Tuxedo laptops default to very noisy fan control settings. It lives on Github.

Besides the source, Tuxedo provides binary packages for Ubuntu and OpenSUSE.

TCC consists of:

  • a set of systemd services implemented in Javascript,
  • an Electron GUI application to control everything.

Metadata

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/packaging-the-tuxedo-control-center-electron/14326/2

@Artturin
Copy link
Member

i'll take a shot at this

@Artturin
Copy link
Member

Artturin commented Jul 31, 2021

builds and launches but complains about

/bin/sh: prime-select: command not found
/bin/sh: prime-supported: command not found

which are provided by a fedora only package

will also need a module as tccd service is needed

{ lib
, stdenv
, makeWrapper
, fetchurl
, rpmextract
, autoPatchelfHook
, alsa-lib
, cups
, gdk-pixbuf
, glib
, gtk3
, libnotify
, libuuid
, libX11
, libXScrnSaver
, libXcomposite
, libXcursor
, libXdamage
, libXext
, libXfixes
, libXi
, libXrandr
, libXrender
, libXtst
, libxcb
, libxshmfence
, mesa
, nspr
, nss
, pango
, systemd
, libappindicator-gtk3
, libdbusmenu

}:

stdenv.mkDerivation rec {
  pname = "tuxedo-control-center";
  version = "1.0.14";

  src = fetchurl {
    url = "https://rpm.tuxedocomputers.com/opensuse/15.2/x86_64/tuxedo-control-center_${version}.rpm";
    sha256 = "1fhcxf6jdb2b79pkyjxz6l78m8gbzlv0swncys6r17i08y2vv8d1";
  };


  nativeBuildInputs = [
    rpmextract
    makeWrapper
    alsa-lib
    autoPatchelfHook
    cups
    libXdamage
    libX11
    libXScrnSaver
    libXtst
    libxshmfence
    mesa
    nss
    libXrender
    gdk-pixbuf
    gtk3
  ];

  libPath = lib.makeLibraryPath [
    alsa-lib
    gdk-pixbuf
    glib
    gtk3
    libnotify
    libX11
    libXcomposite
    libuuid
    libXcursor
    libXdamage
    libXext
    libXfixes
    libXi
    libXrandr
    libXrender
    libXtst
    nspr
    nss
    libxcb
    pango
    systemd
    libXScrnSaver
    libappindicator-gtk3
    libdbusmenu
  ];

  unpackPhase = ''
    mkdir -p $out/bin
    cd $out
    rpmextract $src
  '';

  installPhase = ''
    runHook preInstall

    wrapProgram $out/opt/${pname}/${pname} \
        --prefix LD_LIBRARY_PATH : ${libPath}:$out/opt/${pname}

    ln -s $out/opt/${pname}/${pname} $out/bin/

    runHook postInstall
  '';


  meta = with lib; {
    description = "A tool to help you control performance, energy, fan and comfort settings on TUXEDO laptops.";
    homepage = "github.com/tuxedocomputers/tuxedo-control-center";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ ];
  };
}

used the discord expression for reference

@blitz
Copy link
Contributor Author

blitz commented Jul 31, 2021

Awesome! I think this is an excellent first step. If I have some time, I'll try to get the systemd services running, but I don't mind if anyone beats me to it. :)

@blitz
Copy link
Contributor Author

blitz commented Aug 1, 2021

@Artturin patchelf seems to cause issues with tccd. I'm hitting this issue: vercel/pkg#321. I've tried to get around patching the binary by adding all dependencies to the LD_LIBRARY_PATH of the wrapper, but this results in weird glibc errors. So I currently assume to package tccd we need a hack like this one.

I wonder this hack can be avoided by building everything from source.

@blitz
Copy link
Contributor Author

blitz commented Aug 1, 2021

Btw, looking at the code, the prime-select errors are somehwat harmless and probably just prevent nVidia PRIME configuration from working.

@Vodurden
Copy link
Contributor

Vodurden commented Aug 5, 2021

Not sure if it's helpful but I had this packaged privately a while ago and working for my clevo-based laptop:

Using the module looked like this:

  services.tuxedo-control-center = {
    enable = true;
    acProfile = "NixOS";
    batteryProfile = "NixOS";
    profiles."NixOS" = {
      cpuGovernor = "powersave";
      cpuEnergyPerformancePreference = "balance_performance";
      fanProfile = "Silent";
    };
  };

I'm not willing to submit it upstream since I no longer use the module and I think tuxedo control center has been re-organised since I wrote the package, but I figure this might help someone in building a new derivation :)

@blitz
Copy link
Contributor Author

blitz commented Aug 5, 2021

@Vodurden Oh wow. Very nice! This is very helpful. I'm going to give this a go with the new TCC version. I'm also happy to maintain this once its in nixpkgs.

@blitz
Copy link
Contributor Author

blitz commented Aug 6, 2021

I started working on this in https://github.com/blitz/nixpkgs/tree/tuxedo-control-center

Still to go:

  • updating TCC to the most recent version,
  • integrating the module from @Vodurden

@blitz
Copy link
Contributor Author

blitz commented Aug 9, 2021

TCC is updated to 1.0.14 in my branch (latest version). This leaves the module.

@blitz
Copy link
Contributor Author

blitz commented Aug 10, 2021

I've added the module. So I think we are "code complete" here. I'll have access to a Tuxedo laptop in 2 weeks to test. If someone wants to check it out in the meantime, rebuild your NixOS with https://github.com/blitz/nixpkgs/tree/tuxedo-control-center and enable hardware.tuxedo-control-center.enable = true;

@Vodurden
Copy link
Contributor

I'm glad to see the module/derivation was helpful, thanks for taking it on and giving it a new life! :)

@DerickEddington
Copy link
Contributor

I'd like to thank you all for working on this and I hope it gets merged.

I have a new Clevo NH55EJQ laptop (from DreamMachines.io) running NixOS 21.05 (soon to be 21.11), and this tuxedo-control-center package (currently installed following https://github.com/blitz/tuxedo-nixos#usage) is the only thing I've found that allows control over my laptop's performance profile. Without it, the CPU GHz, boost, and fan speed were below expected, but with it I'm able to change the profile to achieve maximum performance (or choose a quiet profile).

Tuxedo laptops are (usually? always?) Clevo models (I heard), and I learned from the Arch Linux wiki (I think it was) that the Tuxedo Control Center often works for other Clevos. There is an official Control Center app for Windows for Clevos that is mentioned in my laptop's User's Manual. It's great to have something like it for Linux.

I can confirm that, without prime-select and prime-supported, this tuxedo-control-center package still works for CPU and fan control. My laptop does have an Nvidia dGPU but I haven't gotten into enabling it yet.

I'd be glad to help further test this package if needed (within my limited familiarity with Nix and Electron).

@blitz
Copy link
Contributor Author

blitz commented Nov 2, 2021

@DerickEddington Thanks for the warm words. :) To my knowledge all Tuxedo laptops are Clevo laptops. I'm going to make another push to get this into nixpkgs soon. The main obstacle right now are:

The first point I can probably defeat on my own. For the second, I would need some help from someone who actually knows the JS/Electron ecosystem.

@blitz
Copy link
Contributor Author

blitz commented Nov 4, 2021

Upstream said they will bump Electron soon. 🎉

@marvin
Copy link

marvin commented May 21, 2022

Any News on That? Any More help Required?

@blitz
Copy link
Contributor Author

blitz commented May 28, 2022

@marvin (or anyone else interested in moving this forward :) )

Any News on That? Any More help Required?

Upstream is very slow to update Electron. They basically update to versions that are already deprecated. If you have the skills to help with that, head over to: tuxedocomputers/tuxedo-control-center#148

Updating the Nix expressions to TCC 1.1.4 has also been a challenge and I didn't have time to figure out the issues. 1.1.4 hits some node2nix issues, that i don't understand yet. If you want to take a shot, the update instructions are here: https://github.com/blitz/tuxedo-nixos/tree/master/nix/tuxedo-control-center

@liketechnik
Copy link
Member

Updating the Nix expressions to TCC 1.1.4 has also been a challenge and I didn't have time to figure out the issues. 1.1.4 hits some node2nix issues, that i don't understand yet.

I got version 1.2.2 (latest as of writing) working locally (well, and in one big ugly commit). I am currently working on splitting the update into the update itself and various small fixes and tweaks.

I hope to be able to open a PR in the blitz/tuxedo-nixos repository with the update in the following days :)

@mrcjkb mrcjkb mentioned this issue May 12, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants