mkComposerRepository - php: command not found

Hello, I’m trying to make a derivation that builds my PHP (Laravel) application.
Here’s the code of one of my attampts:

{ stdenvNoCC, php83 }: stdenvNoCC.mkDerivation (finalAttrs:
let
    php' = php83.withExtensions ({ enabled, all }: enabled );
in {
    pname =  "yota-laravel";
    version = "2.0.0";

    src = ./.;

    nativeBuildInputs = [
        php'.packages.composer
        php'.composerHooks.composerInstallHook
    ];

    composerRepository = php'.mkComposerRepository {
        inherit (finalAttrs) src pname version;
        composerNoDev = true;
        composerNoPlugins = true;
        composerNoScripts = true;
        composerLock = ./composer.lock;
        vendorHash = "sha256-vYuWiX3YxS6ZZ3ngsYDuR6ydggBBwBG8K+KRBP8UqrA=";
    };

    buildPhase = ''
        php artisan config:cache
        php artisan route:cache
        php artisan view:cache
    '';
})

And here’s the log:

@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/r9zqbc4ql5wki6rpcs77zmpv2sdz89is-zf911lix4chz74w7c526zi6n8ksb9jzw-source
source root is zf911lix4chz74w7c526zi6n8ksb9jzw-source
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
Executing composerInstallConfigureHook
Validating consistency between composer.lock and /nix/store/gawqdzilggwhlrscxi4df66v8b9n4qrk-yota-laravel-2.0.0-composer-repository/composer.lock
Finished composerInstallConfigureHook
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
/nix/store/xkjqxa15vdg1b9n1mzzb0jw25vnmybbm-stdenv-linux/setup: line 1561: php: command not found

And if I remove the buildPhase I get the following log:

@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/wxgbwkrxwnh9y41wb13bym4i47vrbxcp-zjx5d5zrqmbjq6mq5ghz33f6dlwbikzl-source
source root is zjx5d5zrqmbjq6mq5ghz33f6dlwbikzl-source
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
Executing composerInstallConfigureHook
Validating consistency between composer.lock and /nix/store/gawqdzilggwhlrscxi4df66v8b9n4qrk-yota-laravel-2.0.0-composer-repository/composer.lock
Finished composerInstallConfigureHook
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
Executing composerInstallBuildHook
Setting COMPOSER_ROOT_VERSION to 2.0.0
/nix/store/pxmin3bdjmlcg6wjjps4yjcl618bmk0k-composer-install-hook.sh/nix-support/setup-hook: line 86: composer-local-repo-plugin: command not found
nix/store/pxmin3bdjmlcg6wjjps4yjcl618bmk0k-composer-install-hook.sh/nix-support/setup-hook: line 86: composer-local-repo-plugin: command not found

The composerInstallHook require a very specific version of Composer including a specific module. The error you see is Composer trying to run that command (nixpkgs/pkgs/build-support/php/hooks/composer-install-hook.sh at 041fbed9819322d34fc685149e1f84408b80a8dd · NixOS/nixpkgs · GitHub).

Does that mean I shouldn’t use composerInstallHook or is there a way to specify a required composer version?

Why don’t you use buildComposerProject ?

I was experimenting with different ways to make my derivation. Especially composerRepository seems very useful for my case, because besides Composer for PHP, I’ll also have to run NPM to build the JavaScript files that I have to serve.