From 28752cf31852546057c3f88cd0a0ebe23022910c Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Wed, 28 Sep 2022 09:34:13 +0200 Subject: [PATCH] feat: add PHP environment --- README.md | 8 ++++++++ flake.nix | 5 +++++ php/.envrc | 1 + php/flake.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ php/flake.nix | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 php/.envrc create mode 100644 php/flake.lock create mode 100644 php/flake.nix diff --git a/README.md b/README.md index 560cef8..af09209 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Once your preferred template has been initialized, you can use the provided shel | [Node.js][node] | [`node`](./node/) | | [OCaml] | [`ocaml`](./ocaml/) | | [Open Policy Agent][opa] | [`opa`](./opa) | +| [PHP] | [`php`](./php/) | | [Protobuf] | [`protobuf`](./protobuf/) | | [Ruby] | [`ruby`](./ruby/) | | [Rust] | [`rust`](./rust/) | @@ -170,6 +171,11 @@ The sections below list what each template includes. In all cases, you're free t - [Open Policy Agent][opa] 0.43.0 - [Conftest] 0.34.0 +### [`php`](./php/) + +- [PHP][php] 8.1.10 +- [Composer][composer] 2.4.2 + ### [`protobuf`](./protobuf/) - The [Buf CLI][buf] 1.7.0 @@ -222,6 +228,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [cargo-deny]: https://crates.io/crates/cargo-deny [clippy]: https://github.com/rust-lang/rust-clippy [clojure]: https://clojure.org +[composer]: https://getcomposer.org/ [conftest]: https://www.conftest.dev [cross]: https://github.com/cross-rs/cross [cue]: https://cuelang.org @@ -284,6 +291,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [packer]: https://packer.io [pip]: https://pypi.org/project/pip [phoenix]: https://phoenixframework.org +[php]: https://php.net/ [pnpm]: https://pnpm.io [protobuf]: https://developers.google.com/protocol-buffers [python]: https://python.org diff --git a/flake.nix b/flake.nix index 38055b9..37594bd 100644 --- a/flake.nix +++ b/flake.nix @@ -85,6 +85,11 @@ description = "Open Policy Agent development environment"; }; + php = { + path = ./php; + description = "PHP development environment"; + }; + protobuf = { path = ./protobuf; description = "Protobuf development environment"; diff --git a/php/.envrc b/php/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/php/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/php/flake.lock b/php/flake.lock new file mode 100644 index 0000000..1696a49 --- /dev/null +++ b/php/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1664349153, + "narHash": "sha256-F6ZAHd9qR2lp49L1NiBFZ1NVJdTne56+dkI62glOj/w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "467132e5ab10f122fbe313ebcc31eeaca65fae42", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/php/flake.nix b/php/flake.nix new file mode 100644 index 0000000..5285129 --- /dev/null +++ b/php/flake.nix @@ -0,0 +1,34 @@ +{ + description = "A Nix-flake-based PHP development environment"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs"; + }; + + outputs = + { self + , flake-utils + , nixpkgs + }: + + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ + (self: super: rec { + php = super.php; + composer = super.phpPackages.composer; + }) + ]; + pkgs = import nixpkgs { inherit overlays system; }; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ composer php ]; + + shellHook = '' + echo "`${pkgs.php}/bin/php --version`" + ''; + }; + }); +}