blob: cc7411f90fe7adfc9c6ad883e0f46c955aea3784 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
{ modulesPath, config, lib, pkgs, ... }: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/profiles/qemu-guest.nix")
./disk-config.nix
../serverModules/nginx.nix
];
sops = {
defaultSopsFile = ../../secrets/ltrr-tw/secrets.yaml;
defaultSopsFormat = "yaml";
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
};
boot.loader.grub = {
efiSupport = true;
efiInstallAsRemovable = true;
};
networking = {
interfaces.ens3 = {
ipv4.addresses = [{
address = "77.232.139.132";
prefixLength = 24;
}];
};
defaultGateway = {
address = "77.232.139.1";
interface = "ens3";
};
};
networking.nameservers = [ "8.8.8.8" "1.1.1.1" ];
networking.useDHCP = lib.mkDefault false;
networking.hostName = "ltrr-tw";
services.openssh = {
enable = true;
};
environment.systemPackages = map lib.lowPrio [
pkgs.curl
pkgs.gitMinimal
];
users.users = {
root = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDJ8UW1BXDGDmlaiARO3a9boTG8wknUyITMz0Z0OJpHx spleefer6@yandex.ru"
];
};
};
zramSwap = {
enable = true;
};
swapDevices = [{
device = "/var/lib/swapfile";
size = 2*1024;
}];
networking.nat = {
enable = true;
externalInterface = "ens3";
internalInterfaces = [ "wg0" ];
};
sops.secrets.wg_private_key = {};
networking.wg-quick = {
interfaces.wg0 = {
address = [ "10.1.1.1/32" ];
listenPort = 51820;
privateKeyFile = config.sops.secrets.wg_private_key.path;
preUp = "sysctl -w net.ipv4.ip_forward=1";
peers = [
{
allowedIPs = [ "10.1.1.2/32" ];
publicKey = "kzXzxJu1AdcRI5UwtGOrN6WuTZYqJo++PYRrXdOu/lY=";
persistentKeepalive = 25;
}
];
};
};
networking.firewall.allowedTCPPorts = [ 80 443 ];
networking.firewall.allowedUDPPorts = [ 51820 ];
security.acme = {
acceptTerms = true;
defaults.email = "notspl3g+acme@duck.com";
};
nginx = {
enable = true;
acme.enable = true;
domain = "kcu.su";
subdomains = {
"headscale" = {
proxyPass = "http://127.0.0.1:8768";
proxyWebsockets = true;
recommendedProxySettings = true;
};
};
extraVirtualHosts = {
"_" = {
locations."/" = {
return = 444;
};
};
};
home =
let
homeConfig = import ../server/configuration.nix { inherit modulesPath config lib pkgs; };
in {
subdomains = homeConfig.nginx.subdomains;
url = "http://10.1.1.2";
};
};
services.headscale = {
enable = true;
port = 8768;
settings = {
server_url = "https://headscale.kcu.su:443";
dns = {
base_domain = "tailnet.kcu.su";
nameservers.global = [ "8.8.8.8" ];
};
};
};
system.stateVersion = "24.05";
}
|