this post was submitted on 01 Sep 2023
4 points (83.3% liked)

Nix / NixOS

1765 readers
3 users here now

Main links

Videos

founded 1 year ago
MODERATORS
 

Edit: Solved at https://lemmings.world/comment/1719409


Hi there! I'm trying to make php and composer work. I have this in environment.systemPackages:

    (pkgs.php82.buildEnv {
      extensions = ({ enabled, all }: enabled ++ (with all; [
        xdebug
        redis
      ]));
      extraConfig = ''
        memory_limit=2G
        xdebug.mode=debug
      '';
    })
    php82Extensions.redis

The problem is that while running php -m correctly prints that redis extension is installed, composer does not, because it uses a different php:

  • file $(which php) prints the path /nix/store/igx8j4qjxy9jyj8kjyccwarnzqq5vsml-php-with-extensions-8.2.9/bin/php
  • cat $(which composer) shows that it's a wrapper for '/nix/store/lv4prxa52zifr54ws56iz3b9kdhs1b5w-php-with-extensions-8.2.9/bin/php' --add-flags '/nix/store/avqj0662f4gg2s875zlbbjajx6fm6bl0-php-composer-2.5.5/libexec/composer/composer.phar'

Note that the path to php is different. Is there any way to correct it on my side? I'd like to avoid having to install composer manually

top 2 comments
sorted by: hot top controversial new old
[โ€“] ck_@discuss.tchncs.de 1 points 1 year ago (1 children)

pkgs.composer.override { php = YourPhp; }; should do the trick.

[โ€“] rikudou@lemmings.world 1 points 1 year ago

Just a while ago I solved it using this: https://lemmings.world/comment/1719409

But thanks, will remember it for the next time!