forked from fossar/nix-phps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checks.nix
160 lines (144 loc) · 3.76 KB
/
checks.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{
system,
packages,
pkgs,
}:
let
phpPackages = builtins.filter (name: builtins.match "php[0-9]+" name != null) (builtins.attrNames packages);
checks = {
php = {
description = "Build PHP";
drv = { php, ... }: php;
};
imagick = {
description = "Build Imagick extension";
drv = { php, ... }: php.extensions.imagick;
};
redis = {
description = "Build Redis extension";
drv = { php, ... }: php.extensions.redis;
};
redis3 = {
description = "Build Redis 3 extension";
enabled = { php, lib, ... }: lib.versionOlder php.version "8";
drv = { php, ... }: php.extensions.redis3;
};
mysql = {
description = "Build MySQL extension";
enabled = { php, lib, ... }: lib.versionOlder php.version "7";
drv = { php, ... }: php.extensions.mysql;
};
xdebug = {
description = "Build Xdebug extension";
drv = { php, ... }: php.extensions.xdebug;
};
tidy = {
description = "Build Tidy extension";
drv = { php, ... }: php.extensions.tidy;
};
composer-phar = {
description = "Check that composer PHAR works";
drv =
{ pkgs, php, ... }:
pkgs.runCommand
"composer-phar-check"
{
buildInputs = [
php.packages.composer
];
}
''
composer --version
touch "$out"
'';
};
mysqli-socket-path = {
description = "Validate php.extensions.mysqli default unix socket path";
drv =
{ pkgs, php, ... }:
pkgs.runCommand
"mysqli-socket-path-check"
{
buildInputs = [
(php.withExtensions ({ all, ... }: [
all.mysqli
]))
];
}
''
php -r "echo ini_get('mysqli.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock
touch "$out"
'';
};
pdo_mysql-socket-path = {
description = "Validate php.extensions.pdo_mysql default unix socket path";
drv =
{ pkgs, php, ... }:
pkgs.runCommand
"pdo_mysql-socket-path-check"
{
buildInputs = [
(php.withExtensions ({ all, ... }: [
all.pdo_mysql
]))
];
}
''
php -r "echo ini_get('pdo_mysql.default_socket') . PHP_EOL;" | grep /run/mysqld/mysqld.sock
touch "$out"
'';
};
};
inherit (pkgs) lib;
/* AttrSet<phpName, AttrSet<checkName, checkDrv>> */
checksPerVersion =
lib.listToAttrs (
builtins.map
(phpName:
let
php = packages.${phpName};
phpVersion = lib.versions.majorMinor php.version;
args = { inherit lib php pkgs system; };
supportedChecks = lib.filterAttrs (_name: { enabled ? lib.const true, ... }: enabled args) checks;
in
{
name = phpName;
value =
lib.mapAttrs
(
_name:
{
description,
drv,
...
}:
let
check = drv args;
in
check // {
passthru = check.passthru or { } // {
description = "PHP ${phpVersion} – ${description}";
};
}
)
supportedChecks;
}
)
phpPackages
);
in
lib.foldAttrs
lib.mergeAttrs
{}
(
lib.mapAttrsToList
(
phpName:
lib.mapAttrs'
(
name:
lib.nameValuePair "${phpName}-${name}"
)
)
checksPerVersion
)