wa2k.com/nixos/default.nix

50 lines
1.1 KiB
Nix
Raw Normal View History

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