nixpkgs/pkgs/os-specific/linux/zenstates/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

55 lines
1.5 KiB
Nix

# Zenstates provides access to a variety of CPU tunables no Ryzen processors.
#
# In particular, I am adding Zenstates because I need it to disable the C6
# sleep state to stabilize wake from sleep on my Lenovo x395 system. After
# installing Zenstates, I need a before-sleep script like so:
#
# before-sleep = pkgs.writeScript "before-sleep" ''
# #!${pkgs.bash}/bin/bash
# ${pkgs.zenstates}/bin/zenstates --c6-disable
# '';
#
# ...
#
# systemd.services.before-sleep = {
# description = "Jobs to run before going to sleep";
# serviceConfig = {
# Type = "oneshot";
# ExecStart = "${before-sleep}";
# };
# wantedBy = [ "sleep.target" ];
# before = [ "sleep.target" ];
# };
{ lib, stdenv, fetchFromGitHub, python3 }:
stdenv.mkDerivation rec {
pname = "zenstates";
version = "0.0.1";
src = fetchFromGitHub {
owner = "r4m0n";
repo = "ZenStates-Linux";
rev = "0bc27f4740e382f2a2896dc1dabfec1d0ac96818";
sha256 = "1h1h2n50d2cwcyw3zp4lamfvrdjy1gjghffvl3qrp6arfsfa615y";
};
buildInputs = [ python3 ];
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin
cp $src/zenstates.py $out/bin/zenstates
chmod +x $out/bin/zenstates
patchShebangs --build $out/bin/zenstates
'';
meta = with lib; {
description = "Linux utility for Ryzen processors and motherboards";
homepage = "https://github.com/r4m0n/ZenStates-Linux";
license = licenses.mit;
maintainers = with maintainers; [ savannidgerinel ];
platforms = platforms.linux;
};
}