add nova
This commit is contained in:
parent
1c272b7ec1
commit
49237cd86d
15 changed files with 152 additions and 55 deletions
10
clients/nova/continuwuity.nix
Normal file
10
clients/nova/continuwuity.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
quad.matrix = {
|
||||
enable = true;
|
||||
domain = "polyphony.chat";
|
||||
settings.well_known = {
|
||||
support_email = "info@polyphony.chat";
|
||||
support_mxid = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
16
clients/nova/flori.nix
Normal file
16
clients/nova/flori.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
users = {
|
||||
mutableUsers = true;
|
||||
users.flori = {
|
||||
isNormalUser = true;
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIcXzWUeVwJN7iPxMT/1lhJySY4t6Z2/fH/GHVuzQFr6 cardno:32_241_564"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINBnstd9HyyIjfXWfGymWDcRlK9nZuqgTIcueiqPUDaQ star@starforge"
|
||||
];
|
||||
hashedPasswordFile = config.age.secrets."initialFloriPassword.age".path;
|
||||
description = "Flori";
|
||||
extraGroups = [ "wheel" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
7
clients/nova/hardware-configuration.nix
Normal file
7
clients/nova/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
boot.kernelParams = [ "ip=dhcp" ];
|
||||
boot.initrd.availableKernelModules = [
|
||||
"virtio_pci"
|
||||
"virtio_net"
|
||||
];
|
||||
}
|
||||
20
clients/nova/unlock-ssh-initrd.nix
Normal file
20
clients/nova/unlock-ssh-initrd.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
fileSystems."/".options = [ "x-systemd.device-timeout=0" ];
|
||||
networking.firewall.allowedTCPPorts = [ 222 ];
|
||||
boot = {
|
||||
loader.grub.enable = false;
|
||||
initrd = {
|
||||
systemd = {
|
||||
enable = true;
|
||||
users.root.shell = "/bin/systemd-tty-ask-password-agent";
|
||||
};
|
||||
network.ssh = {
|
||||
enable = true;
|
||||
port = 222;
|
||||
hostKeys = [ "/etc/ssh/ssh_host_ed25519_key_initrd" ];
|
||||
authorizedKeys = config.users.users.ava.openssh.authorizedKeys.keys;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
35
clients/quadraticserver/disko.nix
Normal file
35
clients/quadraticserver/disko.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{ inputs, ... }:
|
||||
{
|
||||
imports = [ inputs.disko.nixosModules.disko ];
|
||||
disko.devices.disk.main = {
|
||||
type = "disk";
|
||||
device = "/dev/sda";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
size = "1M";
|
||||
type = "EF02"; # for grub MBR
|
||||
};
|
||||
ESP = {
|
||||
size = "1G";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ in
|
|||
matrix-ooye = {
|
||||
enable = true;
|
||||
homeserver = client;
|
||||
homeserverName = "federated.nexus";
|
||||
homeserverName = server_name;
|
||||
discordTokenPath = config.age.secrets."discordToken.age".path;
|
||||
discordClientSecretPath = config.age.secrets."discordClientSecret.age".path;
|
||||
socket = "8081";
|
||||
|
|
|
|||
|
|
@ -1,39 +1,10 @@
|
|||
{ lib, ... }:
|
||||
{
|
||||
systemd.services.continuwuity.serviceConfig.Restart = lib.mkForce "always";
|
||||
|
||||
services =
|
||||
let
|
||||
domain = "federated.nexus";
|
||||
subdomain = "matrix.${domain}";
|
||||
socket = "/var/run/continuwuity/continuwuity.sock";
|
||||
in
|
||||
{
|
||||
matrix-continuwuity = {
|
||||
quad.matrix = rec {
|
||||
enable = true;
|
||||
group = "caddy";
|
||||
settings.global = {
|
||||
server_name = domain;
|
||||
unix_socket_path = socket;
|
||||
new_user_displayname_suffix = "";
|
||||
allow_public_room_directory_over_federation = true;
|
||||
trusted_servers = [
|
||||
"matrix.org"
|
||||
"tchncs.de"
|
||||
"maunium.net"
|
||||
];
|
||||
ignore_messages_from_server_names = [ ];
|
||||
url_preview_domain_explicit_allowlist = [ "*" ];
|
||||
|
||||
well_known = {
|
||||
client = "https://${subdomain}";
|
||||
server = "${subdomain}:443";
|
||||
domain = "federated.nexus";
|
||||
settings.well_known = {
|
||||
support_email = "henry@henryhiles.com";
|
||||
support_mxid = "@quadradical:${domain}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
caddy.virtualHosts."${subdomain}".extraConfig = "reverse_proxy unix/${socket}";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
1
clients/quadraticserver/ssh.nix
Normal file
1
clients/quadraticserver/ssh.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ services.openssh.ports = [ 2222 ]; }
|
||||
|
|
@ -158,6 +158,10 @@
|
|||
type = "server";
|
||||
graphical = false;
|
||||
};
|
||||
"nova" = {
|
||||
type = "server";
|
||||
graphical = false;
|
||||
};
|
||||
"quadphone" = {
|
||||
type = "mobile";
|
||||
system = "aarch64-linux";
|
||||
|
|
|
|||
|
|
@ -3,5 +3,7 @@
|
|||
Host server
|
||||
HostName ssh.federated.nexus
|
||||
Port 2222
|
||||
Host nova
|
||||
HostName nova.bitfl0wer.de
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ let
|
|||
in
|
||||
{
|
||||
imports = [ "${modulesPath}/image/repart.nix" ];
|
||||
boot.loader.grub.enable = false;
|
||||
|
||||
systemd.repart = {
|
||||
enable = true;
|
||||
partitions."03-root".Type = "root";
|
||||
|
|
|
|||
52
modules/server/caddy.nix
Normal file
52
modules/server/caddy.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.services.caddy.authedHosts = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.lines;
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
config = {
|
||||
systemd.services.caddy.serviceConfig.Restart = lib.mkForce "always";
|
||||
networking.firewall.allowedTCPPorts = [ 443 ];
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
email = "henry@henryhiles.com";
|
||||
environmentFile = config.age.secrets."base64JwtSecret.age".path;
|
||||
package = pkgs.caddy.withPlugins {
|
||||
plugins = [
|
||||
"github.com/ggicci/caddy-jwt@v1.1.0"
|
||||
"pkg.jsn.cam/caddy-defender@v0.9.0"
|
||||
];
|
||||
hash = "sha256-DO4jgD7UWva6z2/pQT+4RfBfKoBAAZVCgjXC/unYCQk=";
|
||||
};
|
||||
|
||||
virtualHosts = lib.mapAttrs (domain: host: {
|
||||
extraConfig =
|
||||
let
|
||||
auth = "https://auth.federated.nexus";
|
||||
in
|
||||
''
|
||||
handle_errors 401 {
|
||||
redir https://federated.nexus/login?redirect_uri=${auth}/bridge?redirect_uri=https://${domain}{uri} 302
|
||||
}
|
||||
|
||||
route {
|
||||
jwtauth {
|
||||
from_cookies id_token
|
||||
sign_key {$JWK_SECRET}
|
||||
issuer_whitelist ${auth}
|
||||
audience_whitelist proxy
|
||||
}
|
||||
|
||||
${host}
|
||||
}
|
||||
'';
|
||||
}) config.services.caddy.authedHosts;
|
||||
};
|
||||
};
|
||||
}
|
||||
47
modules/server/continuwuity.nix
Normal file
47
modules/server/continuwuity.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
options.quad.matrix = {
|
||||
enable = lib.mkEnableOption "matrix";
|
||||
|
||||
domain = lib.mkOption { type = lib.types.string; };
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule { };
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
systemd.services.continuwuity.serviceConfig.Restart = lib.mkForce "always";
|
||||
services =
|
||||
let
|
||||
subdomain = "matrix.${config.quad.matrix.domain}";
|
||||
socket = "/var/run/continuwuity/continuwuity.sock";
|
||||
in
|
||||
{
|
||||
matrix-continuwuity = {
|
||||
enable = config.quad.matrix.enable;
|
||||
group = "caddy";
|
||||
settings.global = config.quad.matrix.settings // {
|
||||
server_name = config.quad.matrix.domain;
|
||||
unix_socket_path = socket;
|
||||
new_user_displayname_suffix = "";
|
||||
allow_public_room_directory_over_federation = true;
|
||||
trusted_servers = [
|
||||
"matrix.org"
|
||||
"tchncs.de"
|
||||
"maunium.net"
|
||||
];
|
||||
ignore_messages_from_server_names = [ ];
|
||||
url_preview_domain_explicit_allowlist = [ "*" ];
|
||||
|
||||
well_known = {
|
||||
client = "https://${subdomain}";
|
||||
server = "${subdomain}:443";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
caddy.virtualHosts."${subdomain}".extraConfig = "reverse_proxy unix/${socket}";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,16 +1,28 @@
|
|||
let
|
||||
port = 2222;
|
||||
in
|
||||
{
|
||||
networking.firewall.allowedTCPPorts = [ port ];
|
||||
users.users.quadradical.openssh.authorizedKeys.keys = import ../../secrets/keys.nix;
|
||||
services.openssh = {
|
||||
services = {
|
||||
openssh = {
|
||||
enable = true;
|
||||
ports = [ port ];
|
||||
openFirewall = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
AllowUsers = [ "quadradical" ];
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
|
||||
fail2ban = {
|
||||
enable = true;
|
||||
maxretry = 5;
|
||||
ignoreIP = [ "192.168.0.0/16" ];
|
||||
bantime = "6h";
|
||||
bantime-increment = {
|
||||
enable = true;
|
||||
formula = "ban.Time * math.exp(float(ban.Count+1)*banFactor)/math.exp(1*banFactor)";
|
||||
maxtime = "240h";
|
||||
overalljails = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
9
secrets/initialFloriPassword.age
Normal file
9
secrets/initialFloriPassword.age
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IFZLUVVkUSBPSXBv
|
||||
OWZxUnNMOWxHbDV0Z3h1N2JrbjBiOFh2b2YxZ2RWVlZHMUUzVEhNCjg2QysxRk1w
|
||||
cWZoREZvTTZITFkrRGt2a0xhZGhJSmFLS0tuNkdjSWhMeGcKLT4gKmxvIWstZ3Jl
|
||||
YXNlIGZ4cyBGIEFOVEwseXdhIFVNOWV3CktuM3lKZUM0ekdpalhWKzIzbE9DSnZi
|
||||
OHlWOEJOMG9KWjcrTXI4MllodytGazgzRVpoSQotLS0gODJmRHpLT3oxU1lSbUNQ
|
||||
WXhKem50VFJsUjVpbkFrVUdMZi9Yam5ta21hWQqYwhZCHkg5hjh4PboW8UCZOChC
|
||||
y+LqaQY4MhIXHWnMlVJYig==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
Loading…
Reference in a new issue