mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
chore: nf-fmt-nix
This commit is contained in:
parent
7486517713
commit
9903866044
160 changed files with 4570 additions and 3019 deletions
|
|
@ -1,5 +1,12 @@
|
|||
let
|
||||
serverModule = {config, nixosConfig, name, gensokyo-zone, lib, ...}: let
|
||||
serverModule = {
|
||||
config,
|
||||
nixosConfig,
|
||||
name,
|
||||
gensokyo-zone,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.modules) mkIf mkBefore mkOptionDefault;
|
||||
|
|
@ -13,7 +20,7 @@ let
|
|||
enable = mkEnableOption "ngx_stream_ssl_preread_module";
|
||||
upstream = mkOption {
|
||||
type = str;
|
||||
default = "$preread_" + replaceStrings [ "'" ] [ "_" ] name;
|
||||
default = "$preread_" + replaceStrings ["'"] ["_"] name;
|
||||
};
|
||||
upstreams = mkOption {
|
||||
type = nullOr (attrsOf str);
|
||||
|
|
@ -25,9 +32,10 @@ let
|
|||
config = let
|
||||
inherit (nginx.stream) upstreams;
|
||||
mkUpstream = host: upstream: "${host} ${upstreams.${upstream}.name};";
|
||||
upstreams' = removeAttrs cfg.upstreams [ "default" ];
|
||||
upstreamLines = mapAttrsToList mkUpstream upstreams'
|
||||
++ optional (cfg.upstreams ? default) (mkUpstream "default" cfg.upstreams.default);
|
||||
upstreams' = removeAttrs cfg.upstreams ["default"];
|
||||
upstreamLines =
|
||||
mapAttrsToList mkUpstream upstreams'
|
||||
++ optional (cfg.upstreams ? default) (mkUpstream "default" cfg.upstreams.default);
|
||||
in {
|
||||
ssl.preread = {
|
||||
streamConfig = mkIf (cfg.upstreams != null) ''
|
||||
|
|
@ -46,59 +54,65 @@ let
|
|||
serverBlock = mkIf cfg.enable (mkOptionDefault (mkBefore cfg.streamConfig));
|
||||
};
|
||||
};
|
||||
in {config, gensokyo-zone, lib, ...}: let
|
||||
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.modules) mkIf mkDefault mkOptionDefault;
|
||||
cfg = config.services.nginx.ssl.preread;
|
||||
in {
|
||||
options.services.nginx = with lib.types; {
|
||||
ssl.preread = {
|
||||
enable = mkEnableOption "ssl preread";
|
||||
listenPort = mkOption {
|
||||
type = port;
|
||||
default = 444;
|
||||
};
|
||||
serverPort = mkOption {
|
||||
type = port;
|
||||
default = 443;
|
||||
};
|
||||
serverName = mkOption {
|
||||
type = str;
|
||||
default = "preread'https";
|
||||
};
|
||||
upstreamName = mkOption {
|
||||
type = str;
|
||||
default = "preread'nginx";
|
||||
};
|
||||
};
|
||||
stream.servers = mkOption {
|
||||
type = attrsOf (submoduleWith {
|
||||
modules = [serverModule];
|
||||
shorthandOnlyDefinesConfig = false;
|
||||
});
|
||||
};
|
||||
};
|
||||
config = {
|
||||
services.nginx = {
|
||||
defaultSSLListenPort = mkIf cfg.enable cfg.listenPort;
|
||||
stream = {
|
||||
upstreams.${cfg.upstreamName} = mkIf cfg.enable {
|
||||
ssl.enable = true;
|
||||
servers.access = {
|
||||
addr = mkDefault "localhost";
|
||||
port = mkOptionDefault cfg.listenPort;
|
||||
};
|
||||
in
|
||||
{
|
||||
config,
|
||||
gensokyo-zone,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.modules) mkIf mkDefault mkOptionDefault;
|
||||
cfg = config.services.nginx.ssl.preread;
|
||||
in {
|
||||
options.services.nginx = with lib.types; {
|
||||
ssl.preread = {
|
||||
enable = mkEnableOption "ssl preread";
|
||||
listenPort = mkOption {
|
||||
type = port;
|
||||
default = 444;
|
||||
};
|
||||
servers.${cfg.serverName} = {
|
||||
enable = mkIf (!cfg.enable) (mkAlmostOptionDefault false);
|
||||
listen.https.port = cfg.serverPort;
|
||||
ssl.preread = {
|
||||
enable = true;
|
||||
upstreams.default = mkOptionDefault cfg.upstreamName;
|
||||
serverPort = mkOption {
|
||||
type = port;
|
||||
default = 443;
|
||||
};
|
||||
serverName = mkOption {
|
||||
type = str;
|
||||
default = "preread'https";
|
||||
};
|
||||
upstreamName = mkOption {
|
||||
type = str;
|
||||
default = "preread'nginx";
|
||||
};
|
||||
};
|
||||
stream.servers = mkOption {
|
||||
type = attrsOf (submoduleWith {
|
||||
modules = [serverModule];
|
||||
shorthandOnlyDefinesConfig = false;
|
||||
});
|
||||
};
|
||||
};
|
||||
config = {
|
||||
services.nginx = {
|
||||
defaultSSLListenPort = mkIf cfg.enable cfg.listenPort;
|
||||
stream = {
|
||||
upstreams.${cfg.upstreamName} = mkIf cfg.enable {
|
||||
ssl.enable = true;
|
||||
servers.access = {
|
||||
addr = mkDefault "localhost";
|
||||
port = mkOptionDefault cfg.listenPort;
|
||||
};
|
||||
};
|
||||
servers.${cfg.serverName} = {
|
||||
enable = mkIf (!cfg.enable) (mkAlmostOptionDefault false);
|
||||
listen.https.port = cfg.serverPort;
|
||||
ssl.preread = {
|
||||
enable = true;
|
||||
upstreams.default = mkOptionDefault cfg.upstreamName;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue