From f224ad463afed0f350b13df136d4d15e7941f4cb Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 30 Jun 2022 11:02:41 +0200 Subject: [PATCH] Update README. --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c91514..82959e7 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ Import the input: ```nix inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; phps.url = "github:loophp/nix-shell"; }; @@ -146,6 +146,57 @@ or phps.packages.${system}.env-php81-nts ``` +You may also use the API to build your own custom version of PHP in your own +flake: + +```nix +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + nix-shell.url = "github:loophp/nix-shell"; + }; + + outputs = { self, nixpkgs, flake-utils, nix-shell }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { + inherit system; + }; + + php = (nix-shell.api.makePhp system { + php = "php81"; + extensions = [ "pcov" "xdebug" ]; + withoutExtensions = [ "sodium" ]; + extraConfig = '' + memory_limit=-1 + ''; + flags = { + apxs2Support = false; + ztsSupport = false; + }; + }); + in + { + devShells = { + default = pkgs.mkShellNoCC { + name = "PHP project"; + + buildInputs = [ + php + php.packages.composer + pkgs.mailhog + ]; + }; + }; + } + ); +} +``` + ### Customize PHP To customize the PHP configuration, you can do it like this: