Note that tgunnoe pointed in the above issue:
There’s already support for toDeb and toRpm in the official bundlers (which also use nix-bundle): GitHub - NixOS/bundlers: Aggregated bundlers [maintainer=@tomberek, @Artturin]
I checked the code and it’s actually recreating the /nix/store
files (thanks to fpm to recreate deb/rpm/…). So it’s certainly more reliable than my unpatching solution, but it does not benefit from the system’s library (and is therefore closer to an AppImage/flatpack that packs all libraries).
@frostbyte what do you prefer? A more reliable solution that packs everything, or a more experimental approach that integrates with the host?