Nix PHP | 76 Members | |
| A room for PHP developers running on Nix | 22 Servers |
| Sender | Message | Time |
|---|---|---|
| 16 Aug 2024 | ||
| Let me find you an example... | 07:22:00 | |
| This might help you: https://github.com/loophp/nix-shell/blob/master/templates/basic/flake.nix you have a couple of PHP apps packaged. | 07:22:45 | |
| And here you have an example on how to add a flake.nix to the symfony/demo project: https://github.com/drupol/symfony-demo/pull/1 | 07:23:35 | |
| Oh and it builds the OCI image too | 07:23:50 | |
| you should have everything you need there | 07:24:01 | |
| Forget what I just said, that last example if very outdated. | 07:25:14 | |
| composer-plugin-nixify looks interesting thank you. With the first examples I see that it gets phpunit from Nixpkgs, I could do that but I would prefer to let composer deal with the PHP packages if possible. That way Nix isn't a "hard dependency". | 07:31:15 | |
In reply to @drupol:matrix.orgAh to bad :) | 07:31:26 | |
Then just use buildComposerProject builder from nixpkgs and let phpunit in the require-dev section. | 07:32:22 | |
That only works if I only use phpunit for testing right? Otherwise I would have to build two buildComposerProject one for testing and one for production? | 07:34:56 | |
When you build a project uising buildComposerProject it is inherently made for production. | 07:42:15 | |
Since it, by default, doesn't include require-dev. I don't see the point doing it either. | 07:42:40 | |
| Perhaps I'm misunderstanding your request? | 07:42:51 | |
| Maybe, let me try to rephrase. | 07:43:38 | |
| I would like to run phpunit in a Gitlab CI. Nix devShell will be used to provide PHP and Gitlab provides a MariaDB container. In an existing project we use imperative containers for the unittests. What I tried so far is a fixed output derivation which looks like the following.
| 07:53:48 | |
| You cannot have --no-dev and install phpunit with require-dev dependencies at the same time | 07:56:16 | |
| in this case you have to install phpunit separately | 07:56:37 | |
| Ah sorry I have two derivations, thats the one for production dependencies | 07:56:56 | |
| 07:57:08 | |
| This one depends on the previous one and that's how I noticed that the outputHash changed because I didn't push the previous derivation to the cache. Therefore the runner had to built it itself and failed because the hash didn't match. | 07:58:35 | |
| However I don't need it to work exactly this way. This was just me trying to hack something together. | 07:59:12 | |
| In a Python project with poetry2nix I can do this for example: https://github.com/Nebucatnetzer/sort-of-pastebin/blob/main/flake.nix#L54-L67 | 08:04:30 | |
| One is the dev environment which which I can run the tests and the other is the final application. | 08:05:07 | |
| Which I ten use like this to do the tests: https://github.com/Nebucatnetzer/sort-of-pastebin/blob/main/.github/workflows/tests.yml | 08:05:49 | |
| And when they succeed I build the container | 08:06:02 | |
| https://github.com/Nebucatnetzer/sort-of-pastebin/blob/main/.github/workflows/build_containers.yml | 08:06:10 | |
But you're using nix develop. | 08:09:59 | |
buildComposerProject does not create a development shell (to be used with nix develop). | 08:10:25 | |
| Is there a way to do that? | 08:15:32 | |
| Creating a devshell containing your tools ? | 08:23:39 | |