forked from timohubois/nix-devshell-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.example.nix
More file actions
53 lines (44 loc) · 1.4 KB
/
flake.example.nix
File metadata and controls
53 lines (44 loc) · 1.4 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
{
description = "Development environment with PHP (FPM and CLI) and Node";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-devshell-helpers = {
url = "github:bleech/nix-devshell-helpers";
flake = false;
};
};
outputs = { nixpkgs, nix-devshell-helpers, ... }: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
php = pkgs.php83.buildEnv {
extensions = { enabled, all }: enabled ++ (with all; [
imagick
xdebug
]);
};
nodejs = pkgs.nodejs_22;
in {
devShells.${system}.default = pkgs.mkShell {
packages = [
php
nodejs
];
shellHook = ''
# PHP-FPM (explicitly set PHP version, recommended for reproducibility)
export PHP_FPM_BIN="${php}/bin/php-fpm"
source ${nix-devshell-helpers}/php-fpm/start-php-fpm.sh
# Apache/.htaccess configuration (optional)
export PROJECT_HTACCESS_PATH="$PWD/static/.htaccess"
source ${nix-devshell-helpers}/php-fpm/add-php-fpm-handler-to-htaccess.sh
echo "PHP: $(php --version | head -1)"
echo "Node: $(node --version)"
# Cleanup on exit
cleanup() {
source ${nix-devshell-helpers}/php-fpm/stop-php-fpm.sh
source ${nix-devshell-helpers}/php-fpm/remove-php-fpm-handler-from-htaccess.sh
}
trap cleanup EXIT
'';
};
};
}