wa2k.com/nixos/default.nix
2026-03-14 16:25:55 +10:00

49 lines
1 KiB
Nix

{
config,
pkgs,
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types;
cfg = config.services.wa2k;
in {
options.services.wa2k = {
enable = mkEnableOption "webserver for wa2k.com";
port = mkOption {
types = types.port;
default = 80;
example = 8080;
description = ''
The listening port on localhost to bind the wa2k.com server to.
'';
};
openFirewall = mkOption {
types = types.bool;
default = false;
example = true;
description = ''
Whether the wa2k listening port should be automatically opened in the system's firewall.
'';
};
};
config = lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts = lib.optional cfg.openFirewall [cfg.port];
# REF: https://nixos.wiki/wiki/Static_Web_Server
services.static-web-server = {
enable = true;
listen = "[::]:${cfg.port}";
root = "${pkgs.wa2k-website}/www";
configuration = {
general = {
directory-listing = false;
};
};
};
};
}