zfs: add option to use kernel keyring for encryption credentials

Changed files
+3 -1
nixos
modules
tasks
filesystems
+3 -1
nixos/modules/tasks/filesystems/zfs.nix
···
tries=3
success=false
while [[ $success != true ]] && [[ $tries -gt 0 ]]; do
-
${systemd}/bin/systemd-ask-password --timeout=${toString cfgZfs.passwordTimeout} "Enter key for $ds:" | ${cfgZfs.package}/sbin/zfs load-key "$ds" \
&& success=true \
|| tries=$((tries - 1))
done
···
an interactive prompt (keylocation=prompt) and from a file (keylocation=file://).
'';
};
passwordTimeout = lib.mkOption {
type = lib.types.int;
···
tries=3
success=false
while [[ $success != true ]] && [[ $tries -gt 0 ]]; do
+
${systemd}/bin/systemd-ask-password ${lib.optionalString cfgZfs.useKeyringForCredentials ("--keyname=zfs-$ds")} --timeout=${toString cfgZfs.passwordTimeout} "Enter key for $ds:" | ${cfgZfs.package}/sbin/zfs load-key "$ds" \
&& success=true \
|| tries=$((tries - 1))
done
···
an interactive prompt (keylocation=prompt) and from a file (keylocation=file://).
'';
};
+
+
useKeyringForCredentials = lib.mkEnableOption "Uses the kernel keyring for encryption credentials with keyname=zfs-<poolname>";
passwordTimeout = lib.mkOption {
type = lib.types.int;