squid: add config validation (#376759)

This commit is contained in:
7c6f434c
2025-01-25 19:35:52 +00:00
committed by GitHub
+18 -1
View File
@@ -6,8 +6,19 @@ let
cfg = config.services.squid;
configWriter =
if cfg.validateConfig then
(
content:
pkgs.writers.makeScriptWriter {
check = "${cfg.package}/bin/squid -k parse -f";
interpreter = "${cfg.package}/bin/squid";
} "squid.conf" content
)
else
(content: pkgs.writeText "squid.conf" content);
squidConfig = pkgs.writeText "squid.conf"
squidConfig = configWriter
(if cfg.configText != null then cfg.configText else
''
#
@@ -111,6 +122,12 @@ in
description = "Whether to run squid web proxy.";
};
validateConfig = mkOption {
type = types.bool;
default = true;
description = "Validate config syntax.";
};
package = mkPackageOption pkgs "squid" { };
proxyAddress = mkOption {