2023-07-09 01:37:11 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
|
|
|
imports =
|
2023-07-09 15:14:43 +02:00
|
|
|
[
|
2023-07-09 15:02:41 +02:00
|
|
|
/etc/nixos/hardware-configuration.nix
|
2023-07-09 01:37:11 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
# Use the GRUB 2 boot loader.
|
|
|
|
boot.loader.grub.enable = true;
|
|
|
|
# boot.loader.grub.efiSupport = true;
|
|
|
|
# boot.loader.grub.efiInstallAsRemovable = true;
|
|
|
|
# boot.loader.efi.efiSysMountPoint = "/boot/efi";
|
|
|
|
# Define on which hard drive you want to install Grub.
|
|
|
|
boot.loader.grub.device = "/dev/vda"; # or "nodev" for efi only
|
|
|
|
|
2023-07-09 15:14:43 +02:00
|
|
|
networking = {
|
|
|
|
hostName = "kamoshi";
|
2023-07-11 18:49:32 +02:00
|
|
|
nat = {
|
|
|
|
enable = true;
|
|
|
|
externalInterface = "eth0";
|
|
|
|
internalInterfaces = [ "wg0" ];
|
|
|
|
};
|
2023-07-09 15:14:43 +02:00
|
|
|
firewall = {
|
|
|
|
enable = true;
|
2023-07-11 18:49:32 +02:00
|
|
|
allowedTCPPorts = [
|
|
|
|
22 # endlessh
|
|
|
|
80 # nginx
|
|
|
|
443 # nginx TLS
|
|
|
|
2222 # ssh
|
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
2023-07-11 19:29:29 +02:00
|
|
|
42069 # wireguard
|
2023-07-11 18:49:32 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
wireguard.interfaces = {
|
|
|
|
wg0 = {
|
|
|
|
ips = [ "10.100.0.1/24" ];
|
2023-07-11 19:29:29 +02:00
|
|
|
listenPort = 42069;
|
2023-07-11 18:49:32 +02:00
|
|
|
postSetup = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
|
|
|
|
'';
|
|
|
|
postShutdown = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
|
|
|
|
'';
|
2023-07-11 19:29:29 +02:00
|
|
|
privateKeyFile = "/root/secrets/wireguard/kamoshi";
|
2023-07-11 18:49:32 +02:00
|
|
|
|
|
|
|
peers = [
|
|
|
|
{
|
2023-07-11 19:29:29 +02:00
|
|
|
publicKey = "26lQ3qCZrZ3hAqLIDfQNrmFQSQv983TeyXpJUY59QkI=";
|
2023-07-11 18:49:32 +02:00
|
|
|
allowedIPs = [ "10.100.0.2/32" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2023-07-09 15:14:43 +02:00
|
|
|
};
|
|
|
|
};
|
2023-07-09 01:37:11 +02:00
|
|
|
|
|
|
|
time.timeZone = "Europe/Warsaw";
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
|
|
|
|
users.users.kamov = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "wheel" ];
|
2023-07-09 22:27:33 +02:00
|
|
|
openssh.authorizedKeys.keyFiles = [ /root/secrets/ssh/kamov.pub ];
|
2023-07-09 01:37:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
2023-07-09 15:08:36 +02:00
|
|
|
git
|
2023-07-09 01:37:11 +02:00
|
|
|
vim
|
|
|
|
wget
|
|
|
|
neovim
|
|
|
|
neofetch
|
|
|
|
nushell
|
2023-07-11 18:49:32 +02:00
|
|
|
wireguard-tools
|
2023-07-09 01:37:11 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
services = {
|
|
|
|
endlessh = {
|
|
|
|
enable = true;
|
|
|
|
port = 22;
|
|
|
|
};
|
|
|
|
openssh = {
|
|
|
|
enable = true;
|
|
|
|
ports = [ 2222 ];
|
|
|
|
settings = {
|
|
|
|
PasswordAuthentication = false;
|
|
|
|
KbdInteractiveAuthentication = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
nginx = {
|
|
|
|
enable = true;
|
2023-07-09 15:18:58 +02:00
|
|
|
recommendedTlsSettings = true;
|
2023-07-09 01:37:11 +02:00
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
virtualHosts = {
|
|
|
|
"kamoshi.org" = {
|
|
|
|
default = true;
|
|
|
|
root = "/var/www/kamoshi.org";
|
|
|
|
addSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security.acme = {
|
|
|
|
acceptTerms = true;
|
|
|
|
defaults.email = "maciej@kamoshi.org";
|
|
|
|
};
|
|
|
|
|
2023-07-09 17:08:31 +02:00
|
|
|
virtualisation = {
|
|
|
|
podman = {
|
|
|
|
enable = true;
|
|
|
|
dockerCompat = true;
|
|
|
|
};
|
|
|
|
oci-containers = {
|
|
|
|
backend = "podman";
|
|
|
|
containers = {
|
|
|
|
kotori = {
|
|
|
|
image = "kamov/kotori";
|
2023-07-09 22:27:33 +02:00
|
|
|
environmentFiles = [ /root/secrets/kotori.env ];
|
2023-07-09 17:08:31 +02:00
|
|
|
autoStart = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-07-09 01:37:11 +02:00
|
|
|
# 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 = "23.05"; # Did you read the comment?
|
|
|
|
|
|
|
|
}
|