[Nix-dev] variable scope / recursion

2012-07-06 Thread Mathijs Kwik
Hi all, I was reading this interesting piece of all-packages.nix (comments/whitespace removed): applyGlobalOverrides = overrider: let overrides = overrider pkgsOrig // (lib.optionalAttrs (pkgsOrig.stdenv ? overrides crossSystem == null) (pkgsOrig.stdenv.overrides pkgsOrig));

Re: [Nix-dev] variable scope / recursion

2012-07-06 Thread Kirill Elagin
rec is the answer (this is something like let/letrec in Lisp, if you know what I mean ;) ). -- Кирилл Елагин 2012/7/6 Mathijs Kwik math...@bluescreen303.nl Hi all, I was reading this interesting piece of all-packages.nix (comments/whitespace removed): applyGlobalOverrides = overrider:

Re: [Nix-dev] variable scope / recursion

2012-07-06 Thread Mathijs Kwik
On Fri, Jul 6, 2012 at 1:43 PM, Kirill Elagin kirela...@gmail.com wrote: Yeah, now I get your problem. It think, it's clear from the source of `applyGlobalOverrides` and from comments, that your `packageOverrides` is called with _original, non-overriden_ pkgs. This way you can to refer to

Re: [Nix-dev] variable scope / recursion

2012-07-06 Thread Marc Weber
Excerpts from Mathijs Kwik's message of Fri Jul 06 11:53:28 +0200 2012: packageOverrides = pkgs: { foo = string; bar = pkgs.foo + concatenation; }; solution a) use rec: (rec { foo = ... bar = foo ; }) solution b,c ) use let recursion or fix function (which in turn

Re: [Nix-dev] variable scope / recursion

2012-07-06 Thread Shea Levy
Hi Mathijs, I've not fully read the thread, but just so you know overrides are done with a special attribute called __overrides, which has a more confusing semantics than simply a rec. See https://github.com/NixOS/nix/blob/master/src/libexpr/eval.cc#L525 for some documentation, and the

Re: [Nix-dev] variable scope / recursion

2012-07-06 Thread Mathijs Kwik
On Fri, Jul 6, 2012 at 2:28 PM, Kirill Elagin kirela...@gmail.com wrote: 2012/7/6 Mathijs Kwik math...@bluescreen303.nl Yeah I saw those comments too, but I can't see how that would work. Because the original (pkgsOrig) set is built by passing pkgs (the final set) to pkgsFun. In other words,