feat(nixos): Add option to fetch ssh keys from github

This commit is contained in:
Jalil David Salamé Messina 2024-01-15 22:19:06 +01:00
parent 7382e8d0f0
commit 9250a92d5a
Signed by: jalil
GPG key ID: F016B9E770737A0B
2 changed files with 22 additions and 0 deletions

View file

@ -46,6 +46,15 @@ in
status.disabled = false; status.disabled = false;
sudo.disabled = false; sudo.disabled = false;
}; };
programs.ssh.knownHostsFiles =
lib.mapAttrsToList
(username: sha256: builtins.fetchurl {
inherit sha256;
url = "https://github.com/${username}.keys";
})
cfg.importSSHKeysFromGithub;
# Default shell # Default shell
programs.zsh.enable = true; programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh; users.defaultUserShell = pkgs.zsh;

View file

@ -56,6 +56,19 @@ let
description = "Jalil's styling options"; description = "Jalil's styling options";
type = types.submodule styling; type = types.submodule styling;
}; };
importSSHKeysFromGithub = lib.mkOption {
description = lib.mdDoc ''
Import public ssh keys from a github username.
This will fetch the keys from https://github.com/$${username}.keys.
The format is `"$${github-username}" = $${sha256-hash}`. The example
will try to fetch the keys from <https://github.com/jalil-salame.keys>.
'';
default = { };
example = { "jalil-salame" = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; };
type = types.attrsOf types.str;
};
}; };
in in
{ {