nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, fetchFromGitHub, nixosTests, which
2, pcre2
3, withPython3 ? true, python3, ncurses
4, withPHP81 ? true, php81
5, withPHP82 ? false, php82
6, withPerl534 ? false, perl534
7, withPerl536 ? true, perl536
8, withPerldevel ? false, perldevel
9, withRuby_3_0 ? false, ruby_3_0
10, withRuby_3_1 ? true, ruby_3_1
11, withRuby_3_2 ? false, ruby_3_2
12, withSSL ? true, openssl ? null
13, withIPv6 ? true
14, withDebug ? false
15}:
16
17with lib;
18
19let
20 phpConfig = {
21 embedSupport = true;
22 apxs2Support = false;
23 systemdSupport = false;
24 phpdbgSupport = false;
25 cgiSupport = false;
26 fpmSupport = false;
27 };
28
29 php81-unit = php81.override phpConfig;
30 php82-unit = php82.override phpConfig;
31
32in stdenv.mkDerivation rec {
33 version = "1.30.0";
34 pname = "unit";
35
36 src = fetchFromGitHub {
37 owner = "nginx";
38 repo = pname;
39 rev = version;
40 sha256 = "sha256-QLTzlW1OsU+gwaPKozLcBKfuTXbYg1ONqTVZpGX6mrQ=";
41 };
42
43 nativeBuildInputs = [ which ];
44
45 buildInputs = [ pcre2.dev ]
46 ++ optionals withPython3 [ python3 ncurses ]
47 ++ optional withPHP81 php81-unit
48 ++ optional withPHP82 php82-unit
49 ++ optional withPerl534 perl534
50 ++ optional withPerl536 perl536
51 ++ optional withPerldevel perldevel
52 ++ optional withRuby_3_0 ruby_3_0
53 ++ optional withRuby_3_1 ruby_3_1
54 ++ optional withRuby_3_2 ruby_3_2
55 ++ optional withSSL openssl;
56
57 configureFlags = [
58 "--control=unix:/run/unit/control.unit.sock"
59 "--pid=/run/unit/unit.pid"
60 "--user=unit"
61 "--group=unit"
62 ] ++ optional withSSL "--openssl"
63 ++ optional (!withIPv6) "--no-ipv6"
64 ++ optional withDebug "--debug";
65
66 # Optionally add the PHP derivations used so they can be addressed in the configs
67 usedPhp81 = optionals withPHP81 php81-unit;
68
69 postConfigure = ''
70 ${optionalString withPython3 "./configure python --module=python3 --config=python3-config --lib-path=${python3}/lib"}
71 ${optionalString withPHP81 "./configure php --module=php81 --config=${php81-unit.unwrapped.dev}/bin/php-config --lib-path=${php81-unit}/lib"}
72 ${optionalString withPHP82 "./configure php --module=php81 --config=${php82-unit.unwrapped.dev}/bin/php-config --lib-path=${php82-unit}/lib"}
73 ${optionalString withPerl534 "./configure perl --module=perl534 --perl=${perl534}/bin/perl"}
74 ${optionalString withPerl536 "./configure perl --module=perl536 --perl=${perl536}/bin/perl"}
75 ${optionalString withPerldevel "./configure perl --module=perldev --perl=${perldevel}/bin/perl"}
76 ${optionalString withRuby_3_0 "./configure ruby --module=ruby30 --ruby=${ruby_3_0}/bin/ruby"}
77 ${optionalString withRuby_3_1 "./configure ruby --module=ruby31 --ruby=${ruby_3_1}/bin/ruby"}
78 ${optionalString withRuby_3_2 "./configure ruby --module=ruby32 --ruby=${ruby_3_2}/bin/ruby"}
79 '';
80
81 passthru.tests.unit-php = nixosTests.unit-php;
82
83 meta = {
84 description = "Dynamic web and application server, designed to run applications in multiple languages";
85 homepage = "https://unit.nginx.org/";
86 license = licenses.asl20;
87 platforms = platforms.linux;
88 maintainers = with maintainers; [ izorkin ];
89 };
90}