2024-04-11 23:19:41 +02:00
|
|
|
acme-certs: final: prev:
|
|
|
|
let
|
|
|
|
lib = final.lib;
|
|
|
|
crt = "${final.path}/nixos/tests/common/acme/server/acme.test.cert.pem";
|
|
|
|
key = "${final.path}/nixos/tests/common/acme/server/acme.test.key.pem";
|
|
|
|
in {
|
2024-04-11 21:20:25 +02:00
|
|
|
writers = prev.writers // {
|
|
|
|
writeNginxConfig = name: text: final.runCommandLocal name {
|
|
|
|
nginxConfig = prev.writers.writeNginxConfig name text;
|
2024-04-11 23:19:41 +02:00
|
|
|
nativeBuildInputs = [ final.bubblewrap ];
|
2024-04-11 21:20:25 +02:00
|
|
|
} ''
|
|
|
|
ln -s "$nginxConfig" "$out"
|
2024-04-11 23:19:41 +02:00
|
|
|
set +o pipefail
|
|
|
|
bwrap \
|
|
|
|
--ro-bind "${crt}" "/etc/certs/nginx.crt" \
|
|
|
|
--ro-bind "${key}" "/etc/certs/nginx.key" \
|
|
|
|
--ro-bind "/nix" "/nix" \
|
|
|
|
--ro-bind "/etc/hosts" "/etc/hosts" \
|
|
|
|
--dir "/run/nginx" \
|
|
|
|
--dir "/tmp" \
|
|
|
|
--dir "/var/log/nginx" \
|
|
|
|
${lib.concatMapStrings (name: "--ro-bind \"${crt}\" \"/var/lib/acme/${name}/fullchain.pem\" \\") acme-certs}
|
|
|
|
${lib.concatMapStrings (name: "--ro-bind \"${key}\" \"/var/lib/acme/${name}/key.pem\" \\") acme-certs}
|
|
|
|
${lib.concatMapStrings (name: "--ro-bind \"${crt}\" \"/var/lib/acme/${name}/chain.pem\" \\") acme-certs}
|
2024-04-12 00:41:57 +02:00
|
|
|
${lib.getExe' final.nginx "nginx"} -t -c "$out" |& grep "syntax is ok"
|
2024-04-11 21:20:25 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|