Merge pull request #272542 from Sohalt/caddy-config-file

nixos/caddy: use caddyfile adapter by default with explicit configFile
This commit is contained in:
Florian Klink
2023-12-07 09:07:35 +02:00
committed by GitHub
2 changed files with 18 additions and 3 deletions
@@ -147,7 +147,7 @@ in
default = configFile;
defaultText = "A Caddyfile automatically generated by values from services.caddy.*";
example = literalExpression ''
pkgs.writeTextDir "Caddyfile" '''
pkgs.writeText "Caddyfile" '''
example.com
root * /var/www/wordpress
@@ -164,9 +164,9 @@ in
};
adapter = mkOption {
default = if (builtins.baseNameOf cfg.configFile) == "Caddyfile" then "caddyfile" else null;
default = if ((cfg.configFile != configFile) || (builtins.baseNameOf cfg.configFile) == "Caddyfile") then "caddyfile" else null;
defaultText = literalExpression ''
if (builtins.baseNameOf cfg.configFile) == "Caddyfile" then "caddyfile" else null
if ((cfg.configFile != configFile) || (builtins.baseNameOf cfg.configFile) == "Caddyfile") then "caddyfile" else null
'';
example = literalExpression "nginx";
type = with types; nullOr str;
+15
View File
@@ -48,11 +48,19 @@ import ./make-test-python.nix ({ pkgs, ... }: {
};
};
};
specialisation.explicit-config-file.configuration = {
services.caddy.configFile = pkgs.writeText "Caddyfile" ''
localhost:80
respond "hello world"
'';
};
};
};
testScript = { nodes, ... }:
let
explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file";
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload";
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42";
@@ -84,5 +92,12 @@ import ./make-test-python.nix ({ pkgs, ... }: {
)
webserver.wait_for_open_port(80)
webserver.succeed("curl http://localhost | grep hello")
with subtest("explicit configFile"):
webserver.succeed(
"${explicitConfigFile}/bin/switch-to-configuration test >&2"
)
webserver.wait_for_open_port(80)
webserver.succeed("curl http://localhost | grep hello")
'';
})