about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/edac-utils/default.nix
blob: a30d21fefd8062dbfff0080c8d4039ce06cb93c6 (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
{ lib, stdenv, fetchFromGitHub, perl
, sysfsutils, dmidecode, kmod }:

stdenv.mkDerivation {
  pname = "edac-utils";
  version = "unstable-2023-01-30";

  src = fetchFromGitHub {
    owner = "grondo";
    repo = "edac-utils";
    rev = "8fdc1d40e30f65737fef6c3ddcd1d2cd769f6277";
    hash = "sha256-jZGRrZ1sa4x0/TBJ5GsNVuWakmPNOU+oiOoXdhARunk=";
  };

  # Hard-code program paths instead of using PATH lookups. Also, labels.d and
  # mainboard are for user-configurable data, so do not look for them in Nix
  # store.
  dmidecodeProgram = lib.getExe' dmidecode "dmidecode";
  modprobeProgram = lib.getExe' kmod "modprobe";
  postPatch = ''
    substituteInPlace src/util/edac-ctl.in \
      --replace-fail 'find_prog ("dmidecode")' "\"$dmidecodeProgram\"" \
      --replace-fail 'find_prog ("modprobe")  or exit (1)' "\"$modprobeProgram\"" \
      --replace-fail '"$sysconfdir/edac/labels.d"' '"/etc/edac/labels.d"' \
      --replace-fail '"$sysconfdir/edac/mainboard"' '"/etc/edac/mainboard"'
  '';

  nativeBuildInputs = [ perl ];
  buildInputs = [ perl sysfsutils ];

  configureFlags = [
    "--sysconfdir=/etc"
    "--localstatedir=/var"
  ];

  installFlags = [
    "sysconfdir=\${out}/etc"
  ];

  # SysV init script is not relevant.
  postFixup = ''
    rm -r $out/etc/init.d
  '';

  meta = with lib; {
    homepage = "https://github.com/grondo/edac-utils";
    description = "Handles the reporting of hardware-related memory errors";
    license = licenses.gpl2;
    platforms = platforms.linux;
  };
}