mirror of
https://github.com/RGBCube/ncc
synced 2025-07-27 18:17:44 +00:00
feat: automatically generate ssh matchblocks
This commit is contained in:
parent
d62084eb03
commit
c2acac6f3e
1 changed files with 14 additions and 22 deletions
|
@ -1,7 +1,19 @@
|
|||
{ self, config, lib, pkgs, ... }: let
|
||||
inherit (lib) enabled mkIf;
|
||||
inherit (lib) enabled mkIf filterAttrs attrNames mapAttrs head remove;
|
||||
|
||||
controlPath = "~/.ssh/control";
|
||||
|
||||
hosts = self.nixosConfigurations
|
||||
|> filterAttrs (_: value: value.config.services.openssh.enable)
|
||||
|> mapAttrs (_: value: {
|
||||
hostname = value.config.networking.ipv4.address;
|
||||
|
||||
user = value.config.users.users
|
||||
|> attrNames
|
||||
|> remove "root"
|
||||
|> remove "backup"
|
||||
|> head;
|
||||
});
|
||||
in {
|
||||
secrets.sshConfig = {
|
||||
file = ./config.age;
|
||||
|
@ -24,33 +36,13 @@ in {
|
|||
|
||||
includes = [ config.secrets.sshConfig.path ];
|
||||
|
||||
matchBlocks = {
|
||||
matchBlocks = hosts // {
|
||||
"*" = {
|
||||
setEnv.COLORTERM = "truecolor";
|
||||
setEnv.TERM = "xterm-256color";
|
||||
|
||||
identityFile = "~/.ssh/id";
|
||||
};
|
||||
|
||||
# TODO: Maybe autogenerate these?
|
||||
|
||||
best = {
|
||||
hostname = self.best.networking.ipv4.address;
|
||||
user = "the";
|
||||
port = 2222;
|
||||
};
|
||||
|
||||
disk = {
|
||||
hostname = self.disk.networking.ipv4.address;
|
||||
user = "floppy";
|
||||
port = 2222;
|
||||
};
|
||||
|
||||
nine = {
|
||||
hostname = self.nine.networking.ipv4.address;
|
||||
user = "seven";
|
||||
port = 2222;
|
||||
};
|
||||
};
|
||||
};
|
||||
}];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue