1. boot.initrd.extraUtilsCommands = ''
  2. # Put thin-provisioning-tools into extra-utils and patch lvm accordingly.
  3. # NOTE: this works only because thin-provisioning-tools string, including
  4. # version, is longer than extra-utils string. The difference is zeroed. If
  5. # it would be vice versa there is a chance it would not work because the
  6. # stuff after the full path to the tool would be overwritten. Although there
  7. # seem to be some other, documentation, string just behind the full path
  8. # name which might not be that important... Anyways, not spending time
  9. # to figure out how to avoid the patching in case it is not possible doing
  10. # the proper way.
  11. for BIN in ${pkgs.thin-provisioning-tools}/bin/*; do
  12. copy_bin_and_libs $BIN
  13. SRC="(?<all>/[a-zA-Z0-9/]+/[0-9a-z]{32}-[0-9a-z-.]+(?<exe>/bin/$(basename $BIN)))"
  14. REP="\"$out\" . \$+{exe} . \"\\x0\" x (length(\$+{all}) - length(\"$out\" . \$+{exe}))"
  15. PRP="s,$SRC,$REP,ge"
  16. ${pkgs.perl}/bin/perl -p -i -e "$PRP" $out/bin/lvm
  17. done
  18. '';
  19. boot.initrd.extraUtilsCommandsTest = ''
  20. # The thin-provisioning-tools use pdata_tools binary as a link target of
  21. # supported utils so it is enough to check only one, the others should
  22. # "just" work...
  23. $out/bin/pdata_tools cache_check -V
  24. '';
  25. boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" "dm_persistent_data" "dm_bio_prison" "dm_bufio" "libcrc32c" "crc32c_generic" "dm_cache_smq" ];
  26. boot.initrd.kernelModules = [ "dm_cache" ];

Makes lvmcache working in initrd on NixOS.