[Nix-dev] variable scope / recursion

Mathijs Kwik mathijs at bluescreen303.nl
Fri Jul 6 11:53:28 CEST 2012


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));
      pkgsOrig = pkgsFun pkgs {};
      pkgs = pkgsFun pkgs overrides;
    in pkgs;

I'm familiar with tying-the-knot lazy trickery in haskell.
As pkgsOrig uses pkgs (the final end result including overrides), and
the overrider function gets passed pkgsOrig, I would expect the
following to work:

  packageOverrides = pkgs:
    { foo = "string";
      bar = pkgs.foo + " concatenation";
    };

However, it complains about foo missing.
What am I missing?

Thanks,
Mathijs


More information about the nix-dev mailing list