1{ lib, stdenv, fetchFromGitHub, perl
2, sysfsutils, dmidecode, kmod }:
3
4stdenv.mkDerivation {
5 pname = "edac-utils";
6 version = "unstable-2023-01-30";
7
8 src = fetchFromGitHub {
9 owner = "grondo";
10 repo = "edac-utils";
11 rev = "8fdc1d40e30f65737fef6c3ddcd1d2cd769f6277";
12 hash = "sha256-jZGRrZ1sa4x0/TBJ5GsNVuWakmPNOU+oiOoXdhARunk=";
13 };
14
15 # Hard-code program paths instead of using PATH lookups. Also, labels.d and
16 # mainboard are for user-configurable data, so do not look for them in Nix
17 # store.
18 dmidecodeProgram = lib.getExe' dmidecode "dmidecode";
19 modprobeProgram = lib.getExe' kmod "modprobe";
20 postPatch = ''
21 substituteInPlace src/util/edac-ctl.in \
22 --replace-fail 'find_prog ("dmidecode")' "\"$dmidecodeProgram\"" \
23 --replace-fail 'find_prog ("modprobe") or exit (1)' "\"$modprobeProgram\"" \
24 --replace-fail '"$sysconfdir/edac/labels.d"' '"/etc/edac/labels.d"' \
25 --replace-fail '"$sysconfdir/edac/mainboard"' '"/etc/edac/mainboard"'
26 '';
27
28 # NB edac-utils needs Perl for configure script, but also edac-ctl program is
29 # a Perl script. Perl from buildInputs is used by patchShebangsAuto in
30 # fixupPhase to update the hash bang line.
31 strictDeps = true;
32 nativeBuildInputs = [ perl ];
33 buildInputs = [ perl sysfsutils ];
34
35 installFlags = [
36 "sbindir=${placeholder "out"}/bin"
37 ];
38
39 # SysV init script is not relevant.
40 postInstall = ''
41 rm -r "$out"/etc/init.d
42 '';
43
44 meta = with lib; {
45 homepage = "https://github.com/grondo/edac-utils";
46 description = "Handles the reporting of hardware-related memory errors";
47 license = licenses.gpl2Plus;
48 platforms = platforms.linux;
49 };
50}