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/id_rsa.pub). It seems it’s not possible to loop.

openssh = {
  authorizedKeys = {
    keys = [
      (builtins.readFile ../authorized_keys/id_rsa.pub)
      "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?

thanks

With builtins.readDir:

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

Thanks! It worked like a charm