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