Created
January 16, 2026 21:34
-
-
Save andreswebs/c19c48a6f854ef55385d75b7e303d7a6 to your computer and use it in GitHub Desktop.
Nix Flake for a PHP 5.6 environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| description = "PHP 5.6 environment"; | |
| inputs = { | |
| nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | |
| utils.url = "github:numtide/flake-utils"; | |
| phps = { | |
| url = "github:loophp/nix-shell"; | |
| inputs.nixpkgs.follows = "nixpkgs"; | |
| }; | |
| }; | |
| outputs = { self, nixpkgs, utils, phps, ... }: | |
| utils.lib.eachDefaultSystem (system: | |
| let | |
| pkgs = import nixpkgs { | |
| inherit system; | |
| config = { | |
| allowUnfree = true; | |
| permittedInsecurePackages = [ | |
| "openssl-1.1.1w" | |
| ]; | |
| }; | |
| overlays = [ | |
| phps.overlays.default | |
| ]; | |
| }; | |
| # See: github:NixOS/nixpkgs/pkgs/top-level/php-packages.nix | |
| php56WithExtensions = pkgs.php56.withExtensions ({ all, ... }: | |
| with all; [ | |
| bcmath | |
| bz2 | |
| curl | |
| dom | |
| fileinfo | |
| filter | |
| gd | |
| iconv | |
| imap | |
| json | |
| mcrypt | |
| mysqlnd | |
| openssl | |
| pcntl | |
| posix | |
| readline | |
| redis | |
| simplexml | |
| sockets | |
| tokenizer | |
| zip | |
| zlib | |
| ]); | |
| mongo = php56WithExtensions.buildPecl { | |
| pname = "mongo"; | |
| version = "1.5.0"; | |
| src = pkgs.fetchurl { | |
| url = "https://pecl.php.net/get/mongo-1.5.0.tgz"; | |
| sha256 = "sha256-7KEL+kjrtNUM4QqYVG+eONfw+mFOdd1yADofB6N7QoM="; | |
| }; | |
| nativeBuildInputs = [ pkgs.autoconf pkgs.automake ]; | |
| buildInputs = [ php56WithExtensions pkgs.openssl_1_1 ]; | |
| configureFlags = [ | |
| "--with-php-config=${php56WithExtensions.unwrapped.dev}/bin/php-config" | |
| "--with-openssl-dir=${pkgs.openssl_1_1.dev}" | |
| ]; | |
| installPhase = '' | |
| mkdir -p $out/lib/php/extensions | |
| cp modules/mongo.so $out/lib/php/extensions/ | |
| ''; | |
| }; | |
| php56Configured = php56WithExtensions.buildEnv { | |
| extraConfig = '' | |
| extension=${mongo}/lib/php/extensions/mongo.so | |
| upload_max_filesize = 20M | |
| post_max_size = 20M | |
| ''; | |
| }; | |
| runtimePackages = [ | |
| pkgs.cacert | |
| pkgs.curl | |
| pkgs.git | |
| ]; | |
| appPackages = [ | |
| php56Configured | |
| ] ++ runtimePackages; | |
| in | |
| { | |
| devShells.default = pkgs.mkShell { | |
| packages = appPackages; | |
| }; | |
| packages.default = pkgs.buildEnv { | |
| name = "app-env"; | |
| paths = appPackages; | |
| }; | |
| } | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment