-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
fetchurl - add wrapper with output derivation overridable #158018
base: master
Are you sure you want to change the base?
fetchurl - add wrapper with output derivation overridable #158018
Conversation
hmm, ofBorg has some problems. I would guess there is some issue with this in nixpkgs which should be fixed before merging |
Looks like it ran out of memory during execution (exit code 137). I doubt this is something I can configure. How should I proceed @Lassulus ? |
ef45b5e
to
a80ea2e
Compare
can you update the usage in your first comment? |
Most of the time user would want to do something like hello = (prev.hello.overrideAttrs (oldAttrs: {
version = "1.2.3";
src = oldAttrs.src.override {
sha256 = "<something>";
};
}); which will not work unless the package also uses #119942 (if this change is compatible with that) or the user also updates
|
Given the new version, having to write {
tk869 = (pkgs.tk-8_6.override {
fetchurl = fetchurlOverridableOutput;
tcl = tcl869; # Something overriding `tcl-8_6 to an older version
}).overrideAttrs (self: rec {
src = self.src.override { sha256 = "1d7bfkxpacy33w5nahf73lkwxqpff44w1jplg7i2gmwgiaawvjwg"; };
});
} is somewhat awkward, and it doesn't really look any better than {
tk869 = (pkgs.tk-8_6.override {
fetchurl = args: lib.makeOverridable fetchurl args;
tcl = tcl869; # Something overriding `tcl-8_6 to an older version
}).overrideAttrs (self: rec {
src = self.src.override { sha256 = "1d7bfkxpacy33w5nahf73lkwxqpff44w1jplg7i2gmwgiaawvjwg"; };
});
} And in particular, this new approach doesn't scale once you start looking at other fetchers, unless we want to have a separate copy of every single fetcher that is named e.g. If we can't just make the fetcher overridable by default, then I would rather see us simply document this override trick in the manual. It could also be documented in comments in |
If the impact is not acceptable, I agree we should document the current solution. @lilyball's example can be eta-reduced and the unused {
tk869 = (pkgs.tk-8_6.override {
fetchurl = lib.makeOverridable fetchurl;
}).overrideAttrs (self: {
src = self.src.override { sha256 = "1d7bfkxpacy33w5nahf73lkwxqpff44w1jplg7i2gmwgiaawvjwg"; };
});
} Furthermore, it may be possible to write a helper function that takes care of the general pattern, detecting the fetchers used reflectively, but that may be an abstraction that is too fragile; not sure. |
Yeah, that's the first thing i did, but per @grahamc the perf impact was... substantial. I'd much prefer making it overridable by default if anyone has any clever ideas how to do so without causing massive perf degradation (and i'll even try to implement the ideas if so), but honestly i am not familiar enough with nix internals and perf consequences to have a good idea how to proceed on my own. I also agree that the current state (having a named wrapper) really doesn't buy us all that much compared to just manually wrapping the fetcher during override where desired. I actually realized this about 2 minutes after pushing the updated PR, but figured I'd wait to see if people felt similarly or if they found it useful. I guess that's answered :) If no one has good ideas on how to fix the perf problems in the original, i think i'll just drop this named-wrapper PR instead. |
Cost is around 0.5%; see #158968 |
I stongly agree with @lilyball here: The current opt-in solution is a non-starter UX wise.
@jtojnar Can you please explain why it wouldn't work as-is? I don't understand where the performance regression comes from, since I assume it would only cost us where we actually use |
That would be a very bad BC break, we widely rely on being able to override |
It wouldn't be any more breaking than the originally proposed solution, AFAICT. |
The originally proposed solution adds an
From a memory standpoint, making the fetcher overridable means persisting the original arugments to the fetcher so they can't be GC'd. I don't know how much of a difference that should make under normal use though. @roberth #158968 was measuring the cost of making |
can we document this workaround in the manual? While long term, we want a more declarative structure for packages anyway, this makes for an almost sane UX, and we can have it right now (at least as far as packages use the overlay style recursion). I guess we could also add a convenience function along the lines of |
Make the output of
fetchurl
overridable.Currently, the
fetchurl
function itself is overridable, but not the output derivation. This change fixes that, so the output derivation itself is also overridable.Motivating example:
Oftentimes a package uses
fetchurl
to set the value for the derivation'ssrc
attribute. Sometimes theurl
parameter tofetchurl
is computed. As an example, thetk
package acceptstcl
as a parameter for package dependency, and computes its ownurl
from the version attribute defined in thetcl
package. If one passes in a different version oftcl
totk
via something likeit would be very convenient to just update the
sha256
fortk
's sources without having to muck around with recreating the computed URL for the sources. With this change, it's pretty easy:Without this change, one has to manually construct the entire
fetchurl
args, which is much uglier.Alternatively, this makes it possible to easily substitute an internal mirror URL for a particular package.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes