Function 'anonymous lambda' called with unexpected argument

Hi,

I am moving the following nix-shell (attached below) to a fixed nix pkgs version.

let
  pkgs = import (fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/4ecab3273592f27479a583fb6d975d4aba3486fe.tar.gz";
  }) {};

  poetry2nixSrc = pkgs.fetchFromGitHub {
    owner = "nix-community";
    repo = "poetry2nix";
    rev = "e23218d1599e3369dfc878757e58974017e0ecc8";
    sha256 = "sha256-p6niqag7b4XEHvzWgG0X/xjoW/ZXbAxW8ggd8yReT3Y=";
  };

  poetry2nix = import poetry2nixSrc { };
  # Create a Python environment using poetry2nix
  finalEnv = poetry2nix.mkPoetryEnv {
    python = pkgs.python310;
    projectDir = ../../.;
    poetrylock = ../../poetry.lock; # Path to your poetry.lock file
    overrides = poetry2nix.overrides.withDefaults (self: super: {
      attrs = super.attrs.overridePythonAttrs (old: {
        buildInputs = old.buildInputs or [ ]
          ++ [ self.wheel self.hatch-vcs self.hatch-fancy-pypi-readme ];
      });
      protobuf3 = super.protobuf3.overridePythonAttrs (old: {
        buildInputs = old.buildInputs or [ ]
          ++ [ super.setuptools super.wheel ];
      });
      werkzeug = super.werkzeug.overridePythonAttrs
        (old: { buildInputs = old.buildInputs or [ ] ++ [ self.flit-core ]; });

      flask = super.flask.overridePythonAttrs
        (old: { buildInputs = old.buildInputs or [ ] ++ [ self.flit-core ]; });

      execnet = super.execnet.overridePythonAttrs (old: {
        buildInputs = old.buildInputs or [ ] ++ [
          self.hatchling
          self.wheel
          self.hatch-vcs
          self.hatch-fancy-pypi-readme
        ];
      });

      simple-websocket = super.simple-websocket.overridePythonAttrs (old: {
        buildInputs = old.buildInputs or [ ] ++ [ self.setuptools self.wheel ];
      });

      pyln-grpc-proto = super.pyln-grpc-proto.overridePythonAttrs
        (old: { buildInputs = old.buildInputs or [ ] ++ [ self.poetry ]; });

      pytest-custom-exit-code =
        super.pytest-custom-exit-code.overridePythonAttrs (old: {
          buildInputs = old.buildInputs or [ ]
            ++ [ self.setuptools self.wheel ];
        });

      pytest-test-groups = super.pytest-test-groups.overridePythonAttrs (old: {
        buildInputs = old.buildInputs or [ ] ++ [ self.setuptools self.wheel ];
      });

      cryptography = super.cryptography.overrideAttrs (oldAttrs: {
        src = pkgs.fetchurl {
          url =
            "https://pypi.io/packages/source/c/cryptography/cryptography-41.0.4.tar.gz";
          sha256 = "oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=";
        };
      });

      rpds-py = super.rpds-py.overrideAttrs (old: {
        src = pkgs.fetchurl {
          url =
            "https://files.pythonhosted.org/packages/9e/a8/4a4e5ef90c4c4f27683ce2bb74b9521b5b1d06ac134cd650333fdca0f52c/rpds_py-0.10.4.tar.gz";
          sha256 = "GNX/f70wWh1WQnPp6yLeg6482c1jKf3cjxL2QopxGmo=";
        };
        buildInputs = old.buildInputs ++ [ pkgs.maturin self.gevent self.mypy ];
      });
    });
  };
in with pkgs;
stdenv.mkDerivation {
  name = "git-dev-nix-env";

  buildInputs = [
    gcc
    sqlite
    autoconf
    git
    clang
    libtool
    sqlite
    autoconf
    autogen
    automake
    gnumake
    pkg-config
    gmp
    zlib
    gettext
    libsodium

    # Python dep
    poetry
    python310
    python310Packages.pip
    python310Packages.pytest
    maturin
    finalEnv # Add the poetry environment here

    # optional dev libraries
    ccache

    # debugs libraries
    valgrind

    # Indirected dependencies for running tests
    bitcoind
  ];
}

But when I run nix-shell I get the following error

➜  lightning git:(macros/nix-shell) ✗ nix-shell contrib/nix/default.nix
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'git-dev-nix-env'
         whose name attribute is located at /nix/store/vhq11h949l5zycaw07acphv53ifq4p2c-source/pkgs/stdenv/generic/make-derivation.nix:303:7

       … while evaluating attribute 'buildInputs' of derivation 'git-dev-nix-env'

         at /nix/store/vhq11h949l5zycaw07acphv53ifq4p2c-source/pkgs/stdenv/generic/make-derivation.nix:350:7:

          349|       depsHostHost                = lib.elemAt (lib.elemAt dependencies 1) 0;
          350|       buildInputs                 = lib.elemAt (lib.elemAt dependencies 1) 1;
             |       ^
          351|       depsTargetTarget            = lib.elemAt (lib.elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: function 'anonymous lambda' called with unexpected argument 'setuptools'

       at /nix/store/267shz758zsrgjdvjxir8bdsi3a07diy-nixpkgs/nixpkgs/pkgs/development/python-modules/wheel/default.nix:1:1:

            1| { lib
             | ^
            2| , buildPythonPackage

What I am doing wrong? how I can import the pkgs in the correct way from a tarball?

Your code is ok but the nixpkgs rev 4ecab32 is the initial release of nixos 23.05 from 2023.05
Use the latest commit from https://status.nixos.org/ or archive/nixos-23.05 if rev pinning isn’t necessary

The other issue is that poetry2nix master is supposed to be used with nixos-unstable because the overrides target nixos-unstable https://github.com/nix-community/poetry2nix/blob/fe0dcb4c9b44162a385f1170895fe6a392ed71b5/overrides/default.nix#L2860-L2868

but poetry2nix seems to be broken with new nixpkgs right now so see Segmentation fault · Issue #1291 · nix-community/poetry2nix · GitHub, the latest good nixpkgs commit is 3476a10478587dec90acb14ec6bde0966c545cc0

3 Likes

but poetry2nix seems to be broken with new nixpkgs right now so see Segmentation fault · Issue #1291 · nix-community/poetry2nix · GitHub , the latest good nixpkgs commit is 3476a10478587dec90acb14ec6bde0966c545cc0

I do not think this commit works

This is the error that I am getting that was the reason that I was cloning the unstable one


installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz
checking for references to /build/ in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz...
patching script interpreter paths in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz
error: hash mismatch in fixed-output derivation '/nix/store/4jckj2d2318dxd57qyr9a8dj27082rgk-cryptography-41.0.4-vendor.tar.gz.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=
error: building '/nix/store/4jckj2d2318dxd57qyr9a8dj27082rgk-cryptography-41.0.4-vendor.tar.gz.drv' failed
building '/nix/store/02v72aysdfkw7vj8gnplxb1l2n3d2khw-python3.10-brotlicffi-1.0.9.2.drv'...
error: 1 dependencies of derivation '/nix/store/hvy1hzvwi7gflnqrfpkjb5s7hlfnkv0f-python3.10-cryptography-41.0.4.drv' failed to build
error: building '/nix/store/hvy1hzvwi7gflnqrfpkjb5s7hlfnkv0f-python3.10-cryptography-41.0.4.drv' failed
error: 1 dependencies of derivation '/nix/store/iipd640541xrfl8jxvbbgy6dfnzpmcpx-python3-3.10.12-env.drv' failed to build
error: building '/nix/store/iipd640541xrfl8jxvbbgy6dfnzpmcpx-python3-3.10.12-env.drv' failed

At this point, I do not think there is a real solution only to wait that the memory issue will be fixed on master

You’ll have to update the cargoDeps hash when overriding the src

cargoDeps = oldAttrs.cargoDeps.overrideAttrs (_: {
  inherit src;
  # empty and build, then insert the hash nix gives you
  outputHash = "";
});

may also have to pass a updated sourceRoot

1 Like

I am not really sure if I am dump or this will not work


installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz
checking for references to /build/ in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz...
patching script interpreter paths in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz
error: hash mismatch in fixed-output derivation '/nix/store/4jckj2d2318dxd57qyr9a8dj27082rgk-cryptography-41.0.4-vendor.tar.gz.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=
error: building '/nix/store/4jckj2d2318dxd57qyr9a8dj27082rgk-cryptography-41.0.4-vendor.tar.gz.drv' failed
building '/nix/store/02v72aysdfkw7vj8gnplxb1l2n3d2khw-python3.10-brotlicffi-1.0.9.2.drv'...
error: 1 dependencies of derivation '/nix/store/hvy1hzvwi7gflnqrfpkjb5s7hlfnkv0f-python3.10-cryptography-41.0.4.drv' failed to build
error: building '/nix/store/hvy1hzvwi7gflnqrfpkjb5s7hlfnkv0f-python3.10-cryptography-41.0.4.drv' failed
error: 1 dependencies of derivation '/nix/store/iipd640541xrfl8jxvbbgy6dfnzpmcpx-python3-3.10.12-env.drv' failed to build
error: building '/nix/store/iipd640541xrfl8jxvbbgy6dfnzpmcpx-python3-3.10.12-env.drv' failed

with

   57       cryptography = super.cryptography.overrideAttrs (oldAttrs: {
   58         src = pkgs.fetchurl {
   59           url =
   60             "https://pypi.io/packages/source/c/cryptography/cryptography-41.0.4.tar.gz";
   61           sha256 = "oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=";
+  62         };
+  63         cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
+  64           src = oldAttrs.src; # Fix is here
+  65           hash = "sha256-oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=";
   66         };
   67       });

The sha256 to the pypi fetchurl is wrong

here’s a tester I used which works

let
  pkgs = import ./. { };
in
pkgs.python3Packages.cryptography.overridePythonAttrs (previousAttrs: rec {
  version = "41.0.4";
  src = pkgs.fetchurl {
    url =
      "https://pypi.io/packages/source/c/cryptography/cryptography-${version}.tar.gz";
    sha256 = "sha256-f+vDCUEl/BJqf2+x9CDQ2mOfPzLLFcj/DcOZfEVJ9Ro=";
  };

  cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
    inherit src;
    sourceRoot = "${previousAttrs.pname}-${version}/src/rust";
    name = "${previousAttrs.pname}-${version}";
    hash = "sha256-oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=";
  };

  # cryptography-vectors is in a let so it's not easy to override
  # AssertionError: assert '41.0.4' == '41.0.3'
  doCheck = false;
})

The sha256 to the pypi fetchurl is wrong

Thanks, but with your example, there is the same error


-      cryptography = super.cryptography.overrideAttrs (oldAttrs: {
+      cryptography = super.cryptography.overrideAttrs (oldAttrs: rec {
+        version = "41.0.4";
         src = pkgs.fetchurl {
           url =
-            "https://pypi.io/packages/source/c/cryptography/cryptography-41.0.4.tar.gz";
-          sha256 = "oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=";
+            "https://pypi.io/packages/source/c/cryptography/cryptography-${version}.tar.gz";
+          sha256 = "sha256-f+vDCUEl/BJqf2+x9CDQ2mOfPzLLFcj/DcOZfEVJ9Ro=";
         };
+
+        cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
+          inherit src;
+          sourceRoot = "${oldAttrs.pname}-${version}/src/rust";
+          name = "${oldAttrs.pname}-${version}";
+          hash = "sha256-oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=";
+        };
+
+        # cryptography-vectors is in a let so it's not easy to override
+        # AssertionError: assert '41.0.4' == '41.0.3'
+        doCheck = false;
       });

The error is the same as before

installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz
checking for references to /build/ in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz...
patching script interpreter paths in /nix/store/lr06kyfn2nzxq718jf5c2mw00kz5ir5f-cryptography-41.0.4-vendor.tar.gz
error: hash mismatch in fixed-output derivation '/nix/store/4jckj2d2318dxd57qyr9a8dj27082rgk-cryptography-41.0.4-vendor.tar.gz.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=
error: building '/nix/store/4jckj2d2318dxd57qyr9a8dj27082rgk-cryptography-41.0.4-vendor.tar.gz.drv' failed
building '/nix/store/8pbaw30sj99pcp6bg4kc1sp21g9nwxgp-python3.10-certifi-2023.05.07.drv'...
error: 1 dependencies of derivation '/nix/store/hvy1hzvwi7gflnqrfpkjb5s7hlfnkv0f-python3.10-cryptography-41.0.4.drv' failed to build
error: building '/nix/store/hvy1hzvwi7gflnqrfpkjb5s7hlfnkv0f-python3.10-cryptography-41.0.4.drv' failed
error: 1 dependencies of derivation '/nix/store/iipd640541xrfl8jxvbbgy6dfnzpmcpx-python3-3.10.12-env.drv' failed to build
error: building '/nix/store/iipd640541xrfl8jxvbbgy6dfnzpmcpx-python3-3.10.12-env.drv' failed

I do not understand what is going on