nginxModules.njs: init at 0.7.8

Changed files
+51 -1
nixos
pkgs
servers
http
nginx
+1
nixos/tests/all-tests.nix
···
nginx-etag = handleTest ./nginx-etag.nix {};
nginx-http3 = handleTest ./nginx-http3.nix {};
nginx-modsecurity = handleTest ./nginx-modsecurity.nix {};
+
nginx-njs = handleTest ./nginx-njs.nix {};
nginx-pubhtml = handleTest ./nginx-pubhtml.nix {};
nginx-sandbox = handleTestOn ["x86_64-linux"] ./nginx-sandbox.nix {};
nginx-sso = handleTest ./nginx-sso.nix {};
+27
nixos/tests/nginx-njs.nix
···
+
import ./make-test-python.nix ({ pkgs, lib, ... }: {
+
name = "nginx-njs";
+
+
nodes.machine = { config, lib, pkgs, ... }: {
+
services.nginx = {
+
enable = true;
+
additionalModules = [ pkgs.nginxModules.njs ];
+
commonHttpConfig = ''
+
js_import http from ${builtins.toFile "http.js" ''
+
function hello(r) {
+
r.return(200, "Hello world!");
+
}
+
export default {hello};
+
''};
+
'';
+
virtualHosts."localhost".locations."/".extraConfig = ''
+
js_content http.hello;
+
'';
+
};
+
};
+
testScript = ''
+
machine.wait_for_unit("nginx")
+
+
response = machine.wait_until_succeeds("curl -fvvv -s http://127.0.0.1/")
+
assert "Hello world!" == response, f"Expected 'Hello world!', got '{response}'"
+
'';
+
})
+23 -1
pkgs/servers/http/nginx/modules.nix
···
-
{ fetchFromGitHub, fetchFromGitLab, lib, pkgs }:
+
{ fetchFromGitHub, fetchFromGitLab, fetchhg, lib, pkgs }:
let
···
rev = "95ac520eed2ea04098a76305fd0ad7e9158840b7";
sha256 = "0b5pnqkgg18kbw5rf2ifiq7lsx5rqmpqsql6hx5ycxjzxj6acfb3";
} + "/naxsi_src";
+
};
+
+
njs = rec {
+
src = fetchhg {
+
url = "https://hg.nginx.org/njs";
+
rev = "0.7.8";
+
sha256 = "sha256-jsR8EOeW8tAo2utKznuUaCG4hK0oU0ZJSnnGmI5HUDk=";
+
name = "nginx-njs";
+
};
+
+
# njs module sources have to be writable during nginx build, so we copy them
+
# to a temporary directory and change the module path in the configureFlags
+
preConfigure = ''
+
NJS_SOURCE_DIR=$(readlink -m "$TMPDIR/${src}")
+
mkdir -p "$(dirname "$NJS_SOURCE_DIR")"
+
cp --recursive "${src}" "$NJS_SOURCE_DIR"
+
chmod -R u+rwX,go+rX "$NJS_SOURCE_DIR"
+
export configureFlags="''${configureFlags/"${src}"/"$NJS_SOURCE_DIR/nginx"}"
+
unset NJS_SOURCE_DIR
+
'';
+
+
inputs = [ pkgs.which ];
};
opentracing = {