PHP Composer does not find installed php extensions

Hello, I have a Problem using the PHP composer on NixOS, so I have installed PHP with some extensions that I need for a project(Magento2) with nix shell:

let
  pkgs = import <nixpkgs> { };

  packages = with pkgs; [
     (pkgs.php.buildEnv {
        extensions = ({ enabled, all }: enabled ++ (with all; [
                xdebug
                bcmath
                dom
                imagick
                intl
                opcache
                pdo
                pdo_mysql
                soap
                zip
                xsl
                mbstring
                gd
        ]));
        extraConfig = ''
          xdebug.mode=debug
        '';
      })
      phpPackages.composer
  ];
in
pkgs.mkShell {
  buildInputs = packages;
}

And now I have the problem that PHP is installing fine every extension is registered and lists with php -m so that works I tested the extensions that they really work and they do. Now to the fun part I need composer to install the magento2 Project the problem is that the composer install script requires some PHP modules( xsl mysql etc…) and composer does not recognize the PHP.ini that PHP is using, so the composer fails to install

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
Creating a "magento/project-community-edition" project at "./magento2"
Installing magento/project-community-edition (2.4.6-p1)
  - Installing magento/project-community-edition (2.4.6-p1): Extracting archive
Created project in /home/titus/WebstormProjects/Magento2DevSetup/magento2
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires magento/product-community-edition 2.4.6-p1 -> satisfiable by magento/product-community-edition[2.4.6-p1].
    - magento/product-community-edition 2.4.6-p1 requires ext-xsl * -> it is missing from your system. Install or enable PHP's xsl extension.

To enable extensions, verify that they are enabled in your .ini files:
    - /nix/store/ss4yv13gny44dj4svmlgq7lasikmjz62-php-with-extensions-8.1.20/lib/php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-xsl` to temporarily ignore these required extensions.

The problem I suspect is causing this is that composer does not get its .ini from php --ini and just uses the registered php.ini but has its own ant the PHP plugins are not registered there how can I fix it why is this the case shouldn’t composer do this automatically?

Did you manage to solve the problem?