This commit is contained in:
commit
fef2377502
174 changed files with 7423 additions and 0 deletions
53
nixos-modules/meta/hosts.nix
Normal file
53
nixos-modules/meta/hosts.nix
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.qois.meta.hosts;
|
||||
in
|
||||
{
|
||||
options.qois.meta.hosts = mkOption {
|
||||
type = types.attrsOf (
|
||||
types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
hostName = mkOption {
|
||||
type = types.strMatching "^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$";
|
||||
default = name;
|
||||
description = "The host's name. See networking.hostName for more details.";
|
||||
};
|
||||
|
||||
sshKey = mkOption {
|
||||
type = types.nullOr (types.strMatching "^ssh-ed25519 [a-zA-Z0-9/+]{68}$");
|
||||
default = null;
|
||||
example = "ssh-ed25519 AAAAbcdefgh....xyz root@myhost";
|
||||
description = lib.mdDoc ''
|
||||
The ssh public key of ed25519 type.
|
||||
|
||||
May be fetched with `ssh-keyscan example.com`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = { };
|
||||
description = "Host configuration properties options";
|
||||
};
|
||||
config =
|
||||
let
|
||||
hostsWithSshKey = lib.filterAttrs (name: hostCfg: hostCfg.sshKey != null) cfg;
|
||||
in
|
||||
{
|
||||
programs.ssh.knownHosts = lib.mapAttrs (name: hostCfg: {
|
||||
publicKey = hostCfg.sshKey;
|
||||
}) hostsWithSshKey;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue