-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
php: add new Composer builder #248184
php: add new Composer builder #248184
Conversation
fcbcf0f
to
4493934
Compare
4493934
to
56c823c
Compare
190cebe
to
59ffb11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been testing this builder with some packages and find it very intuitive to use and am hoping to get it included soon. 👍🏼
@drupol except if you express strong rejection, I suggest that we move forward whatever is left to do to another PR and I can merge this now. |
Give me an extra day so I can make last minor changes please :) |
ea28e93
to
15c7a4d
Compare
15c7a4d
to
f9e0b70
Compare
d94242b
to
cb6c49c
Compare
I'm also thinking about commit messages. Rather than the prefixes I think it goes more in line with the contribution guidelines that way EDIT: We can also just squash merge it using GitHub. |
1c2d6d2
to
6ea64c8
Compare
Actually, yes, we never have |
Let's squash all of these commits during the merge, WDYT? |
I disagree, this is valuable history which is not that bad in terms of atomicity, losing it does not really make sense or bring any value IMHO. |
Hello, does this PR handle git (vcs ?) dependencies as specified here ? If not may be it could be stated in the docs ! I'm trying to package the above software and the tooling introduced by this PR gives me this :
(the full nix expression is here : https://github.com/sinavir/sinavir/blob/lychee/lychee-nix/lychee.nix) Nevertheless, this PR seems amazing ! Thanks for your work ! (PS: I'm not very familiar with composer so it may be just me not understanding how things are working) |
I tried locally and I get:
The new builder should support this kind of repo, but I have the feeling that you reached the limit for accessing that repo, that's why you get the error. Maybe this is something we could improve at some point (I have no clue how yet). |
Ok going to rewrite all of them properly. |
6ea64c8
to
3eb168d
Compare
@GrahamcOfBorg build phpPackages.composer |
Ok, Thank you for the information. I don't have the throttling message and |
Well well well.. @RaitoBezarius or @etu ? |
Add a module definition for flarum, copied/inspired by this closed PR from a few years ago https://github.com/NixOS/nixpkgs/pull/96869/files#diff-d694d99e5b93515b9aeb968b1335e30f9349a205780f0f558d131988c7913dec We commented out most of the module and added pieces back one by one, following the instructions at https://docs.flarum.org/install/ A key realization (which was already in the original PR) was that we could pass in a configuration file to php flarum install https://discuss.flarum.org/d/22187-command-line-install-via-php-flarum-install-no-interaction/5 Add https://github.com/loophp/nix-php-composer-builder/ as an input to the module because it's used in packaging We are pinning it to 0caf5a60753397cfa959a74fc9ea0562556573c1 because that's what we developed against. Currently the latest version puts build artifacts in directories that are not compatible with our module definition. We will look into pointing to the latest of that repo or use the upstreamed version introduced in php: add new Composer builder NixOS/nixpkgs#248184 add a default configuration for flarum Future work: - as mentioned previous, update the php-composer-builder to a newer SHA or use the upstream version - add testing using nixos tests pattern that pretalx introduced Co-authored-by: Jason Odoom jasonodoom@gmail.com Co-authored-by: Anish Lakhwara anish+git@lakhwara.com Co-authored-by: Dominic Mills dominic.millz27@gmail.com Co-authored-by: Albert Chae albertchae@users.noreply.github.com Co-authored-by: Jack Leightcap jack@leightcap.com
The implementation was upstreamed to nixpkgs, see NixOS/nixpkgs#248184
I'm a bit late on this, but does the buildComposerProject also have a guard against forgetting to update the FOD-hash? In yarn and Cargo builders, we include the lockfile in the fixed-output derivation, and then check that the lockfile in the deps FOD is the same as in src when building. |
I don't think we have that ... yet? |
@drupol Regarding #237307 we wanted to execute unit and possibly integration tests as part of the derivation created via |
What do you think of this? Could you test please? #261429 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/contribute-to-the-nix-2023-recap/37484/8 |
Introducing a new builder for PHP Composer-Based Applications
Ensuring reproducibility and stability of outputs is required even when using an external dependency manager (Composer). As such, we've explored several possible solutions.
The first attempt of this PR was using a Fixed Output Derivation strategy, using the Composer cache. Although this solution rectified numerous issues, it was not entirely secure, as it was heavily dependent on Composer. If Composer implemented even a minor structural alteration in the cache structure, it could break all derivations based on this builder. As a result, we concluded that this solution wasn't ideal.
Our second attempt involved the use of fossar/composition-c4. This project reads the
composer.lock
file and constructs a local Composer repository, which is then used to install the dependencies. However, as Import From Derivation (IFD) is not permitted innixpkgs
, this approach didn't serve as a feasible solution. Moreover,path
type repositories are currently unsupported, adding another roadblock.A proof-of-concept led to the creation of our last and final attempt; a custom Composer plugin,
nix-community/composer-local-repo-plugin
providing a new command. It mirrors the functionalities offossar/composition-c4
and is written in PHP. It relies entirely on Composer to create a local Composer repository, thus emerging as a solid solution.Although this plugin is currently hosted under my own name, there is a consideration to host it elsewhere, a decision yet to be made.Here's a diagram overview on how the new builder is working
This PR includes the following changes:
mkDerivation
wrappers)php.buildComposerProject
php.mkComposerRepository
php.composerHooks.composerRepositoryHook
php.composerHooks.composerInstallHook
This new helpers significantly simplifies the process of integrating applications such as Symfony App, Wordpress or even Drupal into Nix, streamlining development and deployment.
Below is a practical example demonstrating how to efficiently package Drupal using this approach:
Or magento2:
Todo
--no-dev
Upcoming PRs
composer.json
for extensions and instantiate the adequatephp
attribute with these extensions enabled. This has already been done in https://github.com/loophp/nix-shell/, we just need to formalize it in here.