mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
nixos/caddy: Use caddyfile adapter by default when explicitly specifying configFile
This commit is contained in:
parent
ea5566eb3b
commit
3c6b3d71fa
2 changed files with 18 additions and 3 deletions
|
@ -147,7 +147,7 @@ in
|
||||||
default = configFile;
|
default = configFile;
|
||||||
defaultText = "A Caddyfile automatically generated by values from services.caddy.*";
|
defaultText = "A Caddyfile automatically generated by values from services.caddy.*";
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
pkgs.writeTextDir "Caddyfile" '''
|
pkgs.writeText "Caddyfile" '''
|
||||||
example.com
|
example.com
|
||||||
|
|
||||||
root * /var/www/wordpress
|
root * /var/www/wordpress
|
||||||
|
@ -164,9 +164,9 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
adapter = mkOption {
|
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 ''
|
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";
|
example = literalExpression "nginx";
|
||||||
type = with types; nullOr str;
|
type = with types; nullOr str;
|
||||||
|
|
|
@ -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, ... }:
|
testScript = { nodes, ... }:
|
||||||
let
|
let
|
||||||
|
explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file";
|
||||||
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload";
|
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload";
|
||||||
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
|
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
|
||||||
rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42";
|
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.wait_for_open_port(80)
|
||||||
webserver.succeed("curl http://localhost | grep hello")
|
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")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue