diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index c356fc56a0eb..b212b81f29d5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -343,6 +343,7 @@ ./services/desktops/accountsservice.nix ./services/desktops/bamf.nix ./services/desktops/blueman.nix + ./services/desktops/cpupower-gui.nix ./services/desktops/dleyna-renderer.nix ./services/desktops/dleyna-server.nix ./services/desktops/pantheon/files.nix diff --git a/nixos/modules/services/desktops/cpupower-gui.nix b/nixos/modules/services/desktops/cpupower-gui.nix new file mode 100644 index 000000000000..f66afc0a3dc1 --- /dev/null +++ b/nixos/modules/services/desktops/cpupower-gui.nix @@ -0,0 +1,56 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.cpupower-gui; +in { + options = { + services.cpupower-gui = { + enable = mkOption { + type = lib.types.bool; + default = false; + example = true; + description = '' + Enables dbus/systemd service needed by cpupower-gui. + These services are responsible for retrieving and modifying cpu power + saving settings. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.cpupower-gui ]; + services.dbus.packages = [ pkgs.cpupower-gui ]; + systemd.user = { + services.cpupower-gui-user = { + description = "Apply cpupower-gui config at user login"; + wantedBy = [ "graphical-session.target" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.cpupower-gui}/bin/cpupower-gui config"; + }; + }; + }; + systemd.services = { + cpupower-gui = { + description = "Apply cpupower-gui config at boot"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.cpupower-gui}/bin/cpupower-gui config"; + }; + }; + cpupower-gui-helper = { + description = "cpupower-gui system helper"; + aliases = [ "dbus-org.rnd2.cpupower_gui.helper.service" ]; + serviceConfig = { + Type = "dbus"; + BusName = "org.rnd2.cpupower_gui.helper"; + ExecStart = "${pkgs.cpupower-gui}/lib/cpupower-gui/cpupower-gui-helper"; + }; + }; + }; + }; +} diff --git a/pkgs/os-specific/linux/cpupower-gui/default.nix b/pkgs/os-specific/linux/cpupower-gui/default.nix new file mode 100644 index 000000000000..2fcc55e14cb3 --- /dev/null +++ b/pkgs/os-specific/linux/cpupower-gui/default.nix @@ -0,0 +1,93 @@ +{ lib +, stdenv +, fetchFromGitHub +, buildPythonApplication +, appstream-glib +, dbus-python +, desktop-file-utils +, gettext +, glib +, gobject-introspection +, gtk3 +, hicolor-icon-theme +, libappindicator +, libhandy +, meson +, ninja +, pkg-config +, pygobject3 +, pyxdg +, systemd +, wrapGAppsHook +}: + +buildPythonApplication rec { + pname = "cpupower-gui"; + version = "1.0.0"; + + # This packages doesn't have a setup.py + format = "other"; + + src = fetchFromGitHub { + owner = "vagnum08"; + repo = pname; + rev = "v${version}"; + sha256 = "05lvpi3wgyi741sd8lgcslj8i7yi3wz7jwl7ca3y539y50hwrdas"; + }; + + nativeBuildInputs = [ + appstream-glib + desktop-file-utils # needed for update-desktop-database + gettext + glib # needed for glib-compile-schemas + gobject-introspection # need for gtk namespace to be available + hicolor-icon-theme # needed for postinstall script + meson + ninja + pkg-config + wrapGAppsHook + + # Python packages + dbus-python + libappindicator + pygobject3 + pyxdg + ]; + + buildInputs = [ + glib + gtk3 + libhandy + ]; + + propagatedBuildInputs = [ + dbus-python + libappindicator + pygobject3 + pyxdg + ]; + + mesonFlags = [ + "-Dsystemddir=${placeholder "out"}/lib/systemd" + ]; + + preConfigure = '' + patchShebangs build-aux/meson/postinstall.py + ''; + + strictDeps = false; + dontWrapGApps = true; + + makeWrapperArgs = [ "\${gappsWrapperArgs[@]}" ]; + + postFixup = '' + wrapPythonProgramsIn $out/lib "$out $propagatedBuildInputs" + ''; + + meta = with lib; { + description = "Change the frequency limits of your cpu and its governor"; + homepage = "https://github.com/vagnum08/cpupower-gui/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ unode ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9453bcc5829f..dffd925fd794 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21138,6 +21138,10 @@ with pkgs; cpufrequtils = callPackage ../os-specific/linux/cpufrequtils { }; + cpupower-gui = python3Packages.callPackage ../os-specific/linux/cpupower-gui { + inherit (pkgs) meson; + }; + cpuset = callPackage ../os-specific/linux/cpuset { pythonPackages = python3Packages; };