diff options
-rw-r--r-- | hosts/ahmed/configuration.nix | 47 | ||||
-rw-r--r-- | hosts/ahmed/dyndns/default.nix | 20 | ||||
-rw-r--r-- | hosts/ahmed/minecraft/default.nix | 27 | ||||
-rw-r--r-- | hosts/ahmed/nginx/default.nix | 18 |
4 files changed, 68 insertions, 44 deletions
diff --git a/hosts/ahmed/configuration.nix b/hosts/ahmed/configuration.nix index 25be8d0..25eb336 100644 --- a/hosts/ahmed/configuration.nix +++ b/hosts/ahmed/configuration.nix @@ -20,6 +20,9 @@ ./ssh ./torrenting ./remote-builder + ./dyndns + ./minecraft + ./nginx ]; # Create the main user. @@ -56,50 +59,6 @@ keyMap = "dk"; # This host has a Danish keyboard layout. }; - # Set up Minecraft server. - services.on-demand-minecraft = { - enable = true; - eula = true; - package = pkgs.unstable.papermc; - openFirewall = true; - # Try shutting down every 10 minutes. - frequency-check-players = "*-*-* *:00/10:00"; - - # Seed requested by Tobias. - server-properties."level-seed" = "1727502807"; - - # I changed the default location after creating the world. - data-dir = "/srv/minecrafter/papermc-1.21.4-15"; - }; - services.cloudflare-dyndns.domains = ["minecraft.linus.onl"]; - - # Virtual hosts. - # Each module for a HTTP service will register a virtual host. - services.nginx.enable = true; - - # Configure ACME. This is used by various HTTP services through the NGINX virtual hosts. - security.acme = { - acceptTerms = true; - defaults.email = "linusvejlo+${config.networking.hostName}[email protected]"; - }; - - # Configure DDNS. The website for each module is responsible for extending - # `services.cloudflare-dyndns.domains` with its domain. - age.secrets.cloudflare-dyndns-api-token.file = ../../secrets/cloudflare-ddns-token.env.age; - services.cloudflare-dyndns = { - enable = true; - apiTokenFile = config.age.secrets.cloudflare-dyndns-api-token.path; - proxied = true; - }; - # We also have to overwrite the dependencies of the DYNDNS client service to - # make sure we are *actually* online. - # - # See: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget - systemd.services.cloudflare-dyndns.after = ["network-online.target"]; - - # Listen for HTTP connections. - networking.firewall.allowedTCPPorts = [80 443]; - # Automatic upgrades system.autoUpgrade = { enable = true; diff --git a/hosts/ahmed/dyndns/default.nix b/hosts/ahmed/dyndns/default.nix new file mode 100644 index 0000000..62c2cca --- /dev/null +++ b/hosts/ahmed/dyndns/default.nix @@ -0,0 +1,20 @@ +# This module sets up dynamic DNS (DDNS). +# +# Other services will register the domains to be updated via +# `services.cloudflare-dyndns.domains`. +{config, ...}: { + services.cloudflare-dyndns = { + enable = true; + apiTokenFile = config.age.secrets.cloudflare-dyndns-api-token.path; + proxied = true; + }; + + # We have to authenticate the Cloudflare's DDNS service with an API key. + age.secrets.cloudflare-dyndns-api-token.file = ../../../secrets/cloudflare-ddns-token.env.age; + + # We also have to overwrite the dependencies of the DYNDNS client service to + # make sure we are *actually* online. + # + # See: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget + systemd.services.cloudflare-dyndns.after = ["network-online.target"]; +} diff --git a/hosts/ahmed/minecraft/default.nix b/hosts/ahmed/minecraft/default.nix new file mode 100644 index 0000000..112ef8f --- /dev/null +++ b/hosts/ahmed/minecraft/default.nix @@ -0,0 +1,27 @@ +# This module configures a Minecraft server. +# +# Most of the heavy lifting is done in the reusable module `modules/nixos/on-demand-minecraft/`. +{pkgs, ...}: { + # Set up Minecraft server. + services.on-demand-minecraft = { + enable = true; + eula = true; + + package = pkgs.unstable.papermc; + + openFirewall = true; + + # Try shutting down every 10 minutes. + frequency-check-players = "*-*-* *:00/10:00"; + + # Seed requested by Tobias. + server-properties."level-seed" = "1727502807"; + + # I changed the default location after creating the world. + data-dir = "/srv/minecrafter/papermc-1.21.4-15"; + }; + + # Update the DDNS. + # This would be the "IP" we give to folks. + services.cloudflare-dyndns.domains = ["minecraft.linus.onl"]; +} diff --git a/hosts/ahmed/nginx/default.nix b/hosts/ahmed/nginx/default.nix new file mode 100644 index 0000000..24dde85 --- /dev/null +++ b/hosts/ahmed/nginx/default.nix @@ -0,0 +1,18 @@ +# This module sets up an NGINX on this host. +# +# Different services' will register themselves with NGINX via +# `services.nginx.virtualHosts`. They may also want to order themselves before +# NGINX `systemd.services.*.{before,wantedBy}`. +{config, ...}: { + # Virtual hosts. + services.nginx.enable = true; + + # Configure ACME. This is used by various HTTP services through the NGINX virtual hosts. + security.acme = { + acceptTerms = true; + defaults.email = "linusvejlo+${config.networking.hostName}[email protected]"; + }; + + # Allow HTTP connections. + networking.firewall.allowedTCPPorts = [80 443]; +} |