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

adjustor: init at 3.6.1 #347279

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions nixos/modules/services/hardware/handheld-daemon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ in
package = mkPackageOption pkgs "handheld-daemon-ui" { };
};

adjustor = {
enable = mkEnableOption "Handheld Daemon TDP control plugin";
package = mkPackageOption pkgs "adjustor" { };
};

user = mkOption {
type = types.str;
description = ''
Expand All @@ -26,13 +31,22 @@ in
};
};

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

boot.extraModulePackages = mkIf cfg.adjustor.enable [
config.boot.kernelPackages.acpi_call
];

systemd.services.handheld-daemon = {
description = "Handheld Daemon";
Expand All @@ -47,7 +61,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";
Expand Down
57 changes: 57 additions & 0 deletions pkgs/by-name/ad/adjustor/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
fetchFromGitHub,
lib,
python3Packages,

# Dependencies
kmod,
util-linux,
}:
python3Packages.buildPythonPackage rec {
pname = "adjustor";
version = "3.6.1";
pyproject = true;

src = fetchFromGitHub {
owner = "hhd-dev";
repo = "adjustor";
rev = "refs/tags/v${version}";
hash = "sha256-A5IdwuhsK9umMtsUR7CpREGxbTYuJNPV4MT+6wqcWT8=";
};

# 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 = with lib; {
homepage = "https://github.com/hhd-dev/adjustor/";
description = "Adjustor TDP plugin for Handheld Daemon";
platforms = platforms.linux;
license = licenses.gpl3Only;
maintainers = with maintainers; [ toast ];
mainProgram = "hhd";
};
}
4 changes: 4 additions & 0 deletions pkgs/by-name/ha/handheld-daemon/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
python3Packages,
fetchFromGitHub,
withAdjustor ? false,

# dependencies
systemd,
Expand All @@ -11,6 +12,7 @@
efibootmgr,
dbus,
lsof,
adjustor
}:
python3Packages.buildPythonApplication rec {
pname = "handheld-daemon";
Expand Down Expand Up @@ -69,6 +71,8 @@ python3Packages.buildPythonApplication rec {
rich
setuptools
xlib
] ++ lib.optionals withAdjustor [
adjustor
];

# This package doesn't have upstream tests.
Expand Down
Loading