1import ./make-test-python.nix ({ pkgs, lib, ... }: {
2 name = "mod_perl";
3
4 meta = with pkgs.lib.maintainers; {
5 maintainers = [ sgo ];
6 };
7
8 nodes.machine = { config, lib, pkgs, ... }: {
9 services.httpd = {
10 enable = true;
11 adminAddr = "admin@localhost";
12 virtualHosts."modperl" =
13 let
14 inc = pkgs.writeTextDir "ModPerlTest.pm" ''
15 package ModPerlTest;
16 use strict;
17 use Apache2::RequestRec ();
18 use Apache2::RequestIO ();
19 use Apache2::Const -compile => qw(OK);
20 sub handler {
21 my $r = shift;
22 $r->content_type('text/plain');
23 print "Hello mod_perl!\n";
24 return Apache2::Const::OK;
25 }
26 1;
27 '';
28 startup = pkgs.writeScript "startup.pl" ''
29 use lib "${inc}",
30 split ":","${with pkgs.perl.pkgs; makeFullPerlPath ([ mod_perl2 ])}";
31 1;
32 '';
33 in
34 {
35 extraConfig = ''
36 PerlRequire ${startup}
37 '';
38 locations."/modperl" = {
39 extraConfig = ''
40 SetHandler perl-script
41 PerlResponseHandler ModPerlTest
42 '';
43 };
44 };
45 enablePerl = true;
46 };
47 };
48 testScript = { ... }: ''
49 machine.wait_for_unit("httpd.service")
50 response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/modperl")
51 assert "Hello mod_perl!" in response, "/modperl handler did not respond"
52 '';
53})