###########################################################################
#
#       BOF - Begin of File
#
###########################################################################

###########################################################################
#
#       Liste aller am  ursprünglichen Dokument beteiligter Autorinnen
#       List of 
#       @author admin@ --> Abgesprochene zusammenfuehrung von Kommentaren
#       @author resi@
#       @author mlp@
#       @author vat@
#       @author offbyone@
#
###########################################################################
#       Autor der  überarbeiteten  Version
#       @author johann@
###########################################################################
#
#       Liste verwendeter Abkuerzungen im Dokument
#       
#       PVE             - Proxmox Virtual Enviroment - 
#       Link: https://en.wikipedia.org/wiki/Proxmox_Virtual_Environment
#
#       LXC             - Linux Container
#       Link: https://en.wikipedia.org/wiki/LXC | https://linuxcontainers.org/lxc/
#
#       CT              - Container
#       ID              - Identity Document
#
#       DHCP            - Dynamic Host Configuration Protocol
#       Link: https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
#       
#       TCP & UDP       - Transmission Control Protocol & User Datagram Protocol
#       Link: https://en.wikipedia.org/wiki/Transmission_Control_Protocol & https://en.wikipedia.org/wiki/User_Datagram_Protocol
#       
#       HTW     - Hochschule fuer Technik und Wirtschaft Dresden
#       Link: https://www.htw-dresden.de/       
#
#       NGINX           - "engine X" Webserver 
#       Link: https://en.wikipedia.org/wiki/Nginx | https://nginx.org/
#       
#
###########################################################################

{ config, pkgs, ... }:

{

  imports = [ 


    <nixpkgs/nixos/modules/virtualisation/proxmox-lxc.nix>
  ];
  
  
###############################
###     NixOS
##############################

system.stateVersion = "24.05";
system.autoUpgrade.enable = true;
system.autoUpgrade.allowReboot = true;
nix.settings.auto-optimise-store = true;
nix.optimise.automatic = true;
nix.gc.automatic = true;
nix.gc.options = "--delete-older-than 5d";


############################
####    System
############################

  proxmoxLXC.manageHostName = true;
  
  networking.hostName = "www";
  networking.domain = "chat.stura.htw-dresden.de";

  time.timeZone = "Europe/Berlin";
  
  # NGINX Webserver
  services.nginx.enable = true;
  
  services.nginx.virtualHosts."${config.networking.fqdn}" = {
    forceSSL = true;
    enableACME = true;
    root = "/var/www/";
  };
  
  
  services.nginx.logError = ''/var/log/nginx/error.log debug''; 
 
  security.acme.defaults.email = "cert@stura.htw-dresden.de";
  security.acme.acceptTerms = true;


###############################################################
#
#       SSH Verbindungen zu  diesem Container sollen prinzipiell nicht moeglich sein. 
#       NixOS Container = Server        -       SSH Verbindung = Client
#       
#       Allgemein soll das Anmelden auf einen NixOS Container ueber "pct  enter <ct_id>" erfolgen.
#       Es ist demnach nicht notwendig SSH als Server fuer den Nixcontainer zu aktivieren.
#       services.openssh.enable = false; 
#       Grund: Wird von Proxmoy auf true gesetzt.

###############################################################
       
       services.openssh.enable = false;

############################
####    Netzwerk
############################

###############################################################
#
#       Network Cofigruation - nur IPv4 
#       Zur nicht dynamischen Bereitstellung eignet sich DHCP nicht wirklich
# 
###############################################################

  networking.useDHCP = false;
  networking.enableIPv6 = false;

############################################################### 
#
#       Firewall Configuration
#       Standardmaessig ist die Firewall bei NixOS an. Wir spezifizieren erlaubte TCP Ports.
#       
##############################################################

  networking.firewall.allowedTCPPorts = [ 80 443 ];

}
##################################################################
#
#       EOF - End of File
#
##################################################################
