mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
feat(exports): nginx
This commit is contained in:
parent
743593452d
commit
e72478968c
5 changed files with 52 additions and 0 deletions
34
modules/system/exports/nginx.nix
Normal file
34
modules/system/exports/nginx.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{lib, gensokyo-zone, ...}: let
|
||||
inherit (gensokyo-zone.lib) mapAlmostOptionDefaults mkAlmostOptionDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
in {
|
||||
config.exports.services.nginx = { config, ... }: let
|
||||
mkAssertion = f: nixosConfig: let
|
||||
cfg = nixosConfig.services.nginx;
|
||||
in f nixosConfig cfg;
|
||||
assertPorts = nixosConfig: cfg: {
|
||||
assertion = config.ports.http.port == cfg.defaultHTTPListenPort && config.ports.https.port == cfg.defaultSSLListenPort;
|
||||
message = "ports mismatch";
|
||||
};
|
||||
in {
|
||||
nixos = {
|
||||
serviceAttr = "nginx";
|
||||
assertions = mkIf config.enable [
|
||||
(mkAssertion assertPorts)
|
||||
];
|
||||
};
|
||||
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||
ports = mapAttrs (_: mapAlmostOptionDefaults) {
|
||||
http = {
|
||||
port = 80;
|
||||
protocol = "http";
|
||||
};
|
||||
https = {
|
||||
enable = false;
|
||||
port = 443;
|
||||
protocol = "https";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -24,6 +24,21 @@ _: {
|
|||
enable = true;
|
||||
id = "login.local";
|
||||
};
|
||||
nginx = {
|
||||
enable = true;
|
||||
ports = {
|
||||
https_global = {
|
||||
port = 443;
|
||||
protocol = "https";
|
||||
listen = "wan";
|
||||
};
|
||||
https = {
|
||||
enable = true;
|
||||
port = 444;
|
||||
};
|
||||
http.listen = "wan";
|
||||
};
|
||||
};
|
||||
sshd = {
|
||||
enable = true;
|
||||
ports.global = {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ _: {
|
|||
exports = {
|
||||
services = {
|
||||
sshd.enable = true;
|
||||
nginx.enable = true;
|
||||
plex.enable = true;
|
||||
invidious.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ _: {
|
|||
exports = {
|
||||
services = {
|
||||
sshd.enable = true;
|
||||
nginx.enable = true;
|
||||
tailscale.enable = true;
|
||||
home-assistant.enable = true;
|
||||
zigbee2mqtt.enable = true;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ _: {
|
|||
exports = {
|
||||
services = {
|
||||
sshd.enable = true;
|
||||
nginx.enable = true;
|
||||
unifi.enable = true;
|
||||
mosquitto.enable = true;
|
||||
dnsmasq.enable = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue