Matthew Robbetts <
wingfe...@gmail.com> writes:
> As an aside: is this mechanism an obvious thing? Even now that you’ve
> told me about it, I am looking at
> pkgs/development/libraries/qt-5/5.10/default.nix and I still don’t see
> it! I am guessing it comes in via the newScope argument? Is it
> documented anywhere?
That file defines a function that is turned into a package set by a call
to `makeScope' in `pkgs/top-level/all-packages.nix'. The function takes
a package set as its argument; `makeScope' [1] works by calling the
function with its own result,
makeScope = newScope: f:
let self = f self // { ... };
in self;
which is an old lazy functional programming trick. `f' is the function
defined in `pkgs/development/libraries/qt-5/5.10/default.nix', which has
the form:
self: with self; {
qtbase = ...;
qtwebengine = ...;
...
}
In Nix, this is about the same as defining a recursive set:
rec {
qtbase = ...;
qtwebengine = ...;
...
}
The difference between the fixed-point trick and the recursive set is
when overrides are applied: If we override with `overrideScope' (only in
the fixed-point version) to override `qtbase', then `qtwebengine' will
depend on the new one. If we override with `//' (which is the only
option in the recursive-set version) then `qtwebengine' will depend on
the old one. Why does this matter? Imagine you have a build that depends
directly on `qtbase' and `qtwebengine' and that you override `qtbase';
if `qtwebengine' is still built with the old `qtbase', then the build
will pull in both old and new versions and there will be trouble!
I've already said more than I intended to, so I hope this clarifies
things, rather than adding to the confusion!
Regards,
Thomas
[1].
https://github.com/NixOS/nixpkgs/blob/943592f69850fd07dd2422da062b1c1ebc45974d/lib/customisation.nix#L196