liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f2d1789ad78779faf4d6cb28e79e2725a63fa98f
parent 2594239bbc64d3d830a7e2fdba4b19527abb65a4
Author: Daniel Barlow <dan@telent.net>
Date:   Fri, 10 Mar 2023 23:13:32 +0000

add openssh authorized_keys

Diffstat:
Mmodules/users.nix | 31+++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/modules/users.nix b/modules/users.nix @@ -42,6 +42,10 @@ in { type = types.str; default = "/bin/sh"; }; + openssh.authorizedKeys.keys = mkOption { + type = types.listOf types.str; + default = []; + }; }; }); }; @@ -59,12 +63,27 @@ in { }); }; }; - config = { - filesystem = dir { - etc = dir { - passwd = { file = passwd-file; }; - group = { file = group-file; }; + config = + let authorized_key_files = + lib.attrsets.mapAttrs + (name: val: dir { + ".ssh" = dir { + authorized_keys = { + type = "f"; + mode = "0400"; + file = lib.concatStringsSep + "\n" val.openssh.authorizedKeys.keys; + }; + }; + }) + config.users; + in { + filesystem = dir { + etc = dir { + passwd = { file = passwd-file; }; + group = { file = group-file; }; + }; + home = dir authorized_key_files; }; }; - }; }