about summary refs log tree commit diff
path: root/pkgs/tools/system/hw-probe/default.nix
blob: 8b190087ffd5755956d25a209ecd9444fdd31cd8 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{ lib
, stdenv
, fetchFromGitHub
, makeWrapper
, makePerlPath

# Perl libraries
, LWP
, LWPProtocolHttps
, HTTPMessage
, HTTPDate
, URI
, TryTiny

# Required
, coreutils
, curl # Preferred to using the Perl HTTP libs - according to hw-probe.
, dmidecode
, edid-decode
, gnugrep
, gnutar
, hwinfo
, iproute2
, kmod
, pciutils
, perl
, smartmontools
, usbutils
, xz

# Conditionally recommended
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
, systemd

# Recommended
, withRecommended ? true # Install recommended tools
, mcelog
, hdparm
, acpica-tools
, drm_info
, mesa-demos
, memtester
, sysstat
, cpuid
, util-linuxMinimal
, xinput
, libva-utils
, inxi
, vulkan-tools
, i2c-tools
, opensc

# Suggested
, withSuggested ? false # Install (most) suggested tools
, hplip
, sane-backends
# , pnputils # pnputils (lspnp) isn't currently in nixpkgs and appears to be poorly maintained
}:

stdenv.mkDerivation rec {
  pname = "hw-probe";
  version = "1.6.5";

  src = fetchFromGitHub {
    owner = "linuxhw";
    repo = pname;
    rev = version;
    sha256 = "sha256-WlLSgjVLqGGtwCyyUn9X3XbE2Yhz6LD245+U2JgGd+k=";
  };

  makeFlags = [ "prefix=$(out)" ];

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = [ perl ];

  makeWrapperArgs =
    let
      requiredPrograms = [
        hwinfo
        dmidecode
        smartmontools
        pciutils
        usbutils
        edid-decode
        iproute2 # (ip)
        coreutils # (sort)
        gnugrep
        curl
        gnutar
        xz
        kmod # (lsmod)
      ];
      recommendedPrograms = [
        mcelog
        hdparm
        acpica-tools
        drm_info
        mesa-demos
        memtester
        sysstat # (iostat)
        util-linuxMinimal # (rfkill)
        xinput
        libva-utils # (vainfo)
        inxi
        vulkan-tools
        i2c-tools
        opensc
      ]
      # cpuid is only compatible with i686 and x86_64
      ++ lib.optional (lib.elem stdenv.hostPlatform.system cpuid.meta.platforms) cpuid;
      conditionallyRecommendedPrograms = lib.optional systemdSupport systemd; # (systemd-analyze)
      suggestedPrograms = [
        hplip # (hp-probe)
        sane-backends # (sane-find-scanner)
        # pnputils # (lspnp)
      ];
      programs =
        requiredPrograms
        ++ conditionallyRecommendedPrograms
        ++ lib.optionals withRecommended recommendedPrograms
        ++ lib.optionals withSuggested suggestedPrograms;
    in [
      "--set" "PERL5LIB" "${makePerlPath [ LWP LWPProtocolHttps HTTPMessage URI HTTPDate TryTiny ]}"
      "--prefix" "PATH" ":" "${lib.makeBinPath programs}"
    ];

  postInstall = ''
    wrapProgram $out/bin/hw-probe \
      $makeWrapperArgs
  '';

  meta = with lib; {
    description = "Probe for hardware, check operability and find drivers";
    homepage = "https://github.com/linuxhw/hw-probe";
    platforms = with platforms; (linux ++ freebsd ++ netbsd ++ openbsd);
    license = with licenses; [ lgpl21 bsdOriginal ];
    maintainers = with maintainers; [ rehno-lindeque  ];
    mainProgram = "hw-probe";
  };
}