2022-05-06 17:41:05 +02:00
|
|
|
|
# Edit this configuration file to define what should be installed on
|
|
|
|
|
# your system. Help is available in the configuration.nix(5) man page
|
|
|
|
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
|
|
|
|
|
|
|
|
|
{ lib, config, pkgs, inputs, ... }:
|
2022-12-08 21:17:05 +01:00
|
|
|
|
let vs = config.vault-secrets.secrets;
|
|
|
|
|
in {
|
2022-05-06 17:41:05 +02:00
|
|
|
|
imports = [ ];
|
|
|
|
|
|
|
|
|
|
# This value determines the NixOS release from which the default
|
|
|
|
|
# settings for stateful data, like file locations and database versions
|
|
|
|
|
# on your system were taken. It‘s perfectly fine and recommended to leave
|
|
|
|
|
# this value at the release version of the first install of this system.
|
|
|
|
|
# Before changing this value read the documentation for this option
|
|
|
|
|
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
|
|
|
|
|
system.stateVersion = "21.11"; # Did you read the comment?
|
|
|
|
|
|
|
|
|
|
# Additional packages
|
|
|
|
|
environment.systemPackages = with pkgs; [ wireguard-tools ];
|
|
|
|
|
|
|
|
|
|
environment.noXlibs = lib.mkForce false;
|
|
|
|
|
|
2022-12-08 21:17:05 +01:00
|
|
|
|
networking.firewall.allowedUDPPorts =
|
|
|
|
|
[ config.networking.wireguard.interfaces.wg0.listenPort ];
|
2022-09-25 12:44:52 +02:00
|
|
|
|
networking.firewall.checkReversePath = false;
|
2022-05-06 17:41:05 +02:00
|
|
|
|
|
2022-12-08 21:17:05 +01:00
|
|
|
|
vault-secrets.secrets.wireguard = { services = [ "wireguard-wg0" ]; };
|
2022-05-06 17:41:05 +02:00
|
|
|
|
|
|
|
|
|
networking.nat = {
|
|
|
|
|
enable = true;
|
2022-09-25 12:44:52 +02:00
|
|
|
|
internalInterfaces = [ "wg0" "eth0" ];
|
2022-05-06 17:41:05 +02:00
|
|
|
|
externalInterface = "eth0";
|
|
|
|
|
};
|
|
|
|
|
|
2022-09-25 12:44:52 +02:00
|
|
|
|
boot.kernel.sysctl = {
|
|
|
|
|
"net.ipv4.ip_forward" = 1;
|
|
|
|
|
"net.ipv6.conf.all.forwarding" = 1;
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-30 12:22:19 +02:00
|
|
|
|
services.prometheus.exporters.wireguard = {
|
|
|
|
|
enable = true;
|
|
|
|
|
openFirewall = true;
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-06 17:41:05 +02:00
|
|
|
|
networking.wireguard.interfaces.wg0 = {
|
|
|
|
|
ips = [ "10.100.0.1/24" ];
|
|
|
|
|
listenPort = 51820;
|
|
|
|
|
privateKeyFile = "${vs.wireguard}/privateKey";
|
|
|
|
|
|
|
|
|
|
peers = [
|
|
|
|
|
{
|
|
|
|
|
# Phone
|
|
|
|
|
publicKey = "K+99mvSYs4urcclreQDLA1pekD4xtu/mpS2uVWw8Bws=";
|
|
|
|
|
allowedIPs = [ "10.100.0.2/32" ];
|
|
|
|
|
}
|
2022-07-29 21:43:49 +02:00
|
|
|
|
{
|
|
|
|
|
# Laura's laptop
|
|
|
|
|
publicKey = "ZWIaDGrASlTkEK75j10VeGCvrIGfpk4GPobmqcYX2D0=";
|
|
|
|
|
allowedIPs = [ "10.100.0.3/32" ];
|
|
|
|
|
}
|
2022-08-20 15:49:40 +02:00
|
|
|
|
{
|
2022-12-07 17:06:38 +01:00
|
|
|
|
# Old Laptop
|
2022-08-20 15:49:40 +02:00
|
|
|
|
publicKey = "L8myt2bcdja7M+i+9eatdQRW8relPUoZZ9lEKSLe+m8=";
|
|
|
|
|
allowedIPs = [ "10.100.0.4/32" ];
|
|
|
|
|
}
|
2022-12-07 17:06:38 +01:00
|
|
|
|
{
|
|
|
|
|
# New Laptop
|
|
|
|
|
publicKey = "+Ms3xV6LxNZWTQk11zoz+AUIV2uds6A64Wz15JlR/Ak=";
|
2022-12-19 09:36:53 +01:00
|
|
|
|
allowedIPs = [ "10.100.0.6/32" ];
|
2022-12-07 17:06:38 +01:00
|
|
|
|
}
|
2022-09-10 10:27:48 +02:00
|
|
|
|
{
|
|
|
|
|
# Aerdenhout
|
|
|
|
|
# Useful setup video for opnsense: https://www.youtube.com/watch?v=RoXHe5dqCM0
|
|
|
|
|
# https://docs.opnsense.org/manual/how-tos/wireguard-s2s.html
|
|
|
|
|
publicKey = "KgqLhmUMX6kyTjRoa/GOCrZOvXNE5HWYuOr/T3v8/VI=";
|
2022-09-25 12:44:52 +02:00
|
|
|
|
allowedIPs = [ "10.100.0.5/32" "192.168.0.0/23" "10.10.10.0/24" ];
|
2022-09-10 10:27:48 +02:00
|
|
|
|
endpoint = "80.60.83.220:51820";
|
2022-09-27 14:05:24 +02:00
|
|
|
|
persistentKeepalive = 25;
|
2022-09-10 10:27:48 +02:00
|
|
|
|
}
|
2022-05-06 17:41:05 +02:00
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
}
|