3
0
Fork 0
forked from mirrors/nixpkgs

nixos/caddy: Use caddyfile adapter by default when explicitly specifying configFile

This commit is contained in:
sohalt 2023-12-06 21:34:38 +01:00
parent ea5566eb3b
commit 3c6b3d71fa
2 changed files with 18 additions and 3 deletions

View file

@ -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;

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")
'';
})