Closed asymmetric closed 1 year ago
Here's a minimal repro case:
{
description = "foo";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
poetry2nix = {
url = "github:nix-community/poetry2nix?ref=33db1f30d0a4bffdba969f731dc71e67e69038b4";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, poetry2nix }:
let
name = "foobar";
system = "x86_64-linux";
pythonVersion = pkgs.python39;
pkgs = import nixpkgs {
inherit system;
overlays = [ poetry2nix.overlay ];
};
poetryAttrs = {
projectDir = ./.;
python = pythonVersion;
overrides = [
pkgs.poetry2nix.defaultPoetryOverrides
];
};
in
{
packages.${system} = {
default = pkgs.poetry2nix.mkPoetryApplication poetryAttrs;
};
};
}
Also need the contents of your pyproject.toml and lock file.
@asymmetric There were some follow up PRs recently merged that may fix your issue here. Can you check against master
?
I get something similar with keras @ 2.4.2
on master
:
I think this might be an interaction between the package name normalization added in #736 and python-aliases.nix
in nixpkgs.
The package name for babel @ 2.10.3 is Babel
and for keras @ 2.4.2 it is Keras
(note the capital letter).
Both Keras
and Babel
are mapped to self.keras
and self.babel
in nixpkgs: here and here.
Then in poetry2nix we set keras = self.Keras
and babel = self.Babel
: here called from here.
This results in a cycle because now keras = self.Keras = self.keras
and babel = self.Babel = self.babel
.
Is there any intermediate way to fix it?
@thiagorp pinning your flake input to 1.31.0
@cpcloud Unfortunately, the problem is still there as of d62ba59f1e28c382665c57203a4b9ad11fd7f449.
Thank you @asymmetric . I assume I need a specific version of nixpkgs too, in order to solve the setup tools issue? Do you happen to know what that version is?
For those who need just to upgrade one package the Poetry 1.1.15 still generates old style packages names and poetry2nix@1.31.0 will successfully parse them , so you don't have to go and update every possible dependency.
@thiagorp I have only tried this with 22.05, not sure what newer versions would work.
I'm seeing the same issue. I'm using nixos-unstable channel and latest master of poetry2nix. I've created the lock with 1.2.2 and 1.1.15 poetry, but still i'm getting the same error.
@asymmetric I've got the same problem with infinite recursion (nix-community/poetry2nix@3b9040d and nixos/nixpkgs@80d4d591522bf3d31e0fe4703bbc30388f7fc8f2 including trying 22.05 and latest from today) when babel
is in the poetry.lock
, in my case I want to depend on jupyterlab
.
What works for now is creating a poetry2nix
override like:
{ poetry2nix
, pkgs
, ...
}:
let
preDefaults = self: super: {
# XXX: Unset babel/Babel and rename to babel_ to avoid infinit recursion
# then in postDefaults we set `babel_` back to `babel`
babel = null;
Babel = null;
babel_ = super.babel;
};
postDefaults = self: super: {
# XXX: Avoid infinit recursion
babel = super.babel_;
};
in
(poetry2nix.defaultPoetryOverrides.overrideOverlay preDefaults).extend postDefaults
I encountered this problem yesterday evening when trying to upgrade poetry2nix
, so haven't had time to figure out all the details except that this solution works for me right now.
I also have to use my fork (icetan/poetry2nix@06a79b95b9) with the feature to filter out things from the lock file using filterLock
, otherwise nix will stall and eventually run out of memory without even crashing with infinite recursion
.
Hope this helps and that there is a more long term solution soon.
For the record, a similar problem has been reported also against mach-nix: https://github.com/DavHau/mach-nix/issues/470
Thanks @icetan and @lelit
What works for now is creating a
poetry2nix
override like:{ poetry2nix , pkgs , ... }: let preDefaults = self: super: { # XXX: Unset babel/Babel and rename to babel_ to avoid infinit recursion # then in postDefaults we set `babel_` back to `babel` babel = null; Babel = null; babel_ = super.babel; }; postDefaults = self: super: { # XXX: Avoid infinit recursion babel = super.babel_; }; in (poetry2nix.defaultPoetryOverrides.overrideOverlay preDefaults).extend postDefaults
This worked for me, too, but with keras
/Keras
(once I fixed the silly mistake in my first implementation).
Much like how Babel = babel
is set at https://github.com/NixOS/nixpkgs/blob/fbb042bc87bc92fc5296b8b151e36970dd996c64/pkgs/top-level/python-aliases.nix#L35-L41 there is a Keras = keras
line (https://github.com/NixOS/nixpkgs/blob/fbb042bc87bc92fc5296b8b151e36970dd996c64/pkgs/top-level/python-aliases.nix#L103)
The comment in https://github.com/DavHau/mach-nix/issues/470#issuecomment-1185474576 seems to be close to what is going on, no, given the fix?
I had to update various packages to add setuptools
as dependencies, too. When I fixed that (and set dontUseWheelUnpack = true
…) everything worked.
Describe the issue
Since #736 got merged (I confirmed by pinning the commit in the flake input), I'm getting this error:
Additional context
trace
``` warning: Git tree '/home/asymmetric/code/foo/bar' is dirty error: infinite recursion encountered at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/attrsets.nix:312:41: 311| */ 312| nameValuePair = name: value: { inherit name value; }; | ^ 313| … while evaluating the attribute 'babel' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/attrsets.nix:312:41: 311| */ 312| nameValuePair = name: value: { inherit name value; }; | ^ 313| … while evaluating 'addBuildSystem' at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:9:5: 8| addBuildSystem = 9| { self | ^ 10| , drv … from call site at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:81:21: 80| (attr: systems: builtins.foldl' 81| (drv: attr: addBuildSystem { | ^ 82| inherit drv self attr; … while evaluating anonymous lambda at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:81:15: 80| (attr: systems: builtins.foldl' 81| (drv: attr: addBuildSystem { | ^ 82| inherit drv self attr; … from call site at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:80:23: 79| lib.mapAttrs 80| (attr: systems: builtins.foldl' | ^ 81| (drv: attr: addBuildSystem { … while evaluating anonymous lambda at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:80:14: 79| lib.mapAttrs 80| (attr: systems: builtins.foldl' | ^ 81| (drv: attr: addBuildSystem { … from call site … while evaluating 'checkInPkgs' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:22:20: 21| # python-packages.nix. 22| checkInPkgs = n: alias: if builtins.hasAttr n super | ^ 23| then throw "Alias ${n} is still in python-packages.nix" … from call site at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:29:32: 28| (removeRecurseForDerivations 29| (checkInPkgs n alias))) | ^ 30| aliases; … while evaluating 'removeRecurseForDerivations' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:8:33: 7| # set to appear while listing all the packages available. 8| removeRecurseForDerivations = alias: with lib; | ^ 9| if alias.recurseForDerivations or false then … from call site at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:28:31: 27| lib.mapAttrs (n: alias: removeDistribute 28| (removeRecurseForDerivations | ^ 29| (checkInPkgs n alias))) … while evaluating 'isDerivation' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/attrsets.nix:427:18: 426| */ 427| isDerivation = x: x.type or null == "derivation"; | ^ 428| … from call site at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:16:8: 15| removeDistribute = alias: with lib; 16| if isDerivation alias then | ^ 17| dontDistribute alias … while evaluating 'removeDistribute' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:15:22: 14| # sets from building on Hydra. 15| removeDistribute = alias: with lib; | ^ 16| if isDerivation alias then … from call site at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:27:29: 26| mapAliases = aliases: 27| lib.mapAttrs (n: alias: removeDistribute | ^ 28| (removeRecurseForDerivations … while evaluating anonymous lambda at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/top-level/python-aliases.nix:27:22: 26| mapAliases = aliases: 27| lib.mapAttrs (n: alias: removeDistribute | ^ 28| (removeRecurseForDerivations … from call site … while evaluating 'isDerivation' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/attrsets.nix:427:18: 426| */ 427| isDerivation = x: x.type or null == "derivation"; | ^ 428| … from call site at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/default.nix:248:20: 247| (name: value: ( 248| if lib.isDerivation value && lib.hasAttr "overridePythonAttrs" value | ^ 249| then value.overridePythonAttrs (_: { doCheck = false; }) … while evaluating anonymous lambda at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/default.nix:247:22: 246| (self: super: lib.mapAttrs 247| (name: value: ( | ^ 248| if lib.isDerivation value && lib.hasAttr "overridePythonAttrs" value … from call site … while evaluating the attribute 'babel' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/attrsets.nix:312:41: 311| */ 312| nameValuePair = name: value: { inherit name value; }; | ^ 313| … while evaluating 'addBuildSystem' at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:9:5: 8| addBuildSystem = 9| { self | ^ 10| , drv … from call site at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:81:21: 80| (attr: systems: builtins.foldl' 81| (drv: attr: addBuildSystem { | ^ 82| inherit drv self attr; … while evaluating anonymous lambda at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:81:15: 80| (attr: systems: builtins.foldl' 81| (drv: attr: addBuildSystem { | ^ 82| inherit drv self attr; … from call site at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:80:23: 79| lib.mapAttrs 80| (attr: systems: builtins.foldl' | ^ 81| (drv: attr: addBuildSystem { … while evaluating anonymous lambda at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/overrides/default.nix:80:14: 79| lib.mapAttrs 80| (attr: systems: builtins.foldl' | ^ 81| (drv: attr: addBuildSystem { … from call site … while evaluating anonymous lambda at /nix/store/4yy33bawrm7cmlgmjnjrfn8qvyh0shz8-source/default.nix:43:15: 42| ( 43| dep: | ^ 44| let … from call site … while evaluating 'isDerivation' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/attrsets.nix:427:18: 426| */ 427| isDerivation = x: x.type or null == "derivation"; | ^ 428| … from call site at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/stdenv/generic/make-derivation.nix:201:8: 200| checkDependencyList' = positions: name: deps: lib.flip lib.imap1 deps (index: dep: 201| if lib.isDerivation dep || isNull dep || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep | ^ 202| else if lib.isList dep then checkDependencyList' ([index] ++ positions) name dep … while evaluating anonymous lambda at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/stdenv/generic/make-derivation.nix:200:81: 199| checkDependencyList = checkDependencyList' []; 200| checkDependencyList' = positions: name: deps: lib.flip lib.imap1 deps (index: dep: | ^ 201| if lib.isDerivation dep || isNull dep || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep … from call site at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/lists.nix:117:32: 116| */ 117| imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list); | ^ 118| … while evaluating anonymous lambda at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/lists.nix:117:29: 116| */ 117| imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list); | ^ 118| … from call site … while evaluating anonymous lambda at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/stdenv/generic/make-derivation.nix:243:13: 242| (map (drv: drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHostPropagated" depsHostHostPropagated)) 243| (map (drv: drv.crossDrv or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) | ^ 244| ] … from call site … while evaluating 'getOutput' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/attrsets.nix:598:23: 597| */ 598| getOutput = output: pkg: | ^ 599| if ! pkg ? outputSpecified || ! pkg.outputSpecified … from call site … while evaluating the attribute 'propagatedBuildInputs' of the derivation 'python3.9-market-maker-stats-1.0.0' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/pkgs/stdenv/generic/make-derivation.nix:278:7: 277| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) { 278| name = | ^ 279| let … while evaluating the attribute 'drvPath' at /nix/store/8gwzhqn67qm8r5biakx2hxsqiy3jfqmz-source/lib/customisation.nix:210:7: 209| in commonAttrs // { 210| drvPath = assert condition; drv.drvPath; | ^ 211| outPath = assert condition; drv.outPath; ```