-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
105 lines (97 loc) · 2.89 KB
/
flake.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
{
description = "A Nix-flake-based Rust development environment";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = {
self,
flake-utils,
nixpkgs,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [
(import rust-overlay)
(self: super: {
rustToolchain = let
rust = super.rust-bin;
in
if builtins.pathExists ./rust-toolchain.toml
then rust.fromRustupToolchainFile ./rust-toolchain.toml
else if builtins.pathExists ./rust-toolchain
then rust.fromRustupToolchainFile ./rust-toolchain
else rust.stable.latest.default;
})
];
pkgs = import nixpkgs {inherit system overlays;};
phpunwrapped = pkgs.php81.unwrapped.dev.overrideAttrs (attrs: {
configureFlags = attrs.configureFlags ++ ["--enable-zts"];
preConfigure =
''
for i in main/build-defs.h.in scripts/php-config.in; do
substituteInPlace $i \
--replace '@CONFIGURE_COMMAND@' '(omitted)' \
--replace '@PHP_LDFLAGS@' ""
done
export EXTENSION_DIR=$out/lib/php/extensions
for i in $(find . -type f -name "*.m4"); do
substituteInPlace $i \
--replace 'test -x "$PKG_CONFIG"' 'type -P "$PKG_CONFIG" >/dev/null'
done
./buildconf --copy --force
if test -f $src/genfiles; then
./genfiles
fi
''
+ pkgs.lib.optionalString (system == flake-utils.lib.system.aarch64-darwin) ''
substituteInPlace configure --replace "-lstdc++" "-lc++"
'';
});
php = phpunwrapped.buildEnv {
extensions = {
enabled,
all,
}:
enabled
++ (with all; [
redis
pcov
dom
mbstring
tokenizer
xmlwriter
xmlreader
]);
extraConfig = "memory_limit = -1";
};
in {
devShells.default = pkgs.mkShell {
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
nativeBuildInputs = with pkgs; [
php
php81Packages.composer
phpunwrapped
stdenv.cc.libc
clang
rustToolchain
openssl
pkg-config
cargo-deny
cargo-edit
cargo-watch
rust-analyzer
];
buildInputs = with pkgs; [
php
phpunwrapped
stdenv.cc.libc
clang
];
shellHook = ''
${pkgs.rustToolchain}/bin/cargo --version
'';
};
});
}