Nixos container with zfs

Is there any convenient way to mount a zfs dataset inside an ephemeral nixos declarative container, without mounting it outside in the host system?

cc @uvNikita

Iā€™m personally not using zfs, so unfortunately not familiar with specific details about zfs when it comes to containers. Is there something special with zfs when ephemeral option is enabled in nixos containers?

Maybe containers.<name>.allowedDevices option might be useful here?

Mounting in zfs is weird. The kernel module is not allowed to call the GPL symbol vfs_mount.
Hence in order to mount it calls the userspace mount program. This is however not mount namespace aware and hence you always need to mount zfs on the host before being able to bind mount it to the container.


I figured as much. Thanks for confirming!