Repository navigation
Expand file tree
/
Copy pathshell.nix
More file actions
210 lines (194 loc) · 8.95 KB
/
Copy pathshell.nix
File metadata and controls
210 lines (194 loc) · 8.95 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
{
php-version ? 8.5,
with-blackfire ? false,
with-xdebug ? false,
with-turbocov ? !with-blackfire && !with-php-benchmark && !with-xdebug,
with-php-benchmark ? false,
with-duckdb ? false,
with-polars ? false,
with-spark ? false,
with-pg-query-ext ? !with-c,
with-arrow-ext ? !with-rust,
with-flow-php-ext ? !with-rust,
with-c ? false,
with-rust ? false,
with-terraform ? false,
with-wasm ? false,
with-grpc ? false,
with-protobuf ? php-version != 8.6,
with-protoc ? false
}:
assert (!(with-rust && with-arrow-ext)) || builtins.throw "Cannot use --arg with-rust true and --arg with-arrow-ext true together. Use: --arg with-arrow-ext false --arg with-rust true";
assert (!(with-rust && with-flow-php-ext)) || builtins.throw "Cannot use --arg with-rust true and --arg with-flow-php-ext true together. Use: --arg with-flow-php-ext false --arg with-rust true";
assert (!(with-c && with-pg-query-ext)) || builtins.throw "Cannot use --arg with-c true and --arg with-pg-query-ext true together. Use: --arg with-pg-query-ext false --arg with-c true";
assert (!(with-php-benchmark && with-turbocov)) || builtins.throw "Cannot use --arg with-php-benchmark true and --arg with-turbocov true together: Turbocov distorts timings.";
assert (!(with-turbocov && with-xdebug)) || builtins.throw "Turbocov cannot run together with Xdebug";
assert (!(with-php-benchmark && with-xdebug)) || builtins.throw "Cannot use --arg with-php-benchmark true and --arg with-xdebug true together: xdebug distorts timings.";
assert (!(with-php-benchmark && with-blackfire)) || builtins.throw "Cannot use --arg with-php-benchmark true and --arg with-blackfire true together: time without the probe, profile with --arg with-blackfire true alone.";
let
nixpkgs = fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/619c39f6eac5d1ed6b8f073a9414baf7034b2356.tar.gz";
sha256 = "1m4bsj927vplp8rd4fgb789cf897frgvcnp8q8w51bsycvjqzbd1";
};
pkgs = import nixpkgs {
config = {
allowUnfree = true;
};
overlays = [
(final: prev:
if prev.stdenv.hostPlatform.system == "aarch64-darwin" then {
blackfire = prev.blackfire.overrideAttrs (old: {
version = "2026.10.2";
src = prev.fetchurl {
url = "https://packages.blackfire.io/blackfire/2026.10.2/blackfire-darwin_arm64.pkg.tar.gz";
sha256 = "sha256-8XYmYKnE5AFf9l698kSEDhYTfFGyRoXVoaFBRl9BFgk=";
};
});
} else {}
)
];
};
base-php = if php-version == 8.5 then
pkgs.php85
else if php-version == 8.6 then
pkgs.php86
else
throw "Unsupported php version, Flow supports 8.5 and 8.6";
php-brotli = pkgs.callPackage ./.nix/pkgs/php-brotli/package.nix { php = base-php; };
php-turbocov = pkgs.callPackage ./.nix/pkgs/php-turbocov/package.nix { php = base-php; };
php-snappy = pkgs.callPackage ./.nix/pkgs/php-snappy/package.nix { php = base-php; };
php-lz4 = pkgs.callPackage ./.nix/pkgs/php-lz4/package.nix { php = base-php; };
php-zstd = pkgs.callPackage ./.nix/pkgs/php-zstd/package.nix { php = base-php; };
php-pg-query-ext = pkgs.callPackage ./.nix/pkgs/php-pg-query-ext/package.nix { php = base-php; };
extension-version = let
lib = pkgs.lib;
resolve = base: path: if lib.hasPrefix "/" path then /. + path else base + "/${path}";
firstLine = file: builtins.head (lib.splitString "\n" (builtins.readFile file));
dotGit = ./. + "/.git";
gitDir =
if !(builtins.pathExists dotGit) then
throw "cannot determine the extension version: ${toString ./.} is not a git checkout"
else if lib.pathIsDirectory dotGit then
dotGit
else
resolve ./. (lib.removePrefix "gitdir: " (firstLine dotGit));
commonDir =
if builtins.pathExists (gitDir + "/commondir") then resolve gitDir (firstLine (gitDir + "/commondir")) else gitDir;
looseTags =
lib.optionals (lib.pathIsDirectory (commonDir + "/refs/tags"))
(builtins.attrNames (builtins.readDir (commonDir + "/refs/tags")));
packedTags =
lib.optionals (builtins.pathExists (commonDir + "/packed-refs"))
(map builtins.head (lib.filter (match: match != null)
(map (builtins.match "[0-9a-f]+ refs/tags/(.+)") (lib.splitString "\n" (builtins.readFile (commonDir + "/packed-refs"))))));
tags = lib.filter (tag: builtins.match "[0-9]+\\.[0-9]+\\.[0-9]+" tag != null) (looseTags ++ packedTags);
latest = lib.splitString "." (lib.foldl' (a: b: if builtins.compareVersions a b >= 0 then a else b) (builtins.head tags) tags);
in
if builtins.pathExists (commonDir + "/reftable") then
throw "cannot determine the extension version: reftable ref storage is not supported, run `git refs migrate --ref-format=files`"
else if tags == [ ] then
throw "cannot determine the extension version: no X.Y.Z tags in ${toString commonDir}, run `git fetch --tags`"
else
"${builtins.elemAt latest 0}.${toString (lib.toInt (builtins.elemAt latest 1) + 1)}.0-dev";
php-arrow-ext = pkgs.callPackage ./.nix/pkgs/php-arrow-ext/package.nix { php = base-php; arrow-ext-version = extension-version; };
php-flow-php-ext = pkgs.callPackage ./.nix/pkgs/php-flow-php-ext/package.nix { php = base-php; flow-php-ext-version = extension-version; };
php = pkgs.callPackage ./.nix/pkgs/flow-php/package.nix {
php = base-php;
inherit php-snappy php-lz4 php-brotli php-zstd php-turbocov php-pg-query-ext php-arrow-ext php-flow-php-ext
with-turbocov with-xdebug with-blackfire with-php-benchmark with-pg-query-ext with-arrow-ext with-flow-php-ext with-grpc with-protobuf;
};
polars-python = pkgs.python3.withPackages (ps: [ ps.polars ps.pyarrow ]);
spark = pkgs.spark.override { RSupport = false; };
fnox = pkgs.callPackage ./.nix/pkgs/fnox/package.nix { };
fnox-wrappers = pkgs.callPackage ./.nix/fnox/wrappers.nix { inherit fnox; composer = php.packages.composer; };
in
pkgs.mkShell {
buildInputs = [
php
fnox-wrappers.composer
pkgs.starship
pkgs.figlet
pkgs.symfony-cli
pkgs.act
fnox
fnox-wrappers.gh
pkgs.hyperfine
pkgs.actionlint
pkgs.zizmor
pkgs.just
pkgs.oxipng
pkgs.jpegoptim
pkgs.thrift
pkgs.nodejs_24
]
++ pkgs.lib.optional with-blackfire fnox-wrappers.blackfire
++ pkgs.lib.optionals with-wasm [
# WASM build tools
pkgs.emscripten
pkgs.autoconf
pkgs.cmake
pkgs.wget
pkgs.gnutar
pkgs.xz
pkgs.libxml2
pkgs.pkg-config
]
++ pkgs.lib.optional with-terraform fnox-wrappers.terraform
++ pkgs.lib.optionals with-c [
# C development tools for pg-query-ext extension development
pkgs.gcc
pkgs.gnumake
pkgs.autoconf
pkgs.automake
pkgs.libtool
pkgs.protobuf
pkgs.protobufc
pkgs.git
php.unwrapped.dev
]
++ pkgs.lib.optionals with-rust [
# Rust development tools for arrow-ext extension development
pkgs.rustc
pkgs.cargo
pkgs.rustfmt
pkgs.clippy
pkgs.clang
pkgs.llvmPackages.libclang
pkgs.pkg-config
php.unwrapped.dev
]
++ pkgs.lib.optionals with-protoc [
# protoc + grpc_php_plugin for regenerating protobuf/gRPC PHP classes
pkgs.protobuf
pkgs.grpc
pkgs.git
]
++ pkgs.lib.optional with-duckdb pkgs.duckdb
++ pkgs.lib.optional with-polars polars-python
++ pkgs.lib.optional with-spark spark
;
shellHook = ''
if [ -f "$PWD/.nix/shell/starship.toml" ]; then
export STARSHIP_CONFIG="$PWD/.nix/shell/starship.toml"
else
export STARSHIP_CONFIG="$PWD/.nix/shell/starship.toml.dist"
fi
${pkgs.lib.optionalString with-c ''
# Setup for pg-query-ext C extension development
export PHP_CONFIG="${php.unwrapped.dev}/bin/php-config"
export PHPIZE="${php.unwrapped.dev}/bin/phpize"
''}
${pkgs.lib.optionalString with-rust ''
# Setup for arrow-ext Rust extension development
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"
export PHP_CONFIG="${php.unwrapped.dev}/bin/php-config"
export PHPIZE="${php.unwrapped.dev}/bin/phpize"
''}
if [ -f "$PWD/.nix/blackfire/blackfire.env" ]; then
set -a; . "$PWD/.nix/blackfire/blackfire.env"; set +a
fi
eval "$(${pkgs.starship}/bin/starship init bash)"
clear
figlet "Flow PHP"
'';
}