ingress/configuration.nix

97 lines
2.3 KiB
Nix
Raw Normal View History

{
inputs,
lib,
config,
pkgs,
...
2024-08-22 18:48:15 +00:00
}:
let
2024-08-23 20:03:47 +00:00
ngx_http_geoip2_module = pkgs.stdenv.mkDerivation {
2024-08-22 18:48:15 +00:00
name = "ngx_http_geoip2_module-a28ceff";
src = pkgs.fetchgit {
url = "https://github.com/leev/ngx_http_geoip2_module";
rev = "445df24ef3781e488cee3dfe8a1e111997fc1dfe";
sha256 = "1h2xkxpb2nk4r3pkbzgas5rbl95i59jpa59rh94x2hyzxmzrzvv8";
};
installPhase = ''
mkdir $out
cp *.c config $out/
'';
fixupPhase = "";
};
in
{
system.stateVersion = "23.11";
2024-08-21 21:00:23 +00:00
#boot.loader.systemd-boot.enable = true;
#boot.loader.efi.canTouchEfiVariables = true;
# PROXMOX
services.qemuGuest.enable = true;
2024-08-23 20:03:47 +00:00
services.cloud-init = {
enable = true;
};
2024-08-21 21:00:23 +00:00
# USER MANAGEMENT
2024-08-23 20:03:47 +00:00
# TODO: Should this be in cloud-init?
2024-08-21 21:00:23 +00:00
nix.settings.trusted-users = [ "nixos" ];
2024-08-22 18:48:15 +00:00
users.users.nixos = {
isNormalUser = true;
2024-08-23 20:03:47 +00:00
password = "nixos";
2024-08-22 18:48:15 +00:00
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICXAlzwziqfUUb2qmFwNF/nrBYc5MNT1MMOx81ohBmB+ tine@little.sys.tjo.space"
];
};
2024-08-23 20:03:47 +00:00
security.sudo.wheelNeedsPassword = false;
# SSH
2024-08-21 21:00:23 +00:00
services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
settings.KbdInteractiveAuthentication = false;
settings.PermitRootLogin = "no";
};
2024-08-23 20:03:47 +00:00
# TAILSCALE
services.tailscale = {
enable = true;
};
# FIREWALL
networking.firewall = {
enable = true;
trustedInterfaces = [ "tailscale0" ];
allowedUDPPorts = [ config.services.tailscale.port ];
allowedTCPPorts = [ 22 ];
};
2024-08-21 21:00:23 +00:00
# NGINX
2024-08-22 18:48:15 +00:00
services.nginx = {
enable = true;
package = pkgs.nginx.overrideAttrs (oldAttrs: {
configureFlags = oldAttrs.configureFlags ++ [ "--add-module=${ngx_http_geoip2_module}" ];
buildInputs = oldAttrs.buildInputs ++ [ pkgs.libmaxminddb ];
});
};
# WEBHOOK
# TODO: we will have multiple instances of these,
# should they somehow broadcast changes to eachother?
# Should this be a GO service instead? With some raft mechanism?
# At that point, we could also switch from nginx to envoy or something...
services.webhook = {
enable = true;
port = 9000;
hooks = {
test = {
execute-command = "echo 'test'";
};
};
};
2024-08-21 21:00:23 +00:00
2024-08-22 18:48:15 +00:00
environment.systemPackages = [ pkgs.nginx ];
}