Skip to content

Commit

Permalink
refactor: Remove xdebugand pcov custom handling.
Browse files Browse the repository at this point in the history
It is now possible to load them through `composer.json`.
  • Loading branch information
drupol committed Feb 5, 2022
1 parent 31f5cbf commit e2d91ff
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 184 deletions.
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ which can be installed on (*almost*) any operating system.

Each available environment provides the following tools:

* PHP with extensions, `xdebug` and `pcov`,
* Custom `php.ini` loading,
* Composer,
* Git,
Expand All @@ -25,7 +24,20 @@ Each available environment provides the following tools:
Available PHP versions from `5.6` to `8.1`.

The PHP extensions to use are automatically inferred
from the `composer.json` file.
from the `composer.json` and `composer.lock` files.

To load the `xdebug` and `pcov` extensions, edit `composer.json` as such:

```json
...8<...

"require": {
"ext-xdebug": "*",
"ext-pcov": "*",
}

...>8...
```

## Usage

Expand All @@ -47,22 +59,22 @@ feel free to use the `NTS` if needed, see the matrix below.

Available PHP versions and environments are:

* `php56`, `php56-nts`, `php56-nodebug`, `php56-nts-nodebug`
* `env-php56`, `env-php56-nts`, `env-php56-nodebug`, `env-php56-nts-nodebug`
* `php70`, `php70-nts`, `php70-nodebug`, `php70-nts-nodebug`
* `env-php70`, `env-php70-nts`, `env-php70-nodebug`, `env-php70-nts-nodebug`
* `php71`, `php71-nts`, `php71-nodebug`, `php71-nts-nodebug`
* `env-php71`, `env-php71-nts`, `env-php71-nodebug`, `env-php71-nts-nodebug`
* `php72`, `php72-nts`, `php72-nodebug`, `php72-nts-nodebug`
* `env-php72`, `env-php72-nts`, `env-php72-nodebug`, `env-php72-nts-nodebug`
* `php73`, `php73-nts`, `php73-nodebug`, `php73-nts-nodebug`
* `env-php73`, `env-php73-nts`, `env-php73-nodebug`, `env-php73-nts-nodebug`
* `php74`, `php74-nts`, `php74-nodebug`, `php74-nts-nodebug`
* `env-php74`, `env-php74-nts`, `env-php74-nodebug`, `env-php74-nts-nodebug`
* `php80`, `php80-nts`, `php80-nodebug`, `php80-nts-nodebug`
* `env-php80`, `env-php80-nts`, `env-php80-nodebug`, `env-php80-nts-nodebug`
* `php81`, `php81-nts`, `php81-nodebug`, `php81-nts-nodebug`
* `env-php81`, `env-php81-nts`, `env-php81-nodebug`, `env-php81-nts-nodebug`
* `php56`, `php56-nts`
* `env-php56`, `env-php56-nts`
* `php70`, `php70-nts`
* `env-php70`, `env-php70-nts`
* `php71`, `php71-nts`
* `env-php71`, `env-php71-nts`
* `php72`, `php72-nts`
* `env-php72`, `env-php72-nts`
* `php73`, `php73-nts`
* `env-php73`, `env-php73-nts`
* `php74`, `php74-nts`
* `env-php74`, `env-php74-nts`
* `php80`, `php80-nts`
* `env-php80`, `env-php80-nts`
* `php81`, `php81-nts`
* `env-php81`, `env-php81-nts`

This package also provide development environments with some tools:

Expand All @@ -75,7 +87,7 @@ This package also provide development environments with some tools:
In order to use them, use the prefix `env-`:

```shell
nix develop github:loophp/nix-shell#env-php81-nts-nodebug
nix develop github:loophp/nix-shell#env-php81-nts
```

### In another flake
Expand All @@ -100,8 +112,8 @@ Then each PHP environment will be available at
or

```nix
# PHP 8.1 Non-Thread-Safe, no debug extension and some tools
phps.packages.${system}.env-php81-nts-nodebug
# PHP 8.1 Non-Thread-Safe
phps.packages.${system}.env-php81-nts
```

### Customize PHP
Expand Down
168 changes: 5 additions & 163 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@
"zip"
"zlib"
] ++ userExtensions ++ composerLockExtensions;

optional = [
"redis"
"ds"
];

debug = [
"pcov"
"xdebug"
];
};

phpIniFile = "${builtins.getEnv "PWD"}/.php.ini";
Expand All @@ -100,7 +90,7 @@

makePhp =
{ version ? "8.1"
, extensions ? extensionsGroups.mandatory ++ extensionsGroups.debug
, extensions ? extensionsGroups.mandatory
, flags ? { }
, extraConfig ? ""
}:
Expand All @@ -118,35 +108,17 @@
derivations = rec
{
default = derivations.php81;
default-nodebug = derivations.php81-nodebug;
default-nts = derivations.php81-nts;
default-nts-nodebug = derivations.php81-nts-nodebug;

php56 = makePhp {
version = "5.6";
extensions = builtins.filter (x: !builtins.elem x [ "sodium" "pcov" ]) (extensionsGroups.mandatory ++ extensionsGroups.debug);
inherit extraConfig;
};

php56-nodebug = makePhp {
version = "5.6";
extensions = builtins.filter (x: !builtins.elem x [ "sodium" ]) extensionsGroups.mandatory;
extensions = builtins.filter (x: !builtins.elem x [ "sodium" "pcov" ]) extensionsGroups.mandatory;
inherit extraConfig;
};

php56-nts = makePhp {
version = "5.6";
extensions = builtins.filter (x: !builtins.elem x [ "sodium" "pcov" ]) (extensionsGroups.mandatory ++ extensionsGroups.debug);
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

php56-nts-nodebug = makePhp {
version = "5.6";
extensions = builtins.filter (x: !builtins.elem x [ "sodium" ]) extensionsGroups.mandatory;
extensions = builtins.filter (x: !builtins.elem x [ "sodium" "pcov" ]) extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
Expand All @@ -168,33 +140,11 @@
inherit extraConfig;
};

php70-nodebug = makePhp {
version = "7.0";
extensions = extensionsGroups.mandatory;
inherit extraConfig;
};

php70-nts-nodebug = makePhp {
version = "7.0";
extensions = extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

php71 = makePhp {
version = "7.1";
inherit extraConfig;
};

php71-nodebug = makePhp {
version = "7.1";
extensions = extensionsGroups.mandatory;
inherit extraConfig;
};

php71-nts = makePhp {
version = "7.1";
flags = {
Expand All @@ -204,27 +154,11 @@
inherit extraConfig;
};

php71-nts-nodebug = makePhp {
version = "7.1";
extensions = extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

php72 = makePhp {
version = "7.2";
inherit extraConfig;
};

php72-nodebug = makePhp {
version = "7.2";
extensions = extensionsGroups.mandatory;
inherit extraConfig;
};

php72-nts = makePhp {
version = "7.2";
flags = {
Expand All @@ -234,27 +168,11 @@
inherit extraConfig;
};

php72-nts-nodebug = makePhp {
version = "7.2";
extensions = extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

php73 = makePhp {
version = "7.3";
inherit extraConfig;
};

php73-nodebug = makePhp {
version = "7.3";
extensions = extensionsGroups.mandatory;
inherit extraConfig;
};

php73-nts = makePhp {
version = "7.3";
flags = {
Expand All @@ -264,16 +182,6 @@
inherit extraConfig;
};

php73-nts-nodebug = makePhp {
version = "7.3";
extensions = extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

php74 = makePhp {
version = "7.4";
inherit extraConfig;
Expand All @@ -288,22 +196,6 @@
inherit extraConfig;
};

php74-nodebug = makePhp {
version = "7.4";
extensions = extensionsGroups.mandatory;
inherit extraConfig;
};

php74-nts-nodebug = makePhp {
version = "7.4";
extensions = extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

php80 = makePhp {
version = "8.0";
inherit extraConfig;
Expand All @@ -318,22 +210,6 @@
inherit extraConfig;
};

php80-nodebug = makePhp {
version = "8.0";
extensions = extensionsGroups.mandatory;
inherit extraConfig;
};

php80-nts-nodebug = makePhp {
version = "8.0";
extensions = extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

php81 = makePhp {
version = "8.1";
inherit extraConfig;
Expand All @@ -348,26 +224,8 @@
inherit extraConfig;
};

php81-nodebug = makePhp {
version = "8.1";
extensions = extensionsGroups.mandatory;
inherit extraConfig;
};

php81-nts-nodebug = makePhp {
version = "8.1";
extensions = extensionsGroups.mandatory;
flags = {
apxs2Support = false;
ztsSupport = false;
};
inherit extraConfig;
};

env-default = makePhpEnv "env-php-default" derivations.php81;
env-default-nodebug = makePhpEnv "env-php-default-nodebug" derivations.php81-nodebug;
env-default-nts = makePhpEnv "env-php-nts" derivations.php81-nts;
env-default-nts-nodebug = makePhpEnv "env-php-nts-nodebug" derivations.php81-nts-nodebug;

env-php56 = makePhpEnv "env-php56" php56;
env-php71 = makePhpEnv "env-php71" php71;
Expand All @@ -384,32 +242,16 @@
env-php74-nts = makePhpEnv "env-php74-nts" php74-nts;
env-php80-nts = makePhpEnv "env-php80-nts" php80-nts;
env-php81-nts = makePhpEnv "env-php81-nts" php81-nts;

env-php56-nodebug = makePhpEnv "env-php56-nodebug" php56-nodebug;
env-php71-nodebug = makePhpEnv "env-php71-nodebug" php71-nodebug;
env-php72-nodebug = makePhpEnv "env-php72-nodebug" php72-nodebug;
env-php73-nodebug = makePhpEnv "env-php73-nodebug" php73-nodebug;
env-php74-nodebug = makePhpEnv "env-php74-nodebug" php74-nodebug;
env-php80-nodebug = makePhpEnv "env-php80-nodebug" php80-nodebug;
env-php81-nodebug = makePhpEnv "env-php81-nodebug" php81-nodebug;

env-php56-nts-nodebug = makePhpEnv "env-php56-nts-nodebug" php56-nts-nodebug;
env-php71-nts-nodebug = makePhpEnv "env-php71-nts-nodebug" php71-nts-nodebug;
env-php72-nts-nodebug = makePhpEnv "env-php72-nts-nodebug" php72-nts-nodebug;
env-php73-nts-nodebug = makePhpEnv "env-php73-nts-nodebug" php73-nts-nodebug;
env-php74-nts-nodebug = makePhpEnv "env-php74-nts-nodebug" php74-nts-nodebug;
env-php80-nts-nodebug = makePhpEnv "env-php80-nts-nodebug" php80-nts-nodebug;
env-php81-nts-nodebug = makePhpEnv "env-php81-nts-nodebug" php81-nts-nodebug;
};
in
{
defaultPackage = derivations.default;
defaultPackage = derivations.default-nts;

packages = derivations;

devShell = pkgs.mkShellNoCC {
name = derivations.default.name;
buildInputs = [ derivations.default ];
buildInputs = [ derivations.default-nts ];
};

devShells = builtins.mapAttrs
Expand Down

0 comments on commit e2d91ff

Please sign in to comment.