Check out builtins.split in the Nix Manual
I have this little snippet in my user configuration:
openssh.authorizedKeys.keys = let
authorizedKeys = pkgs.fetchurl {
url = "<url to public keys>";
sha256 = "1kril7clfay225xdfhpp770gk60g5rp66nr6hzd5gpxvkynyxlrf";
};
in pkgs.lib.splitString "\n" (builtins.readFile
authorizedKeys);
and it works great, I imagine this could be packaged as a cool
function.