-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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.packages: Make packages overridable #107044
Conversation
This will make it easier to make overridable. Had to rename `packages` attribute to `tools` in `php-packages.nix` because `packages` is shadowed by `makeScope`.
Seeing the state of various methods to install dependencies to PHP (pyenv, nvm and phpenv and custom PHP tarballs on Travis, Docker and who knows what on GitHub actions), I have decided to switch to Nix for installing all dependencies. Unfortunately, Nixpkgs repository does not contain old PHP versions but it is trivial with Nix to build them ourselves. We will be able to use Cachix to avoid rebuilding them over and over again. This is only a first step, the actual switch to Nix on CI will come later. Also the Nixpkgs PHP infrastructure does not support overriding nicely, I opened NixOS/nixpkgs#107044 to address that.
This will allow patching extensions without having to manually having to patch all occurrences in the dependency tree.
2fe6351
to
b2594c7
Compare
It sounds like you're going to publish this for broad use? I have a few internal applications I need to support still running |
@aanderse It is already in the selfoss repository (see the links in the OP). Though I hope to remove PHP 5.6 as soon as I manage to release selfoss 2.19, which is the last version I promised PHP 5 support for. |
@jtojnar there isn't a binary cache yet, though, is there? Thanks! Awesome work. |
@aanderse Yes, there is. Turns out Cachix is amazing: |
Related PR for emacs #107152. We really need to converge on a single interface here (partially NixOS/rfcs#67). |
@@ -13,6 +13,7 @@ let | |||
, version | |||
, sha256 | |||
, extraPatches ? [] | |||
, packageOverrides ? (final: prev: {}) |
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.
Python nowadays also supports overrideScope'
but it has not been documented yet. My intention is to deprecate this packageOverrides
because it does not compose.
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.
It does actually compose:
let
pkgs = import ./. { };
idOverlay = final: prev: {};
composeOverlays =
old:
new:
final:
prev:
let
oldInstantiated = old final prev;
prevWithOld = prev // oldInstantiated;
in
oldInstantiated // new final prevWithOld;
oldPhp = pkgs.php.override {
packageOverrides = final: prev: {
extensions = prev.extensions // {
mysqlnd = prev.extensions.mysqlnd.overrideAttrs (attrs: {
foo = "foo";
});
};
};
};
in
oldPhp.override (oldOverrides: {
packageOverrides = composeOverlays (oldOverrides.packageOverrides or idOverlay) (final: prev: {
extensions = prev.extensions // {
mysqlnd = prev.extensions.mysqlnd.overrideAttrs (attrs: {
foo = prev.extensions.mysqlnd.foo or "" + "bar";
});
};
});
})
But yeah, it is a mouthful.
Wrote a draft for an RFC on this topic NixOS/rfcs#83. |
Merging as is for now, will update it to match the RFC once we figure it out. |
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 approve of these changes since it doesn't make sense to wait around for the RFC process to happen. This brings us benefits right now, and we can match the RFC API later on.
@aanderse I have extracted the PHP expressions into a separate repository: https://github.com/fossar/nix-phps |
@jtojnar thank you very much! That is great! ✨ |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Motivation for this change
This will allow patching extensions without having to manually having to patch all occurrences in the dependency tree (like I did in fossar/selfoss@cb22131), see clean-up PR depending on this PR.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)