about summary refs log tree commit diff
path: root/pkgs/by-name/cp/cpu-energy-meter/package.nix
blob: 6d31da594645c7c89bb467cb63631e3f5186ae4d (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
{ lib
, stdenv
, fetchFromGitHub
, libcap
}:
stdenv.mkDerivation rec {
  pname = "cpu-energy-meter";
  version = "1.2";

  src = fetchFromGitHub {
    owner = "sosy-lab";
    repo = "cpu-energy-meter";
    rev = version;
    hash = "sha256-QW65Z8mRYLHcyLeOtNAHjwPNWAUP214wqIYclK+whFw=";
  };

  postPatch = ''
    substituteInPlace Makefile \
      --replace "DESTDIR :=" "DESTDIR := $out" \
      --replace "PREFIX := /usr/local" "PREFIX :="
  '';

  buildInputs = [ libcap ];

  env.NIX_CFLAGS_COMPILE = "-fcommon";

  postInstall = ''
    install -Dm444 -t $out/etc/udev/rules.d $src/debian/additional_files/59-msr.rules
  '';

  meta = with lib; {
    description = "A tool for measuring energy consumption of Intel CPUs";
    homepage = "https://github.com/sosy-lab/cpu-energy-meter";
    changelog = "https://github.com/sosy-lab/cpu-energy-meter/blob/main/CHANGELOG.md";
    maintainers = with maintainers; [ lorenzleutgeb ];
    license = licenses.bsd3;
    platforms = [ "x86_64-linux" ];
    mainProgram = "cpu-energy-meter";
  };
}