Running PHP Composer in a derivation failed

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:
    php' = php83.withExtensions ({ enabled, all }: enabled );
in {
    pname =  "yota-laravel";
    version = "2.0.0";

    src = ./.;

    nativeBuildInputs = [

    buildInputs = [

    COMPOSER_CACHE_DIR = "/dev/null";

    buildPhase = ''
        composer --no-ansi --no-interaction --no-dev --no-plugins --no-scripts install
        php artisan config:cache
        php artisan route:cache
        php artisan view:cache

    installPhase = ''
        mkdir $out
        cp -r . $out

It took 4m55s and it failed with the following log output:

  - Installing nikic/php-parser (v5.0.2): Cloning 139676794d
    Install of nikic/php-parser failed
  - Installing psy/psysh (v0.12.3): Cloning b6b6cce7d3
    Install of psy/psysh failed
  - Installing laravel/tinker (v2.9.0): Cloning 502e0fe3f0
    Install of laravel/tinker failed

In Git.php line 472:
  Failed to clone via https, ssh  
   protocols, aborting.                                                        
    Cloning into '/build/4g3hx676n3s5r809i1lql6d22x04h42g-source/vendor/doctr  
    fatal: unable to access '':   
  Could not resolve host:                                           
    Cloning into '/build/4g3hx676n3s5r809i1lql6d22x04h42g-source/vendor/doctr  
    error: cannot run ssh: No such file or directory                           
    fatal: unable to fork                                                      

You don’t have internet access in the build sandbox and cannot run commands that need to download things unless they are a fixed output derivation (FOD).

1 Like

Maybe this will help?

1 Like

Actually, I first tried using buildComposerProject and mkComposerRepository, but didn’t succeed.
I also posted questions regarding the respective issues I had here: :sweat_smile: