cleaned up duplicated code

This commit is contained in:
Danilo Reyes 2025-10-12 20:03:24 -06:00
parent e393a4481b
commit 30cff89a50
2 changed files with 1 additions and 74 deletions

View File

@ -53,59 +53,8 @@ let
default = null; default = null;
}; };
}; };
proxy = locations: {
inherit locations;
forceSSL = true;
enableACME = true;
http2 = true;
};
proxyReverse =
cfg:
proxy {
"/" = {
proxyPass = "http://${cfg.ip}:${toString cfg.port}/";
proxyWebsockets = cfg.enableSocket;
};
};
proxyReverseFix =
cfg:
let
useLocalhost = cfg.hostName == config.networking.hostName;
localHeaders = ''
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
'';
in
proxyReverse cfg
// {
extraConfig = ''
${if useLocalhost then localHeaders else ""}
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_redirect off;
proxy_http_version 1.1;
'';
};
proxyReversePrivate =
cfg:
proxyReverse cfg
// {
extraConfig = ''
ssl_verify_client on;
ssl_client_certificate ${cfg.certPath};
error_page 403 /403.html;
'';
};
in in
{ {
inherit inherit mkOptions;
mkOptions
proxy
proxyReverse
proxyReverseFix
proxyReversePrivate
;
mkServerOptions = mkOptions; mkServerOptions = mkOptions;
} }

View File

@ -148,28 +148,6 @@ in
if shellType == "bash" then { initExtra = bashContent; } else { initContent = zshContent; }; if shellType == "bash" then { initExtra = bashContent; } else { initContent = zshContent; };
mergeAliases = baseAliases: extraAliases: baseAliases // extraAliases; mergeAliases = baseAliases: extraAliases: baseAliases // extraAliases;
importDotfile = path: import path; importDotfile = path: import path;
mkScriptOptions = lib: {
enable = lib.mkEnableOption "Whether to enable this script";
install = lib.mkEnableOption "Whether to install the script package";
service = lib.mkEnableOption "Whether to enable the script service";
name = lib.mkOption {
type = lib.types.str;
description = "Name of the script.";
};
timer = lib.mkOption {
type = lib.types.str;
default = "*:0";
description = "Systemd timer schedule.";
};
description = lib.mkOption {
type = lib.types.str;
description = "Description of the service.";
};
package = lib.mkOption {
type = lib.types.package;
description = "Package containing the executable script.";
};
};
getServicesWithNativeFirewall = getServicesWithNativeFirewall =
config: blacklist: config: blacklist:
config.my.servers config.my.servers