1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 makeWrapper,
6 makePerlPath,
7
8 # Perl libraries
9 LWP,
10 LWPProtocolHttps,
11 HTTPMessage,
12 HTTPDate,
13 URI,
14 TryTiny,
15
16 # Required
17 coreutils,
18 curl, # Preferred to using the Perl HTTP libs - according to hw-probe.
19 dmidecode,
20 gnugrep,
21 gnutar,
22 hwinfo,
23 iproute2,
24 kmod,
25 pciutils,
26 perl,
27 smartmontools,
28 usbutils,
29 v4l-utils,
30 xz,
31
32 # Conditionally recommended
33 systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd,
34 systemd,
35
36 # Recommended
37 withRecommended ? true, # Install recommended tools
38 mcelog,
39 hdparm,
40 acpica-tools,
41 drm_info,
42 mesa-demos,
43 memtester,
44 sysstat,
45 cpuid,
46 util-linuxMinimal,
47 xinput,
48 libva-utils,
49 inxi,
50 vulkan-tools,
51 i2c-tools,
52 opensc,
53
54 # Suggested
55 withSuggested ? false, # Install (most) suggested tools
56 hplip,
57 sane-backends,
58# , pnputils # pnputils (lspnp) isn't currently in nixpkgs and appears to be poorly maintained
59}:
60
61stdenv.mkDerivation rec {
62 pname = "hw-probe";
63 version = "1.6.6";
64
65 src = fetchFromGitHub {
66 owner = "linuxhw";
67 repo = pname;
68 rev = version;
69 sha256 = "sha256-8dLfk2k7xG2CXMHfMPrpgq43j3ttj5a0bgNPEahl2rQ=";
70 };
71
72 makeFlags = [ "prefix=$(out)" ];
73
74 nativeBuildInputs = [ makeWrapper ];
75
76 buildInputs = [ perl ];
77
78 makeWrapperArgs =
79 let
80 requiredPrograms = [
81 hwinfo
82 dmidecode
83 smartmontools
84 pciutils
85 usbutils
86 iproute2 # (ip)
87 coreutils # (sort)
88 gnugrep
89 curl
90 gnutar
91 v4l-utils
92 xz
93 kmod # (lsmod)
94 ];
95 recommendedPrograms = [
96 mcelog
97 hdparm
98 acpica-tools
99 drm_info
100 mesa-demos
101 memtester
102 sysstat # (iostat)
103 util-linuxMinimal # (rfkill)
104 xinput
105 libva-utils # (vainfo)
106 inxi
107 vulkan-tools
108 i2c-tools
109 opensc
110 ]
111 # cpuid is only compatible with i686 and x86_64
112 ++ lib.optional (lib.elem stdenv.hostPlatform.system cpuid.meta.platforms) cpuid;
113 conditionallyRecommendedPrograms = lib.optional systemdSupport systemd; # (systemd-analyze)
114 suggestedPrograms = [
115 hplip # (hp-probe)
116 sane-backends # (sane-find-scanner)
117 # pnputils # (lspnp)
118 ];
119 programs =
120 requiredPrograms
121 ++ conditionallyRecommendedPrograms
122 ++ lib.optionals withRecommended recommendedPrograms
123 ++ lib.optionals withSuggested suggestedPrograms;
124 in
125 [
126 "--set"
127 "PERL5LIB"
128 "${makePerlPath [
129 LWP
130 LWPProtocolHttps
131 HTTPMessage
132 URI
133 HTTPDate
134 TryTiny
135 ]}"
136 "--prefix"
137 "PATH"
138 ":"
139 "${lib.makeBinPath programs}"
140 ];
141
142 postInstall = ''
143 wrapProgram $out/bin/hw-probe \
144 $makeWrapperArgs
145 '';
146
147 meta = with lib; {
148 description = "Probe for hardware, check operability and find drivers";
149 homepage = "https://github.com/linuxhw/hw-probe";
150 platforms = with platforms; (linux ++ freebsd ++ netbsd ++ openbsd);
151 license = with licenses; [
152 lgpl21
153 bsdOriginal
154 ];
155 maintainers = with maintainers; [ rehno-lindeque ];
156 mainProgram = "hw-probe";
157 };
158}