mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-22 04:34:25 +01:00
Create networking abstraction on top of nebula
This commit is contained in:
parent
6804112df6
commit
252abe9443
15 changed files with 223 additions and 165 deletions
|
|
@ -1,58 +0,0 @@
|
|||
{
|
||||
config,
|
||||
self,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.nebula.node;
|
||||
in
|
||||
{
|
||||
options.custom.services.nebula.node.sshd.enable = lib.mkEnableOption "" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.enable && cfg.sshd.enable) {
|
||||
meta.ports.tcp = [ 22 ];
|
||||
|
||||
services = {
|
||||
openssh = {
|
||||
enable = true;
|
||||
openFirewall = false;
|
||||
ports = [ ];
|
||||
listenAddresses = lib.singleton {
|
||||
addr = cfg.address;
|
||||
port = 22;
|
||||
};
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
KbdInteractiveAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
|
||||
nebula.networks.mesh.firewall.inbound =
|
||||
config.custom.services.nebula.peers
|
||||
|> lib.filter (node: node.isClient)
|
||||
|> lib.map (nebula: {
|
||||
port = 22;
|
||||
proto = "tcp";
|
||||
host = nebula.name;
|
||||
});
|
||||
};
|
||||
|
||||
systemd.services.sshd = {
|
||||
requires = [ "nebula@mesh.service" ];
|
||||
after = [ "nebula@mesh.service" ];
|
||||
};
|
||||
|
||||
users.users.seb.openssh.authorizedKeys.keyFiles =
|
||||
self.nixosConfigurations
|
||||
|> lib.filterAttrs (name: _: name != config.networking.hostName)
|
||||
|> lib.attrValues
|
||||
|> lib.filter (value: value.config |> lib.hasAttr "home-manager")
|
||||
|> lib.map (value: value.config.home-manager.users.seb.custom.programs.ssh)
|
||||
|> lib.filter (ssh: ssh.enable)
|
||||
|> lib.map (ssh: ssh.publicKeyPath);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue