when I try to run the test, I get an infinite recursion error:
nix-build ./test-quickstart.nix
error: infinite recursion encountered, at undefined position
(use '--show-trace' to show detailed location information)
--show-trace doesn’t really help.
Both
removing the test and just building the haskell package and
removing the haskell package and just generating the post-order script seem to work fine.
the moment I try to combine the two I get the infinite recursion.
I have no idea what it might be caused by.
Any help is appreciated.
For some reason I was of the impression that overlays are a way to redistribute reusable “patches” to nixpkgs and packageOverrides are better for project specific changes.
I now realise this is not really based on anything I’ve read. Is this “obsoletion” documented anywhere?
I don’t think this is documented properly, no. But packageOverrides is literally implemented as an overlay that throws away the self argument and only passes super to the defined function. And from what I’ve read overlays was intended to obsolete packageOverrides. I wish someone would update the manual where it talks about packageOverrides though.
I would really appreciate an explanation to this phenomenon as I can’t understand what are the semantics when the overlay list has 2 items “import” and “./nix-markdown-snippets.nix” and how does it cause the aforementioned infinite recursion problem.
The overlay array is an array of functions that take self: super:. By including import as the function directly, this is calling import self, and using that as part of the definition of self. import appears to call builtins.toPath on its argument, which in turn calls toString (and then interprets the results as an absolute path). toString can accept a set, if the set contains a __toString = self: … attribute.
So, as a result, if an entry in the overlays attribute is the function import, it tries to evaluate import self, where self is a set, and the import ends up forcing the __toString attribute, and in order to determine if there is in fact a __toString attribute it needs to evaluate the overlays, which ends up recursing right back to the import.
It didn’t occur to me to treat import as just a normal function that accepts self and super arguments, although that is precisely the would-be type for the args of the overlays array, makes sense now, thanks (again) for that!