1# Zenstates provides access to a variety of CPU tunables no Ryzen processors.
2#
3# In particular, I am adding Zenstates because I need it to disable the C6
4# sleep state to stabilize wake from sleep on my Lenovo x395 system. After
5# installing Zenstates, I need a before-sleep script like so:
6#
7# before-sleep = pkgs.writeScript "before-sleep" ''
8# #!${pkgs.bash}/bin/bash
9# ${pkgs.zenstates}/bin/zenstates --c6-disable
10# '';
11#
12# ...
13#
14# systemd.services.before-sleep = {
15# description = "Jobs to run before going to sleep";
16# serviceConfig = {
17# Type = "oneshot";
18# ExecStart = "${before-sleep}";
19# };
20# wantedBy = [ "sleep.target" ];
21# before = [ "sleep.target" ];
22# };
23
24{ lib, stdenv, fetchFromGitHub, python3 }:
25stdenv.mkDerivation rec {
26 pname = "zenstates";
27 version = "0.0.1";
28
29 src = fetchFromGitHub {
30 owner = "r4m0n";
31 repo = "ZenStates-Linux";
32 rev = "0bc27f4740e382f2a2896dc1dabfec1d0ac96818";
33 sha256 = "1h1h2n50d2cwcyw3zp4lamfvrdjy1gjghffvl3qrp6arfsfa615y";
34 };
35
36 buildInputs = [ python3 ];
37
38 installPhase = ''
39 mkdir -p $out/bin
40 cp $src/zenstates.py $out/bin/zenstates
41 chmod +x $out/bin/zenstates
42 patchShebangs --build $out/bin/zenstates
43 '';
44
45 meta = with lib; {
46 description = "Linux utility for Ryzen processors and motherboards";
47 homepage = "https://github.com/r4m0n/ZenStates-Linux";
48 license = licenses.mit;
49 maintainers = with maintainers; [ savannidgerinel ];
50 platforms = platforms.linux;
51 };
52}