Error during rebuild (hwdb.bin)

During a NixOS rebuild, I keep experiencing this error:

┏━ 2 Errors: 
┃ error: Cannot build '/nix/store/w85i1pi13lcwa74dqda60xj4v24l581f-etc.drv'.
┃        Reason: 1 dependency failed.
┃        Output paths:
┃          /nix/store/z8809qv0f8vh50mnnjrxbqbgv2pzylxg-etc
┃ error: Cannot build '/nix/store/lms7h6s1bzqiwyssfd1kbng2rry64681-hwdb.bin.drv'.
┃        Reason: builder failed with exit code 1.
┃        Output paths:
┃          /nix/store/5jyza1f1vk2s966wh3grlnw66qk2kgnx-hwdb.bin
┃        Last 17 log lines:
┃        > Adding hwdb files for package /nix/store/f8plklbbq3gwkq1wfq89i3f4wy8rabzn-systemd-258
┃        > Adding hwdb files for package /nix/store/82gx9bf05pmp9g28l57ihg881vm54dws-ipv6-privacy-exte…
┃        > Adding hwdb files for package /nix/store/kr78wasw9p6zzg56abrh35m2spyd6cgn-ipv6-privacy-exte…
┃        > Adding hwdb files for package /nix/store/rx59fy95s65pdqsf41ca8f2d7afag2s0-lvm2-2.03.35
┃        > Adding hwdb files for package /nix/store/w2h8j8zqs6i9byikrshkff2qwazly2hg-bcache-tools-1.1
┃        > Adding hwdb files for package /nix/store/rkz3md76za1c7vqp61dm1m5gspz9hrcm-upower-1.90.6
┃        > Adding hwdb files for package /nix/store/gmk03jqv483y7s1vs1vvvs50n20grjb3-udisks-2.10.2
┃        > Adding hwdb files for package /nix/store/agw1dpaw4v9pih0mcfp2mdn2qwbnilj2-extra-udev-rules
┃        > Adding hwdb files for package /nix/store/ilwidsc3c7d0n90a1rd0ci1pbwbmppl5-extra-hwdb-file
┃        > Adding hwdb files for package /nix/store/6cfnpccakpy7jacigs8sk06y08hnh497-tlp-1.8.0
┃        > Adding hwdb files for package /nix/store/yw19crigjbkambz2kpqy1x4mlk66zanm-bluez-5.83
┃        > Adding hwdb files for package /nix/store/8afxxifpdjdxqldvzh2rg6frf8w2nb3r-pipewire-1.4.9
┃        > Adding hwdb files for package /nix/store/wrlv2j29x2d48nqvw721kfz09w4dlgh1-libmtp-1.1.22
┃        > Adding hwdb files for package /nix/store/v6la41kfvq8n5avznxzixbzskq0pc5hv-steam-devices-ude…
┃        > Generating hwdb database...
┃        > No hwdb files found, skipping.
┃        > mv: cannot stat 'etc/udev/hwdb.bin': No such file or directory

I suspect this has to do with my filesystem (I use BTRFS); regardless of changes I make to rebuild, such as downgrading back to systemd-257.9, I get the aforementioned error.
But if it is, what’s the solution? I have considered going the nuclear approach and reinstall NixOS, but with ext4 instead. However, we’re currently replacing the internet provider, so re-downloading everything would take forever. :frowning_face:

Any help or pointing towards the right direction would be appreciated.

Store corruption? Try the old

sudo nix-store --repair --verify --check-contents

? (Might take a while to run.)

Or are you doing something strange in the config?

I ran nix-store check earlier, and nothing was printed out, so that wasn’t it. As for the config, can find nixos-related stuff here. I haven’t made changes recently that would be easily linked to the error. I’d be more than happy if it as simple as me missing something obvious, though.

Can you check if there are any hwdb files in any of these packages? They should be in $pkg/etc/udev/hwdb.d/ or $pkg/lib/udev/hwdb.d/. If all of those directories are nonexistent / empty, that would explain the error and would almost certainly mean your store is corrupted.

I don’t know what nix-store check is but the flags do matter here :slight_smile: Maybe an fsck instead will do the trick - either way, I really suspect store/filesystem corruption.

There are .hwdb files in some packages, like systemd and upower (example below), but not others. What is peculiar to me is that none are being added to the database still.

 ls /nix/store/f8plklbbq3gwkq1wfq89i3f4wy8rabzn-systemd-258/lib/udev/hwdb.d
20-acpi-vendor.hwdb               20-pci-classes.hwdb        20-usb-vendor-model.hwdb                60-evdev.hwdb     70-analyzers.hwdb         70-maker-tools.hwdb     70-sound-card.hwdb
20-bluetooth-vendor-product.hwdb  20-pci-vendor-model.hwdb   20-vmbus-class.hwdb                     60-input-id.hwdb  70-av-production.hwdb     70-mouse.hwdb           70-touchpad.hwdb
20-dmi-id.hwdb                    20-sdio-classes.hwdb       60-autosuspend-chromiumos.hwdb          60-keyboard.hwdb  70-cameras.hwdb           70-pda.hwdb             80-ieee1394-unit-function.hwdb
20-net-ifname.hwdb                20-sdio-vendor-model.hwdb  60-autosuspend-fingerprint-reader.hwdb  60-seat.hwdb      70-hardware-wallets.hwdb  70-pointingstick.hwdb   README
20-OUI.hwdb                       20-usb-classes.hwdb        60-autosuspend.hwdb                     60-sensor.hwdb    70-joystick.hwdb          70-software-radio.hwdb

Oh, sorry, I should have phrased better. I meant I ran nix-store --repair --verify --check-contents before, and got no outputs, which I take means there were no problematic paths.

I’ll give fsck a go, though, thank you for the suggestion!

So I ran btrfs scrub for now, since it’s safer for mounted filesystems. I have not observed any errors yet:

necoarc@necoarc:~/ > sudo btrfs scrub start -Bd /
Starting scrub on devid 1

Scrub device /dev/disk/by-uuid/5720bd37-e549-49b6-981a-a3848c74f75c (id 1) done
Scrub started:    Tue Oct 28 00:55:30 2025
Status:           finished
Duration:         0:01:45
Total to scrub:   284.86GiB
Rate:             2.71GiB/s
Error summary:    no errors found

Just to be sure, I’ll run fsck in the morning. Things may hav not gotten clearer yet, but thanks a lot for all the help so far.

Yea that is expected.

And yea, this is what’s weird. If there are any such files, the hwdb.bin derivation should be building just fine. The fact that it isn’t makes no sense to me :confused: I’ve tried building a hwdb.bin with a nixos config that adds that exact same list of packages to it and it built fine for me.

FWIW i built your config and it builds fine. So, I’m even more inclined to think fs issues.
But I also don’t use btrfs, can’t advise on that.

Probably, though no matter the tool, nothing reported fails or corrupted store paths. I ended up reinstalling the system. But that’s okay, I got to try out disko.
Regardless, the issue is “solved”.