Files
nixconfig/systems/gateway/default.nix
soraefir b0f5ef7439 Fix Ssh
2026-05-02 21:39:40 +02:00

23 lines
769 B
Nix

{ config, lib, inputs, ... }:
let
allUsers = lib.concatMap (peer: if peer.syscfg ? users then peer.syscfg.users else []) config.syscfg.peers;
groupedUsers = lib.groupBy (u: u.username) allUsers;
allowedUsernames = map (u: u.username) config.syscfg.users;
activeUsers = lib.filterAttrs (name: _: lib.elem name allowedUsernames) groupedUsers;
in {
imports = [ ./hardware.nix ];
services.openssh.enable = true;
services.openssh.ports = [ 422 ];
services.openssh.extraConfig = activeUsers;#[ 422 ];
users.users = lib.mapAttrs (name: userList: {
openssh.authorizedKeys.keys = lib.unique (
lib.concatMap (u: if u ? pubssh then [ u.pubssh ] else []) userList
);
}) activeUsers
// {
root = {openssh.authorizedKeys.keys = [];};
};
}