summary refs log tree commit diff
path: root/pkgs/tools/system/thinkfan/default.nix
blob: a564c946bcf4fdcb94eaf275411de4266a231761 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ lib
, stdenv
, fetchFromGitHub
, cmake
, libyamlcpp
, pkg-config
, procps
, coreutils
, smartSupport ? false, libatasmart
}:

stdenv.mkDerivation rec {
  pname = "thinkfan";
  version = "1.3.1";

  src = fetchFromGitHub {
    owner = "vmatare";
    repo = "thinkfan";
    rev = version;
    sha256 = "sha256-aREZv+t4QhtfLKOMrneLiRxgnu0fzB8UV8dvr1dnhx4=";
  };

  postPatch = ''
    # fix hardcoded install path
    substituteInPlace CMakeLists.txt --replace /etc $out/etc

    # fix command paths in unit files
    for unit in rcscripts/systemd/*; do
      substituteInPlace "$unit" \
        --replace /bin/kill ${procps}/bin/kill \
        --replace /usr/bin/pkill ${procps}/bin/pkill \
        --replace /usr/bin/sleep ${coreutils}/bin/sleep
    done
  '';

  cmakeFlags = [
    "-DCMAKE_INSTALL_DOCDIR=share/doc/${pname}"
    "-DUSE_NVML=OFF"
    # force install unit files
    "-DSYSTEMD_FOUND=ON"
  ] ++ lib.optional smartSupport "-DUSE_ATASMART=ON";

  nativeBuildInputs = [ cmake pkg-config ];

  buildInputs = [ libyamlcpp ] ++ lib.optional smartSupport libatasmart;

  meta = {
    description = "A simple, lightweight fan control program";
    longDescription = ''
      Thinkfan is a minimalist fan control program. Originally designed
      specifically for IBM/Lenovo Thinkpads, it now supports any kind of
      system via the sysfs hwmon interface (/sys/class/hwmon).
    '';
    license = lib.licenses.gpl3Plus;
    homepage = "https://github.com/vmatare/thinkfan";
    maintainers = with lib.maintainers; [ domenkozar rnhmjoj ];
    platforms = lib.platforms.linux;
  };
}