From a7f07853eed48be5d49875627291d24320925955 Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Sun, 14 Jan 2024 13:02:24 +0100 Subject: [PATCH] vm: Provide a simple web server within a VM --- module.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/module.nix b/module.nix index 5ec0ece..a3942e4 100644 --- a/module.nix +++ b/module.nix @@ -1,2 +1,29 @@ -{ services.getty.autologinUser = "root"; +{ pkgs, ... }: { + services = { + getty.autologinUser = "root"; + nginx = { + enable = true; + virtualHosts.localhost.locations."/" = { + index = "index.html"; + + root = pkgs.writeTextDir "index.html" '' + + + Hello World! + + + ''; + }; + }; + }; + + networking.firewall.allowedTCPPorts = [ 80 ]; + + virtualisation.forwardPorts = [{ + from = "host"; + guest.port = 80; + host.port = 8080; + }]; + + system.stateVersion = "23.11"; }