!jngDrdMgndWibPCYsR:nixos.org

Nix PHP

77 Members
A room for PHP developers running on Nix22 Servers

Load older messages


SenderMessageTime
21 May 2023
@drupol:matrix.orgPol

I've updated the composer plugin with new commands options:

            ->addOption('only-repo', 'r', InputOption::VALUE_NONE, 'Generate only the repository, without the manifest file "packages.json".')
            ->addOption('only-manifest', 'm', InputOption::VALUE_NONE, 'Generate only the manifest "packages.json", without the repository.')
            ->addOption('only-print-manifest', 'p', InputOption::VALUE_NONE, 'Print the manifest for a given arbitrary repository directory.');
10:11:52
@drupol:matrix.orgPol I made those options to reduce the amount of file manipulation in pkgs/build-support/php/hooks/composer-install-hook.sh 10:12:30
@drupol:matrix.orgPol

The package installation procedure is now reduced to:

    # Remove "packages-dev" entries
    jq '."packages-dev" = []' composer.lock > newComposer.lock
    mv newComposer.lock composer.lock
    # Remove "require-dev" dependencies
    jq '."require-dev" = {}' composer.json > newComposer.json
    mv newComposer.json composer.json

    mkdir -p .repo

    # Create the manifest for the local repository
    COMPOSER_PROCESS_TIMEOUT=0 \
    COMPOSER_CACHE_DIR=/dev/null \
    COMPOSER_HOME="${composerVendorCache}/.composer" \
    composer --no-ansi build-local-repo -p $composerVendorCache > .repo/packages.json

    # Configure composer to use the local repository
    composer config repo.packagist false
    composer config repo.composer '{"type": "composer", "url": "file://'"$PWD"'/.repo/packages.json"}'

    # Merge the composer overrides to avoid randomly generated class names
    jq '. * input' "composer.json" "${composerOverrides}/composer.override.json" > newComposer.json
    mv newComposer.json composer.json

    echo "Finished composerInstallConfigureHook"
10:13:09
@drupol:matrix.orgPolI also updated the plugin to output json in alphabetical order10:13:39
22 May 2023
@drupol:matrix.orgPolToday I will most probably write a summary of all the things we tried to get this thing working. 06:58:52
@drupol:matrix.orgPolI've been testing that thing the whole weekend, and I improved it here and there as you can see in the PR.06:59:19
@drupol:matrix.orgPolThere is only ONE single issue with that method.06:59:31
@drupol:matrix.orgPol If by any change you have post-update-cmd in composer.json like in Drupal: https://github.com/drupal/drupal/blob/11.x/composer.json#L111
This is going to fail.
07:00:30
@drupol:matrix.orgPol Why? Because as far as I can see, the update command is expected to be run AFTER the install command and the autoloader needs to be loaded so the update command can run the command properly. 07:01:14
@drupol:matrix.orgPol But in our case, we are running the update command BEFORE the install command: https://github.com/NixOS/nixpkgs/blob/58fed5f92032c4e51286d08a76d9d2bab5443ecb/pkgs/build-support/php/hooks/composer-install-hook.sh#L52 07:02:18
@drupol:matrix.orgPol So today I'm going to test stuff and see how we can get rid of that composer update command before the install. If you have any clue, please let me know. 07:02:50
@drupol:matrix.orgPolOh I think I fixed the Drupal issue !08:28:50
@drupol:matrix.orgPolConfirmed! Drupal issue fixed :)08:31:55
@drupol:matrix.orgPol The fix has been committed to drupol/composer-local-repo-plugin: https://github.com/drupol/composer-local-repo-plugin/commit/9e1144ba0f3e98442bbfc955edd148be281c4148 and in the PR: https://github.com/NixOS/nixpkgs/compare/58fed5f92032c4e51286d08a76d9d2bab5443ecb..2d49300918ee738fa8f2e9d086647539493bb879 08:37:56
@drupol:matrix.orgPol Jan Tojnar: FYI, I think there are rooms for improvements in fossar/composition-c4. I'm trying to propose a PR, but I have the feeling that I need to move this aside or else I won't be doing anything else today... and I'm at work :D 10:09:39
@drupol:matrix.orgPol Basically, the idea is that Composer is able to download a package from dist or source attribute (see relevant part of the code https://github.com/composer/composer/blob/main/src/Composer/Downloader/DownloadManager.php#L143). In fossar/composition-c4, we only handle source. I guess it would not be complicated to fix this. 10:42:54
@drupol:matrix.orgPol * Basically, the idea is that Composer is able to download a package from dist or source attribute (see relevant part of the code https://github.com/composer/composer/blob/main/src/Composer/Downloader/DownloadManager.php#L143). In fossar/composition-c4, we only handle source. I guess it would not be complicated to fix this. I just don't have enough knowledge in Nix to do it... I'm still trying :D 11:45:27
@drupol:matrix.orgPolI created the relevant issue to keep track of this: https://github.com/fossar/composition-c4/pull/611:57:44
@drupol:matrix.orgPolWDYT of this? I just pushed a commit to refactor the script and add a little bit of documentation: https://github.com/NixOS/nixpkgs/blob/7f2c754d1daeeca5eef173b7a2ec6d305522857d/pkgs/build-support/php/hooks/composer-setup-hook.sh14:03:28
@drupol:matrix.orgPolThe other hook is also very clean now: https://github.com/NixOS/nixpkgs/blob/7f2c754d1daeeca5eef173b7a2ec6d305522857d/pkgs/build-support/php/hooks/composer-install-hook.sh14:05:01
@drupol:matrix.orgPol * WDYT of this? I just pushed a commit to refactor the setup hook script and add a little bit of documentation: https://github.com/NixOS/nixpkgs/blob/7f2c754d1daeeca5eef173b7a2ec6d305522857d/pkgs/build-support/php/hooks/composer-setup-hook.sh 14:09:41
@jtojnar:matrix.orgJan Tojnar
In reply to @drupol:matrix.org
So today I'm going to test stuff and see how we can get rid of that composer update command before the install. If you have any clue, please let me know.
Yeah, I think disabling scripts is proper solution – the only reason we are running composer update is to update the sources in the lockfile.
16:04:26
@jtojnar:matrix.orgJan Tojnar
In reply to @drupol:matrix.org
The fix has been committed to drupol/composer-local-repo-plugin: https://github.com/drupol/composer-local-repo-plugin/commit/9e1144ba0f3e98442bbfc955edd148be281c4148 and in the PR: https://github.com/NixOS/nixpkgs/compare/58fed5f92032c4e51286d08a76d9d2bab5443ecb..2d49300918ee738fa8f2e9d086647539493bb879
I do not see the motivation for https://github.com/drupol/composer-local-repo-plugin/commit/9e1144ba0f3e98442bbfc955edd148be281c4148
16:05:34
@jtojnar:matrix.orgJan Tojnar
In reply to @drupol:matrix.org
Basically, the idea is that Composer is able to download a package from dist or source attribute (see relevant part of the code https://github.com/composer/composer/blob/main/src/Composer/Downloader/DownloadManager.php#L143). In fossar/composition-c4, we only handle source. I guess it would not be complicated to fix this. I just don't have enough knowledge in Nix to do it... I'm still trying :D

I am only providing a single variant since otherwise fetchComposerDeps would have to store both, possibly doubling+ the output size.

I can only use source in composition-c4 because builtins.fetchGit works without an output hash, whereas builtins.fetchTarball would require it even without restricted evaluation mode. It is not a problem for you since you use FOD so you are already specifying the output hash.

16:10:05
@jtojnar:matrix.orgJan Tojnar alternately, we could provide both source and dist generated from a single source but that is pointless since composer will always fall back on what is available, even when using --prefer-source/--prefer-dist flags 16:12:28
@drupol:matrix.orgPol
In reply to @jtojnar:matrix.org
I do not see the motivation for https://github.com/drupol/composer-local-repo-plugin/commit/9e1144ba0f3e98442bbfc955edd148be281c4148
In Drupal, you have these kind of things: https://github.com/drupal/drupal/blob/11.x/composer.json#L124
16:16:15
@drupol:matrix.orgPolComposer repos inside the drupal sources.16:16:24
@drupol:matrix.orgPolWithout this change: https://github.com/drupol/composer-local-repo-plugin/commit/9e1144ba0f3e98442bbfc955edd148be281c4148 it simply doesn't work16:16:51
@drupol:matrix.orgPolBy the way, I just forced pushed on the branch, I made this new improvement: https://github.com/NixOS/nixpkgs/pull/232450/files#diff-d6938cf1d292c64b6f1726b28397358dfa80ce78c9cfaaf54591acf09c36a04eR4316:17:48
@drupol:matrix.orgPolI'm creating a derivation for building the Composer Home directory containing the Composer plugin.16:18:04

Show newer messages


Back to Room ListRoom Version: 6