@@ -140,6 +140,17 @@ in
140140 this once.
141141 '';
142142 };
143+
144+ requestEncryptionCredentials = mkOption {
145+ type = types.bool;
146+ default = config.boot.zfs.enableUnstable;
147+ description = ''
148+ Request encryption keys or passwords for all encrypted datasets on import.
149+
150+ Dataset encryption is only supported in zfsUnstable at the moment.
151+ '';
152+ };
153+
143154 };
144155
145156 services.zfs.autoSnapshot = {
@@ -263,6 +274,10 @@ in
263274 assertion = !cfgZfs.forceImportAll || cfgZfs.forceImportRoot;
264275 message = "If you enable boot.zfs.forceImportAll, you must also enable boot.zfs.forceImportRoot";
265276 }
277+ {
278+ assertion = cfgZfs.requestEncryptionCredentials -> cfgZfs.enableUnstable;
279+ message = "This feature is only available for zfs unstable. Set the NixOS option boot.zfs.enableUnstable.";
280+ }
266281 ];
267282
268283 boot = {
@@ -306,6 +321,9 @@ in
306321 done
307322 echo
308323 if [[ -n "$msg" ]]; then echo "$msg"; fi
324+ ${lib.optionalString cfgZfs.requestEncryptionCredentials ''
325+ zfs load-key -a
326+ ''}
309327 '') rootPools));
310328 };
311329