21 stdenv.mkDerivation (finalAttrs: {
25 src = fetchFromGitHub {
28 rev = finalAttrs.version;
29 hash = "sha256-TOW6jD7ZTA32H4oByaVkDAjUSwo9JSID7WSBYj7ZzBs=";
36 perlPackages.XMLWriter
37 perlPackages.XMLParser
39 depsBuildBuild = [ buildPackages.stdenv.cc ];
47 # used by the build system
48 echo ${finalAttrs.version} > VERSION
50 # Replace /usr paths with Nix store paths
51 substituteInPlace Makefile \
52 --replace-fail "/sbin" "/bin" \
53 --replace-fail "/usr/" "/"
54 substituteInPlace src/isdn/cdb/Makefile \
55 --replace-fail "lex isdn_cdb.lex" "flex isdn_cdb.lex"
56 substituteInPlace hwinfo.pc.in \
57 --replace-fail "prefix=/usr" "prefix=$out"
58 substituteInPlace src/isdn/cdb/cdb_hwdb.h \
59 --replace-fail "/usr/share" "$out/share"
61 # Replace /sbin and /usr/bin paths with Nix store paths
62 substituteInPlace src/hd/hd_int.h \
63 --replace-fail "/sbin/modprobe" "${kmod}/bin/modprobe" \
64 --replace-fail "/sbin/rmmod" "${kmod}/bin/rmmod" \
65 --replace-fail "/usr/bin/udevinfo" "${systemdMinimal}/bin/udevinfo" \
66 --replace-fail "/usr/bin/udevadm" "${systemdMinimal}/bin/udevadm"
68 # Replace /usr/bin/perl
69 patchShebangs src/ids/convert_hd
72 # The pci/usb ids in hwinfo are ancient. We can get a more up-to-date list simply by copying from systemd
74 # since we don't have .git, we cannot run this.
77 cp ${systemdMinimal.src}/hwdb.d/pci.ids src/pci
78 cp ${systemdMinimal.src}/hwdb.d/usb.ids src/usb
79 # taken from https://github.com/openSUSE/hwinfo/blob/c87f449f1d4882c71b0a1e6dc80638224a5baeed/src/ids/update_pci_usb
80 perl -pi -e 'undef $_ if /^C\s/..1' src/usb
81 perl ./convert_hd src/pci
82 perl ./convert_hd src/usb
85 # build tools for build arch
86 make -C src/ids CC=$CC_FOR_BUILD -j $NIX_BUILD_CORES check_hd
87 make -C src/isdn/cdb CC=$CC_FOR_BUILD -j $NIX_BUILD_CORES isdn_cdb mk_isdnhwdb
92 "CC=${stdenv.cc.targetPrefix}cc"
93 "ARCH=${stdenv.hostPlatform.uname.processor}"
95 installFlags = [ "DESTDIR=$(out)" ];
99 version = testers.testVersion { package = finalAttrs.finalPackage; };
100 pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
101 no-usr = testers.testEqualContents {
102 assertion = "There should be no /usr/ paths in the binaries";
103 # There is a bash script that refers to lshal, which is deprecated and not available in Nixpkgs.
104 # We'll allow this line, but nothing else.
105 expected = writeText "expected" ''
106 if [ -x /usr/bin/lshal ] ; then
108 actual = runCommand "actual" { nativeBuildInputs = [ binutils ]; } ''
109 strings ${finalAttrs.finalPackage}/bin/* | grep /usr/ > $out
113 updateScript = gitUpdater { };
117 description = "Hardware detection tool from openSUSE";
118 license = licenses.gpl2Only;
119 homepage = "https://github.com/openSUSE/hwinfo";
120 maintainers = with maintainers; [ bobvanderlinden ];
121 platforms = platforms.linux;
122 mainProgram = "hwinfo";
123 pkgConfigModules = [ "hwinfo" ];