nixos/tests/caddy: drop withPlugins test path (#524860)

This commit is contained in:
Gaétan Lepage
2026-07-09 09:40:25 +00:00
committed by GitHub
3 changed files with 67 additions and 52 deletions
+6 -32
View File
@@ -1,11 +1,11 @@
{ pkgs, ... }:
{ lib, ... }:
{
name = "caddy";
meta = with pkgs.lib.maintainers; {
maintainers = [
stepbrobd
];
};
meta.maintainers = with lib.maintainers; [
stepbrobd
];
nodes = {
webserver =
@@ -69,24 +69,6 @@
respond "hello world"
'';
};
specialisation.with-plugins.configuration = {
services.caddy = {
package = pkgs.caddy.withPlugins {
plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20250618171559-80962887e4c6" ];
hash = "sha256-0N/bQAM5yT6g9UAteWsfxofGcelmU/NDTroS2oL43Gs=";
};
configFile = pkgs.writeText "Caddyfile" ''
{
order replace after encode
}
localhost:80 {
respond "hello world"
replace world caddy
}
'';
};
};
};
};
@@ -98,7 +80,6 @@
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
multipleHostnames = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-hostnames";
rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42";
withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins";
in
''
url = "http://localhost/example.html"
@@ -141,12 +122,5 @@
)
webserver.wait_for_open_port(80)
webserver.succeed("curl http://localhost | grep hello")
with subtest("plugins are correctled installed and configurable"):
webserver.succeed(
"${withPluginsConfig}/bin/switch-to-configuration test >&2"
)
webserver.wait_for_open_port(80)
webserver.succeed("curl http://localhost | grep caddy")
'';
}
+25 -20
View File
@@ -3,6 +3,7 @@
buildGoModule,
callPackage,
fetchFromGitHub,
testers,
nixosTests,
caddy,
installShellFiles,
@@ -10,23 +11,18 @@
writableTmpDirAsHomeHook,
versionCheckHook,
}:
let
version = "2.11.4";
dist = fetchFromGitHub {
owner = "caddyserver";
repo = "dist";
tag = "v${version}";
hash = "sha256-oRQfQH1GKjAjVMj+dZo1f1+HOaOdJIyEfod0iGLYcc8=";
};
in
buildGoModule (finalAttrs: {
pname = "caddy";
inherit version;
version = "2.11.4";
__structuredAttrs = true;
src = fetchFromGitHub {
owner = "caddyserver";
repo = "caddy";
tag = "v${finalAttrs.version}";
# remember to update hashes for `dist` and `plugins` test!
hash = "sha256-wzk8KRZfDCbbjRlBwkoKAoMjOhV4xF3yuXUueqtl1xM=";
};
@@ -52,7 +48,7 @@ buildGoModule (finalAttrs: {
__darwinAllowLocalNetworking = true;
postInstall = ''
install -Dm644 ${dist}/init/caddy.service ${dist}/init/caddy-api.service -t $out/lib/systemd/system
install -Dm644 ${finalAttrs.passthru.dist}/init/caddy.service ${finalAttrs.passthru.dist}/init/caddy-api.service -t $out/lib/systemd/system
substituteInPlace $out/lib/systemd/system/caddy.service \
--replace-fail "/usr/bin/caddy" "$out/bin/caddy"
@@ -72,20 +68,29 @@ buildGoModule (finalAttrs: {
--zsh <($out/bin/caddy completion zsh)
'';
passthru = {
tests = {
inherit (nixosTests) caddy;
acme-integration = nixosTests.acme.caddy;
};
withPlugins = callPackage ./plugins.nix { inherit caddy; };
};
doInstallCheck = true;
nativeInstallCheckInputs = [
writableTmpDirAsHomeHook
versionCheckHook
];
versionCheckKeepEnvironment = [ "HOME" ];
doInstallCheck = true;
passthru = {
withPlugins = callPackage ./plugins.nix { inherit caddy; };
dist = fetchFromGitHub {
owner = "caddyserver";
repo = "dist";
tag = "v${finalAttrs.version}";
hash = "sha256-oRQfQH1GKjAjVMj+dZo1f1+HOaOdJIyEfod0iGLYcc8=";
};
tests = {
inherit (nixosTests) caddy;
plugins = testers.runNixOSTest ./plugins.test.nix;
acme-integration = nixosTests.acme.caddy;
};
};
meta = {
homepage = "https://caddyserver.com";
+36
View File
@@ -0,0 +1,36 @@
{ lib, ... }:
{
name = "caddy-plugins";
meta.maintainers = with lib.maintainers; [
stepbrobd
];
nodes.machine =
{ pkgs, ... }:
{
services.caddy = {
enable = true;
package = pkgs.caddy.withPlugins {
plugins = [ "github.com/caddyserver/replace-response@v0.0.0-20250618171559-80962887e4c6" ];
hash = "sha256-oj0IpspxslpNZbJFsexh0W2Sja19XRUsbShoCuY6qkQ=";
};
globalConfig = ''
order replace after encode
'';
virtualHosts."localhost:80".extraConfig = ''
respond "hello world"
replace world nixos
'';
};
};
testScript = ''
machine.wait_for_unit("caddy")
machine.wait_for_open_port(80)
machine.succeed("curl http://localhost | grep nixos")
'';
}