pathsInNixDB isn't a very accurate name when a Nix store image is built (virtualisation.useNixStoreImage); rename it to additionalPaths, which should be general enough to cover both cases.
The library does not depend on stdenv, that `stdenv` exposes `lib` is an artifact of the ancient origins of nixpkgs.