Commit 73bde868f5f8
Changed files (1)
users
root
users/root/default.nix
@@ -1,8 +1,21 @@
{ config, lib, pkgs, ... }:
-with lib; {
+let
+ inherit (lib) lists attrsets mkIf optionals versionOlder;
+ secretPath = ../../secrets/machines.nix;
+ secretCondition = (builtins.pathExists secretPath);
+
+ isAuthorized = p: builtins.isAttrs p && p.authorized or false;
+ authorizedKeys = lists.optionals secretCondition (
+ attrsets.mapAttrsToList
+ (name: value: value.key)
+ (attrsets.filterAttrs (name: value: isAuthorized value) (import secretPath).ssh)
+ );
+in
+{
users.users.root = {
shell = mkIf config.programs.zsh.enable pkgs.zsh;
+ openssh.authorizedKeys.keys = authorizedKeys;
};
home-manager.users.root = lib.mkMerge (
[