Skip to content
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

overlay: doc update for self/super -> final/previous #30958

Closed

Conversation

disassembler
Copy link
Member

Motivation for this change

confusion of what self and super represent in overlays, since this is something users can set and isn't hard coded, making this change to the docs should help.

@nbp

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Copy link
Member

@nbp nbp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a renaming issue: previous <-> final

doc/overlays.xml Outdated
};
}
</programlisting>

<para>The first argument (<varname>self</varname>) corresponds to the final package
<para>The first argument (<varname>final</varname>) corresponds to the previous package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad rewrite again :/

@disassembler disassembler changed the title overlay: doc update for self/super -> previous/final overlay: doc update for self/super -> final/previous Oct 30, 2017
doc/overlays.xml Outdated
corresponds to the result of the evaluation of the previous stages of
<para>The second argument (<varname>previous</varname>)
corresponds to the result of the evaluation of <literal>Nixpkgs</literal> with the
overlays applied that are called prior to the application of the current overlay.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/that are called/

@disassembler disassembler force-pushed the overlay-self-super-rename branch 2 times, most recently from b05f34a to b0fab62 Compare October 30, 2017 11:25
Copy link
Member

@nbp nbp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last nits before merging.

doc/overlays.xml Outdated
};
}
</programlisting>

<para>The first argument (<varname>self</varname>) corresponds to the final package
<para>The first argument (<varname>final</varname>) corresponds to the resulting
package set after all the overlays are applied.
set. You should use this set for the dependencies of all packages specified in your
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "… applied. set. You …"

doc/overlays.xml Outdated
corresponds to the result of the evaluation of the previous stages of
<para>The second argument (<varname>previous</varname>)
corresponds to the result of the evaluation of <literal>Nixpkgs</literal> with the
overlays applied prior to the application of the current overlay.
Nixpkgs. It does not contain any of the packages added by the current
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "… current overlay. Nixpkgs. It …"

rr = super.callPackage ./pkgs/rr {
stdenv = self.stdenv_32bit;
rr = previous.callPackage ./pkgs/rr {
stdenv = final.stdenv_32bit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it isn't really final though, is it? It can be overlayed on top of later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final is the composition of all overlays, including the future ones too.

However, the brevity and clarity of final in this rr example highlights that we should use e.g. final.callPackage, not previous.callPackage for functions, and use previous only when we explicitly want the previous definition (because the current definition will shadow it in the final set).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grahamc stdenv_32bit is the final, as this is the result which went through the fix-point.
rr is not final yet, it might be overriden, and would be in the previous set of the next overlay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orivej that makes sense to me. Updated PR to use final.callPackage unless @nbp disagrees and wants me to change it back.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, callPackage is a function, and it should come from previous, not final.

@disassembler disassembler force-pushed the overlay-self-super-rename branch 3 times, most recently from fbc1979 to b1b6b06 Compare October 30, 2017 21:46
doc/overlays.xml Outdated
};
rr = super.callPackage ./pkgs/rr {
stdenv = self.stdenv_32bit;
rr = final.callPackage ./pkgs/rr {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callPackage is a function, which it-self captures self to provide the packages to the package, and using it through self will go through the fix-point twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not make sense to me. For the interpreter the fix point is not a loop, and there is no such thing as the count of goes through the fix point. (Here is an accurate enough model of the internal states of a straightforward interpreter of the nix language that illustrates this: https://gist.github.com/orivej/5fddcf792dfa37a5bfa16d9a95fe70fa .) Using final is in no way less computationally efficient than using previous. When callPackage is not overridden in a future overlay, final.callPackage is exactly the same as previous.callPackage, but the choice of the former is more obvious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orivej Today there is not, but the reason the documentation is that way, is to make sure that we make the code written by user future-proof. Doing the opposite would become a problem for automatic grafting.

As you mentioned, there is no difference today, but doing it as currently mentioned in the documentation will prevent the addition of issues that would have to be fixed later.

Copy link
Contributor

@orivej orivej Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, callPackage is a function, and it should come from previous, not final.

Could you explain why functions should come from previous? I am fairly certain that in practice this is a stylistic choice until someone wants to override some functions (and final looks better), that we should use final if they do, and it should not concern us if the referenced value is a derivation or a function . The only concern is if we can just use the final value, or if we need the previous value to implement our override of it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nbp Could you detail the future plans? What is automatic grafting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the name of it I guess the automatic grafting is deep merging of attribute sets, but that does not seem to cause any issues with using functions from final.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orivej The automatic grafting described in #10851 , which is coming slowly, depends on the fact that we can peel off the fix-point and watch the number of hops through the fix-point. Using a function which captures self, from self, implies that we go twice through self, and miss this dependency.

@disassembler
Copy link
Member Author

@nbp ok, reverted. Look good now?

corresponds to the result of the evaluation of the previous stages of
<para>The second argument (<varname>previous</varname>)
corresponds to the the evaluation of <literal>Nixpkgs</literal> with the
overlays applied prior to the application of the current overlay.
Nixpkgs. It does not contain any of the packages added by the current
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: […] current overlay. Nixpkgs. It does […]

@Mic92
Copy link
Member

Mic92 commented Nov 25, 2017

any updates?

@dtzWill
Copy link
Member

dtzWill commented Mar 1, 2018

Beep boop, is this ready?

@disassembler
Copy link
Member Author

I'm going to close this. self: super everyone is comfortable with now and I think it would just confuse people if we changed the names at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants