Unverified Commit 0731872d authored by Aurelia's avatar Aurelia
Browse files

adjustor: init at 3.11.8



based of work from #347279 by @toast003

Co-authored-by: default avatarToast <39011842+toast003@users.noreply.github.com>
Co-authored-by: default avatarqzylinra <225773816+qzylinra@users.noreply.github.com>
parent c72d8b90
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -7,6 +7,10 @@
with lib;
let
  cfg = config.services.handheld-daemon;
  hhdPackage = cfg.package.override {
    withAdjustor = cfg.adjustor.enable;
    adjustor = cfg.adjustor.package;
  };
in
{
  options.services.handheld-daemon = {
@@ -18,6 +22,18 @@ in
      package = mkPackageOption pkgs "handheld-daemon-ui" { };
    };

    adjustor = {
      enable = mkEnableOption "Handheld Daemon TDP control plugin";
      package = mkPackageOption pkgs "adjustor" { };
      loadAcpiCallModule = mkOption {
        type = types.bool;
        description = ''
          Whether to load the acpi_call kernel module.
          Required for TDP control by adjustor on most devices.
        '';
      };
    };

    user = mkOption {
      type = types.str;
      description = ''
@@ -28,13 +44,19 @@ in

  config = mkIf cfg.enable {
    services.handheld-daemon.ui.enable = mkDefault true;
    services.handheld-daemon.adjustor.loadAcpiCallModule = mkDefault cfg.adjustor.enable;
    environment.systemPackages = [
      cfg.package
      hhdPackage
    ]
    ++ lib.optional cfg.ui.enable cfg.ui.package;
    services.udev.packages = [ cfg.package ];
    systemd.packages = [ cfg.package ];

    boot.kernelModules = mkIf cfg.adjustor.loadAcpiCallModule [ "acpi_call" ];
    boot.extraModulePackages = mkIf cfg.adjustor.loadAcpiCallModule [
      config.boot.kernelPackages.acpi_call
    ];

    systemd.services.handheld-daemon = {
      description = "Handheld Daemon";

@@ -48,7 +70,7 @@ in
      ];

      serviceConfig = {
        ExecStart = "${lib.getExe cfg.package} --user ${cfg.user}";
        ExecStart = "${lib.getExe hhdPackage} --user ${cfg.user}";
        Nice = "-12";
        Restart = "on-failure";
        RestartSec = "10";
@@ -56,5 +78,5 @@ in
    };
  };

  meta.maintainers = [ maintainers.appsforartists ];
  meta.maintainers = [ maintainers.toast ];
}
+55 −0
Original line number Diff line number Diff line
{
  fetchFromGitHub,
  lib,
  python3Packages,
  # Dependencies
  kmod,
  util-linux,
}:
python3Packages.buildPythonPackage rec {
  pname = "adjustor";
  version = "3.11.8";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "hhd-dev";
    repo = "adjustor";
    tag = "v${version}";
    hash = "sha256-BS0zV8nan61fTUs3v6nmGBuqPEDjATxBG792ZrrreAI=";
  };

  # This package relies on several programs expected to be on the user's PATH.
  # We take a more reproducible approach by patching the absolute path to each of these required
  # binaries.
  postPatch = ''
    substituteInPlace src/adjustor/core/acpi.py \
      --replace-fail '"modprobe"' '"${lib.getExe' kmod "modprobe"}"'
    substituteInPlace src/adjustor/fuse/utils.py \
      --replace-fail 'f"mount' 'f"${lib.getExe' util-linux "mount"}'
  '';

  build-system = with python3Packages; [
    setuptools
  ];

  dependencies = with python3Packages; [
    rich
    pyroute2
    fuse
    pygobject3
    dbus-python
    kmod
  ];

  # This package doesn't have upstream tests.
  doCheck = false;

  meta = {
    homepage = "https://github.com/hhd-dev/adjustor/";
    description = "Adjustor TDP plugin for Handheld Daemon";
    platforms = lib.platforms.linux;
    license = lib.licenses.gpl3Only;
    maintainers = [ lib.maintainers.toast ];
    mainProgram = "hhd";
  };
}
+15 −8
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  lib,
  python3Packages,
  fetchFromGitHub,
  withAdjustor ? false,

  # dependencies
  systemd,
@@ -13,6 +14,7 @@
  lsof,
  btrfs-progs,
  util-linux,
  adjustor,
}:
python3Packages.buildPythonApplication rec {
  pname = "handheld-daemon";
@@ -79,13 +81,18 @@ python3Packages.buildPythonApplication rec {
    setuptools
  ];

  dependencies = with python3Packages; [
  dependencies =
    with python3Packages;
    [
      evdev
      pyserial
      pyyaml
      rich
      setuptools
      xlib
    ]
    ++ lib.optionals withAdjustor [
      adjustor
    ];

  # This package doesn't have upstream tests.