[Nix-dev] Anyone against giving the nixpkgs attrset a reference to itself?

Mathijs Kwik mathijs at bluescreen303.nl
Mon Jul 16 00:32:16 CEST 2012


Hi all,

I would like to add the final nixpkgs attrset (defaults + overrides)
to itself (named finalPkgs).
As this is a somewhat strange thing to do, I thought it would be best
to ask first :)

This is useful for the following usecase:

- I have a bunch of packages that are no use to others, but which I
use on multiple systems.
- I distribute these between my systems, and hook them into nixpkgs
using the nixpkgs.config mechanism to override/extend the package set.
- I would like to be able to define extra packages with the same ease
as in all-packages.nix, so using callPackage to pass in dependencies.
- For this, I want the total pkgs set to be available as 1 object,
while the "pkgs" argument that nixpkgs.config.packageOverrides
receives is just the original set, before overriding, which I can of
course (//) with my extras, but this is not the same thing as the
final set.

How I use this feature to modularize nixpkgs.config: [1]
The file that defines extra packages, which can now use callPackage to
fill in both dependencies from the original nixpkgs, as new/custom
dependencies, transparently: [2]

Please let me know if this is ok to do, or if I'm doing something stupid :)

Extra bonuspoints:
Currently, uncommenting the "with" statement on line 3 of [2] leads to
"infinite recursion detected".
Can anyone find out why? I was under the impression that "with" just
brought stuff into scope, so as long as I don't use anything that
would recurse to bottom, laziness should save me.
As everything works fine (just need to prefix pkgs.), I fail to see
how just using "with" here would lead to a loop.

Thanks,
Mathijs


[1] https://github.com/bluescreen303/nix-config/blob/master/bluepkgs/default.nix
[2] https://github.com/bluescreen303/nix-config/blob/master/bluepkgs/extra.nix


More information about the nix-dev mailing list