!jngDrdMgndWibPCYsR:nixos.org

Nix PHP

71 Members
A room for PHP developers running on Nix22 Servers

Load older messages


SenderMessageTime
14 Aug 2024
@drupol:matrix.orgPolIdeally yes19:11:14
@drupol:matrix.orgPol8.2.14 doesn't exists IIRC19:11:22
@piotrkwiecinski:matrix.orgpiotrkwiecinski8.2.14 Released: 21 Dec 202319:19:18
@drupol:matrix.orgPolI probably forgot it perhaps20:04:18
@piotrkwiecinski:matrix.orgpiotrkwiecinskiLooks like php core team too as they haven't patched it :)20:04:51
@piotrkwiecinski:matrix.orgpiotrkwiecinskiphp 8.1.28 builds in php-src-nix20:05:41
@piotrkwiecinski:matrix.orgpiotrkwiecinskiI'm testing 8.1.18 but looks like 8.1.x branch should be fine now20:06:09
@piotrkwiecinski:matrix.orgpiotrkwiecinskiI'll probably have some time next week to play around with stabilizing other branches20:07:29
@drupol:matrix.orgPoloki20:16:45
16 Aug 2024
@nebucatnetzer13:matrix.orgnebucatnetzer13 joined the room.06:51:09
@nebucatnetzer13:matrix.orgnebucatnetzer13

Hi everyone, does someone have a public project where phpunit is working and the dev dependencies aren't part of the final derivation?
I think I know how I would package a whole project by itself but I would like to achieve the following:

  1. Load Nix Shell and an additional container image for the DB
  2. Run unittests
06:53:18
@nebucatnetzer13:matrix.orgnebucatnetzer13 *

Hi everyone, does someone have a public project where phpunit is working and the dev dependencies aren't part of the final derivation?
I think I know how I would package a whole project by itself but I would like to achieve the following:

  1. Load Nix Shell and an additional container image for the DB
  2. Run unittests
  3. Create final derivation/container image
06:53:41
@nebucatnetzer13:matrix.orgnebucatnetzer13 *

Hi everyone, does someone have a public project where phpunit is working and the dev dependencies aren't part of the final derivation?
I think I know how I would package a whole project by itself but I would like to achieve the following:

  1. Load Nix Shell and an additional container image for the DB
  2. Run unittests
  3. Create final derivation/container image without dev dependencies

With poetry2nix this is quite easy to do but I haven't figured out how to do it with PHP so that I don't have to redownload all the composer dependencies every time.
With a container based approach I have a base image which contains the production dependencies and for the unittests I build an image on top of that, that contains the dev dependencies as well.

06:55:45
@drupol:matrix.orgPolLet me find you an example... 07:22:00
@drupol:matrix.orgPolThis 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
@drupol:matrix.orgPolAnd here you have an example on how to add a flake.nix to the symfony/demo project: https://github.com/drupol/symfony-demo/pull/107:23:35
@drupol:matrix.orgPolOh and it builds the OCI image too07:23:50
@drupol:matrix.orgPolyou should have everything you need there07:24:01
@drupol:matrix.orgPolForget what I just said, that last example if very outdated.07:25:14
@nebucatnetzer13:matrix.orgnebucatnetzer13composer-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
@nebucatnetzer13:matrix.orgnebucatnetzer13
In reply to @drupol:matrix.org
Forget what I just said, that last example if very outdated.
Ah to bad :)
07:31:26
@drupol:matrix.orgPol Then just use buildComposerProject builder from nixpkgs and let phpunit in the require-dev section. 07:32:22
@nebucatnetzer13:matrix.orgnebucatnetzer13 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
@drupol:matrix.orgPol When you build a project uising buildComposerProject it is inherently made for production. 07:42:15
@drupol:matrix.orgPol Since it, by default, doesn't include require-dev. I don't see the point doing it either. 07:42:40
@drupol:matrix.orgPolPerhaps I'm misunderstanding your request?07:42:51
@nebucatnetzer13:matrix.orgnebucatnetzer13Maybe, let me try to rephrase.07:43:38
@nebucatnetzer13:matrix.orgnebucatnetzer13

I would like to run phpunit in a Gitlab CI. Nix devShell will be used to provide PHP and Gitlab provides a MariaDB container.
Composer brings in some form the additional dependencies.

In an existing project we use imperative containers for the unittests.
Each containers brings a vendor directory that is based on the composer.lock from the main branch.
In the pipeline composer install then only has to install packages that have changed compared to the main branch, which often are none.
This way it's faster and we don't hammer packagist.org.

What I tried so far is a fixed output derivation which looks like the following.
In the pipeline I then simply copied the content into the build directory and rebuilt the autoloader.
It is hacky but it worked in principle, until I noticed that the outputHash changed on the runner, compared to my computer.

stdenvNoCC.mkDerivation {
  name = "composer-dependencies";
  src = composerFiles;
  nativeBuildInputs = [ php83Packages.composer ];
  buildPhase = ''
    export COMPOSER_HOME=$TMPDIR
    composer install --no-interaction --no-scripts --no-ansi --no-autoloader --no-dev
  '';
  installPhase = ''
    mkdir -p $out/
    cp -r vendor $out/
  '';
  dontFixup = true;
  outputHashAlgo = "sha256";
  outputHashMode = "recursive";
  outputHash = "sha256-sK2CvCMvlAAPdaeXLl6LwKAUJeiw9p6zXVxio6y0w0c=";
}
07:53:48
@piotrkwiecinski:matrix.orgpiotrkwiecinskiYou cannot have --no-dev and install phpunit with require-dev dependencies at the same time07:56:16
@piotrkwiecinski:matrix.orgpiotrkwiecinskiin this case you have to install phpunit separately07:56:37

Show newer messages


Back to Room ListRoom Version: 6