Skip to content

Commit

Permalink
hwinfo: use more up-to-date pci.ids / usb.ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Sep 3, 2024
1 parent 61b0313 commit 28f75f3
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions pkgs/by-name/hw/hwinfo/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
runCommand,
validatePkgConfig,
gitUpdater,
buildPackages,
perlPackages,
}:

stdenv.mkDerivation (finalAttrs: {
Expand All @@ -30,17 +32,21 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
flex
validatePkgConfig
perl
perlPackages.XMLWriter
perlPackages.XMLParser
];
depsBuildBuild = [ buildPackages.stdenv.cc ];

buildInputs = [
libuuid
libx86emu
perl
];

postPatch = ''
# used by the build system
echo ${finalAttrs.version} > VERSION
# Replace /usr paths with Nix store paths
substituteInPlace Makefile \
--replace-fail "/sbin" "/bin" \
Expand All @@ -58,12 +64,26 @@ stdenv.mkDerivation (finalAttrs: {
--replace-fail "/sbin/rmmod" "${kmod}/bin/rmmod" \
--replace-fail "/usr/bin/udevinfo" "${systemdMinimal}/bin/udevinfo" \
--replace-fail "/usr/bin/udevadm" "${systemdMinimal}/bin/udevadm"
'';

makeFlags = [
"LIBDIR=/lib"
];
# The pci/usb ids in hwinfo are ancient. We can get a more up-to-date list simply by copying from systemd
preBuild = ''
# since we don't have .git, we cannot run this.
rm git2log
pushd src/ids
cp ${systemdMinimal.src}/hwdb.d/pci.ids src/pci
cp ${systemdMinimal.src}/hwdb.d/usb.ids src/usb
# taken from https://github.com/openSUSE/hwinfo/blob/c87f449f1d4882c71b0a1e6dc80638224a5baeed/src/ids/update_pci_usb
perl -pi -e 'undef $_ if /^C\s/..1' src/usb
perl ./convert_hd src/pci
perl ./convert_hd src/usb
make check_hd CC=$CC_FOR_BUILD
popd
'';

makeFlags = [ "LIBDIR=/lib" ];
installFlags = [ "DESTDIR=$(out)" ];

passthru = {
Expand Down

0 comments on commit 28f75f3

Please sign in to comment.