1{ lib
2, stdenv
3, fetchurl
4, autoreconfHook
5, enableMail ? false
6, gnused
7, hostname
8, mailutils
9, IOKit
10, ApplicationServices
11}:
12
13let
14 dbrev = "5388";
15 drivedbBranch = "RELEASE_7_3_DRIVEDB";
16 driverdb = fetchurl {
17 url = "https://sourceforge.net/p/smartmontools/code/${dbrev}/tree/branches/${drivedbBranch}/smartmontools/drivedb.h?format=raw";
18 sha256 = "sha256-0dtLev4JjeHsS259+qOgg19rz4yjkeX4D3ooUgS4RTI=";
19 name = "smartmontools-drivedb.h";
20 };
21 scriptPath = lib.makeBinPath ([ gnused hostname ] ++ lib.optionals enableMail [ mailutils ]);
22
23in
24stdenv.mkDerivation rec {
25 pname = "smartmontools";
26 version = "7.3";
27
28 src = fetchurl {
29 url = "mirror://sourceforge/smartmontools/${pname}-${version}.tar.gz";
30 sha256 = "sha256-pUT4gI0MWM+w50JMoYQcuFipdJIrA11QXU5MJIvjois=";
31 };
32
33 patches = [
34 # fixes darwin build
35 ./smartmontools.patch
36 ];
37 postPatch = ''
38 cp -v ${driverdb} drivedb.h
39 '';
40
41 configureFlags = [ "--with-scriptpath=${scriptPath}" ];
42
43 nativeBuildInputs = [ autoreconfHook ];
44 buildInputs = lib.optionals stdenv.isDarwin [ IOKit ApplicationServices ];
45 enableParallelBuilding = true;
46
47 meta = with lib; {
48 description = "Tools for monitoring the health of hard drives";
49 homepage = "https://www.smartmontools.org/";
50 license = licenses.gpl2Plus;
51 maintainers = with maintainers; [ Frostman ];
52 platforms = with platforms; linux ++ darwin;
53 mainProgram = "smartctl";
54 };
55}