Unverified Commit 0cc3d43a authored by Naïm Favier's avatar Naïm Favier Committed by GitHub
Browse files

Merge pull request #191796 from hmenke/njs

nginxModules.njs: init at 0.7.8
parents 26d71e93 9ab02e1e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -429,6 +429,7 @@ in {
  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 −0
Original line number Diff line number Diff line
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
Original line number Diff line number Diff line
{ fetchFromGitHub, fetchFromGitLab, lib, pkgs }:
{ fetchFromGitHub, fetchFromGitLab, fetchhg, lib, pkgs }:

let

@@ -290,6 +290,28 @@ in
      } + "/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 = {
    src =
      let src' = fetchFromGitHub {