From dbe74935f2d6abf7aba9847926745df1e7d9a500 Mon Sep 17 00:00:00 2001 From: David Baynard Date: Wed, 26 Oct 2022 21:24:01 +0100 Subject: [PATCH] Avoid infinite recursion because of keras definition Works around https://github.com/nix-community/poetry2nix/issues/750 > infinite recursion encountered The issue, as pointed out in https://github.com/DavHau/mach-nix/issues/470#issuecomment-1185474576, is that nixpkgs defines ``` Keras = keras; ``` https://github.com/NixOS/nixpkgs/blob/fbb042bc87bc92fc5296b8b151e36970dd996c64/pkgs/top-level/python-aliases.nix poetry2nix must (somewhere) set `keras` to depend on `Keras` meaning infinite recursion. The fix is based on the code in https://github.com/nix-community/poetry2nix/issues/750#issuecomment-1290278330 --- default.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 1c35452..f133e46 100644 --- a/default.nix +++ b/default.nix @@ -14,12 +14,29 @@ let in lib.listToAttrs (map (name: { inherit name; value = f name; }) pnames); + withDefaults = + let + inherit (poetry2nix.defaultPoetryOverrides) overrideOverlay; + defaults = { + pre = final: prev: { + keras = null; + Keras = null; + keras_ = prev.keras; + }; + + post = final: prev: { + keras = prev.keras_; + }; + }; + + in + ((overrideOverlay defaults.pre).extend defaults.post).extend; in poetry2nix.mkPoetryApplication { projectDir = ./.; propagatedBuildInputs = [ diffusion-models ]; - overrides = poetry2nix.overrides.withDefaults (withSetuptools [ + overrides = withDefaults (withSetuptools [ "libclang" "pyparsing" "typing-extensions"