Helper scripts and templates for Nix development shells.
Copy flake.example.nix to your project as flake.nix and run nix develop.
Manages PHP-FPM lifecycle in development shells with automatic socket configuration.
php-fpm/start-php-fpm.sh- Starts PHP-FPMphp-fpm/stop-php-fpm.sh- Stops PHP-FPM and cleans upphp-fpm/add-php-fpm-handler-to-htaccess.sh- Configures Apache .htaccessphp-fpm/remove-php-fpm-handler-from-htaccess.sh- Removes .htaccess configuration
Required:
PROJECT_HTACCESS_PATH- Path to .htaccess (only if using htaccess scripts)
Optional (auto-detected with sensible defaults):
PHP_FPM_BIN- Path to php-fpm binary (defaults tophp-fpmin PATH)PHP_FPM_POOL_NAME- Pool name (defaults to current directory name)PHP_FPM_RUNTIME_DIR- Runtime directory (defaults to$XDG_RUNTIME_DIR/<pool-name>on Linux,$TMPDIR/<pool-name>on macOS, or/tmp/<pool-name>as fallback)PHP_FPM_SOCKET_PATH- Socket path (defaults to$PHP_FPM_RUNTIME_DIR/php-fpm.sock)
- Auto-detection: Sensible defaults for pool name, runtime directory, and socket path
- Mailpit integration: Automatically configures
sendmail_pathif mailpit is available in PATH - Per-directory configuration: Supports
.user.inifiles for overriding PHP settings per project (instant updates in dev mode) - Cross-platform: Uses
$XDG_RUNTIME_DIRon Linux,$TMPDIRon macOS, with/tmpfallback - Graceful cleanup: Kills orphaned processes and removes runtime directories on exit
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-devshell-helpers = {
url = "github:timohubois/nix-devshell-helpers";
flake = false;
};
};
outputs = { nixpkgs, nix-devshell-helpers, ... }: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.${system}.default = pkgs.mkShell {
packages = [ pkgs.php83 ];
shellHook = ''
# PHP-FPM (explicitly set PHP version, recommended for reproducibility)
export PHP_FPM_BIN="${pkgs.php83}/bin/php-fpm"
source ${nix-devshell-helpers}/php-fpm/start-php-fpm.sh
cleanup() {
source ${nix-devshell-helpers}/php-fpm/stop-php-fpm.sh
}
trap cleanup EXIT
'';
};
};
}