From 37ab5b43963f51f939b9c031a0dd824d82b41259 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 11 Jan 2022 09:07:58 +0100 Subject: [PATCH] mkDerivation: Add error hint for infinite recursion --- pkgs/stdenv/generic/make-derivation.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index afb6eed632a..3e3a7aa790d 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -19,7 +19,14 @@ let # Based off lib.makeExtensible, with modifications: makeDerivationExtensible = mkDerivationSimple: rattrs: let + # NOTE: The following is a hint that will be printed by the Nix cli when + # encountering an infinite recursion. It must not be formatted into + # separate lines, because Nix would only show the last line of the comment. + + # An infinite recursion here can be caused by having the attribute names of expression `e` in `.overrideAttrs(finalAttrs: previousAttrs: e)` depend on `finalAttrs`. Only the attribute values of `e` can depend on `finalAttrs`. args = rattrs (args // { inherit public; }); + # ^^^^ + public = mkDerivationSimple (f0: