How to add multiple ssh keys from a folder?

Hello everyone, I’m building a raspberry image and I would like to include the public ssh keys from a folder. I was wondering how can I do this. Any thoughts?

At the moment I’m able to read just a single file using the (builtins.readFile ../authorized_keys/ It seems it’s not possible to loop.

openssh = {
  authorizedKeys = {
    keys = [
      (builtins.readFile ../authorized_keys/
      "ssh-ed25519 ..."

I was thinking maybe it’s possible to add the whole folder or something like that. If not, what approach would you take?


With builtins.readDir:

  files = lib.filterAttrs (k: v: v == "regular" && lib.hasSuffix ".pub" k) (builtins.readDir ./.);
lib.mapAttrsToList (k: v: builtins.readFile "${./.}/${k}") files

Thanks! It worked like a charm