[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nix-dev
Subject:    Re: [Nix-dev] all-packages.nix and the unoverridable self.
From:       Daniel Peebles <pumpkingod () gmail ! com>
Date:       2016-05-08 16:12:52
Message-ID: CANaM3xDbBdQ9YXNehfs0ny9_Dprb4LB2TYdLPAs45FzQk5OoVQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Did you figure this out? I'm curious whether something got messed up in the
recent changes.

On Mon, May 2, 2016 at 2:23 AM, <roconnor@theorem.ca> wrote:

> Something seems wrong / bizzare with the recursion in all-packages.nix
>
> I've been trying to override linux_4_4 in my configuration.nix with the
> following:
>
>      nixpkgs.config.packageOverrides = super:
>       { linux_4_4 = super.linux_4_4.override { extraConfig =
> "CHROME_PLATFORMS y";
>                                                kernelPatches = [ { name =
> "f10_sysrq"; patch = ./f10_sysrq.patch; } ]; };
>       };
>
> but this no longer works.  I've spent a few hours studying the issue.
> If I do the following chain of overrides upto the linuxPackages
> attribute
>
>      nixpkgs.config.packageOverrides = super: rec
>       { linux_4_4 = super.linux_4_4.override { extraConfig =
> "CHROME_PLATFORMS y";
>                                                kernelPatches = [ { name =
> "f10_sysrq"; patch = ./f10_sysrq.patch; } ]; };
>         linuxPackages_4_4 = super.recurseIntoAttrs (super.linuxPackagesFor
>         linux_4_4 linuxPackages_4_4);
>         linuxPackages = linuxPackages_4_4;
>         linux = linuxPackages.kernel;
>       };
>
> then it does work.
>
> I couldn't for the life of me understand why copying what is essentially
> the exact definitions of linuxPackages_4_4 and linuxPackages into my
> packageOverrides caused it to work.  The whole point of the
> packageOverride mechanism is to invoke late-binding so that I don't have
> to override long chains.
>
> I traced the issue to the following strange set of definitions:
>
> all-packages.nix begins with something like this
>
> { ... }:
> self: pkgs:
>
> with pkgs;
>
> { ... }
>
> It is a function of three arguments, (1) a set of parameters, (2) a
> binding for self, (3) a binding for pkgs, and the with pkgs; bring all
> the definitions from pkgs into scope.
>
> This is called from top-level/default.nix with the following
> expression:
>
>         allPackages = self: super:
>           let res = import ./all-packages.nix allPackagesArgs res self;
>           in res;
>
> So allPackageArgs contains the parameters, self gets bound to res, and
> pkgs get bound to self.
>
> The upshot of this is that within all-packages.nix self (which is bound
> to res) is the result of only evaluating all-packanges *with no
> overrides* while pkgs (which is bound to self) ends up late-bound and is
> the set of packges *with all overrides*
>
> So when linux and linuxPackages get bound using self in all-packages:
>
>     # The current default kernel / kernel modules.
>     linuxPackages = self.linuxPackages_4_4;
>     linux = self.linuxPackages.kernel;
>
> The use of self here (and throughout the linuxPackage definitions) means
> that we are making reference to the *unoverridden package set*.  This is
> why my packageOverrides of linux_4_4 did nothing, because the references
> to linux_4_4 inn all-packages.nix are prefixed with "self." which means
> it always gets the unoverriden packages.
>
> Is this really the desired behaviour?  I think that all-packages.nix is
> full of many questionable uses of the "self." prefix.  I suspect that
> people don't really understand that "self." means "give me the
> unoverriden version of packages".  I think renaming "self" in
> all-packages.nix to "unoverridenPackages" would be a better name.
>
> --
> Russell O'Connor                                      <http://r6.ca/>
> ``All talk about `theft,''' the general counsel of the American Graphophone
> Company wrote, ``is the merest claptrap, for there exists no property in
> ideas musical, literary or artistic, except as defined by statute.''
> _______________________________________________
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>

[Attachment #5 (text/html)]

<div dir="ltr">Did you figure this out? I&#39;m curious whether something got messed \
up in the recent changes.</div><div class="gmail_extra"><br><div \
class="gmail_quote">On Mon, May 2, 2016 at 2:23 AM,  <span dir="ltr">&lt;<a \
href="mailto:roconnor@theorem.ca" target="_blank">roconnor@theorem.ca</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">Something seems wrong / bizzare with the recursion in \
all-packages.nix<br> <br>
I&#39;ve been trying to override linux_4_4 in my configuration.nix with the<br>
following:<br>
<br>
        nixpkgs.config.packageOverrides = super:<br>
         { linux_4_4 = super.linux_4_4.override { extraConfig = \
                &quot;CHROME_PLATFORMS y&quot;;<br>
                                                                       kernelPatches \
= [ { name = &quot;f10_sysrq&quot;; patch = ./f10_sysrq.patch; } ]; };<br>  };<br>
<br>
but this no longer works.   I&#39;ve spent a few hours studying the issue.<br>
If I do the following chain of overrides upto the linuxPackages<br>
attribute<br>
<br>
        nixpkgs.config.packageOverrides = super: rec<br>
         { linux_4_4 = super.linux_4_4.override { extraConfig = \
                &quot;CHROME_PLATFORMS y&quot;;<br>
                                                                       kernelPatches \
                = [ { name = &quot;f10_sysrq&quot;; patch = ./f10_sysrq.patch; } ]; \
                };<br>
            linuxPackages_4_4 = super.recurseIntoAttrs (super.linuxPackagesFor<br>
            linux_4_4 linuxPackages_4_4);<br>
            linuxPackages = linuxPackages_4_4;<br>
            linux = linuxPackages.kernel;<br>
         };<br>
<br>
then it does work.<br>
<br>
I couldn&#39;t for the life of me understand why copying what is essentially<br>
the exact definitions of linuxPackages_4_4 and linuxPackages into my<br>
packageOverrides caused it to work.   The whole point of the<br>
packageOverride mechanism is to invoke late-binding so that I don&#39;t have<br>
to override long chains.<br>
<br>
I traced the issue to the following strange set of definitions:<br>
<br>
all-packages.nix begins with something like this<br>
<br>
{ ... }:<br>
self: pkgs:<br>
<br>
with pkgs;<br>
<br>
{ ... }<br>
<br>
It is a function of three arguments, (1) a set of parameters, (2) a<br>
binding for self, (3) a binding for pkgs, and the with pkgs; bring all<br>
the definitions from pkgs into scope.<br>
<br>
This is called from top-level/default.nix with the following<br>
expression:<br>
<br>
            allPackages = self: super:<br>
               let res = import ./all-packages.nix allPackagesArgs res self;<br>
               in res;<br>
<br>
So allPackageArgs contains the parameters, self gets bound to res, and<br>
pkgs get bound to self.<br>
<br>
The upshot of this is that within all-packages.nix self (which is bound<br>
to res) is the result of only evaluating all-packanges *with no<br>
overrides* while pkgs (which is bound to self) ends up late-bound and is<br>
the set of packges *with all overrides*<br>
<br>
So when linux and linuxPackages get bound using self in all-packages:<br>
<br>
      # The current default kernel / kernel modules.<br>
      linuxPackages = self.linuxPackages_4_4;<br>
      linux = self.linuxPackages.kernel;<br>
<br>
The use of self here (and throughout the linuxPackage definitions) means<br>
that we are making reference to the *unoverridden package set*.   This is<br>
why my packageOverrides of linux_4_4 did nothing, because the references<br>
to linux_4_4 inn all-packages.nix are prefixed with &quot;self.&quot; which means<br>
it always gets the unoverriden packages.<br>
<br>
Is this really the desired behaviour?   I think that all-packages.nix is<br>
full of many questionable uses of the &quot;self.&quot; prefix.   I suspect that<br>
people don&#39;t really understand that &quot;self.&quot; means &quot;give me the<br>
unoverriden version of packages&quot;.   I think renaming &quot;self&quot; in<br>
all-packages.nix to &quot;unoverridenPackages&quot; would be a better name.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Russell O&#39;Connor                                                         &lt;<a \
href="http://r6.ca/" rel="noreferrer" target="_blank">http://r6.ca/</a>&gt;<br> ``All \
talk about `theft,&#39;&#39;&#39; the general counsel of the American Graphophone<br> \
Company wrote, ``is the merest claptrap, for there exists no property in<br> ideas \
musical, literary or artistic, except as defined by statute.&#39;&#39;<br> \
_______________________________________________<br> nix-dev mailing list<br>
<a href="mailto:nix-dev@lists.science.uu.nl">nix-dev@lists.science.uu.nl</a><br>
<a href="http://lists.science.uu.nl/mailman/listinfo/nix-dev" rel="noreferrer" \
target="_blank">http://lists.science.uu.nl/mailman/listinfo/nix-dev</a><br> \
</font></span></blockquote></div><br></div>



_______________________________________________
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic