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
79 # The pci/usb ids in hwinfo are ancient. We can get a more up-to-date list simply by copying from systemd
81 # since we don't have .git, we cannot run this.
84 cp ${systemdMinimal.src}/hwdb.d/pci.ids src/pci
85 cp ${systemdMinimal.src}/hwdb.d/usb.ids src/usb
86 # taken from https://github.com/openSUSE/hwinfo/blob/c87f449f1d4882c71b0a1e6dc80638224a5baeed/src/ids/update_pci_usb
87 perl -pi -e 'undef $_ if /^C\s/..1' src/usb
88 perl ./convert_hd src/pci
89 perl ./convert_hd src/usb
92 # build tools for build arch
93 make -C src/ids CC=$CC_FOR_BUILD -j $NIX_BUILD_CORES check_hd
94 make -C src/isdn/cdb CC=$CC_FOR_BUILD -j $NIX_BUILD_CORES isdn_cdb mk_isdnhwdb
99 "CC=${stdenv.cc.targetPrefix}cc"
100 "ARCH=${stdenv.hostPlatform.uname.processor}"
102 installFlags = [ "DESTDIR=$(out)" ];
104 enableParallelBuilding = false; # broken parallel dependencies
107 moveToOutput bin "$bin"
108 moveToOutput lib "$lib"
113 version = testers.testVersion { package = finalAttrs.finalPackage; };
114 pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
115 no-usr = testers.testEqualContents {
116 assertion = "There should be no /usr/ paths in the binaries";
117 # There is a bash script that refers to lshal, which is deprecated and not available in Nixpkgs.
118 # We'll allow this line, but nothing else.
119 expected = writeText "expected" ''
120 if [ -x /usr/bin/lshal ] ; then
122 actual = runCommand "actual" { nativeBuildInputs = [ binutils ]; } ''
123 strings ${finalAttrs.finalPackage}/bin/* | grep /usr/ > $out
127 updateScript = gitUpdater { };
131 description = "Hardware detection tool from openSUSE";
132 license = licenses.gpl2Only;
133 homepage = "https://github.com/openSUSE/hwinfo";
134 maintainers = with maintainers; [ bobvanderlinden ];
135 platforms = platforms.linux;
136 mainProgram = "hwinfo";
137 pkgConfigModules = [ "hwinfo" ];