Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poetry2nix: mismatch cryptography sha256 but unable to modify #1337

Closed
vincenzopalazzo opened this issue Oct 7, 2023 · 5 comments
Closed

Comments

@vincenzopalazzo
Copy link

Describe the issue

I have the derivation reported at the end of this post but when I am building it with nix-shell I get the following trace message “trace: warning: Unknown cryptography version: ‘41.0.4’. Please update getCargoHash.”

and then the run fails with the following error

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/9dflz91pqq7h80fkgbya62q3109vspfh-cryptography-41.0.4-vendor.tar.gz.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-oXR8yBUgiA9BOfkZKBJneKWlpwHB71t/74b/5WpiKmw=
error: building '/nix/store/9dflz91pqq7h80fkgbya62q3109vspfh-cryptography-41.0.4-vendor.tar.gz.drv' failed
building '/nix/store/vjmlv1fhlhhrlbjsmcww2283d7xf1d1f-importlib_resources-6.1.0.tar.gz.drv'...
error: 1 dependencies of derivation '/nix/store/npn8q9bml5mwgdwgznhy9axxw0nxvbxp-python3.10-cryptography-41.0.4.drv' failed to build
error: building '/nix/store/npn8q9bml5mwgdwgznhy9axxw0nxvbxp-python3.10-cryptography-41.0.4.drv' failed
error: 1 dependency of derivation '/nix/store/9k75i6rg9vfcncfsrf3sigpi6wr82g0b-python3-3.10.12-env.drv' failed to build
error: building '/nix/store/9k75i6rg9vfcncfsrf3sigpi6wr82g0b-python3-3.10.12-env.drv' failed

This looks really strange because I do not know how to solve it and also because it looks like the sha256 that I am setting is not the one that Nix will match. I read also #413 but I was not able to solve the problem.

There is someone who can help me understand and solve the problem?

Thanks!

Additional context

default.nix/shell.nix/flake.nix:

let
  # Import nixpkgs
  pkgs = import <nixpkgs> { };

  # Import poetry2nix and its functions
  poetry2nix = pkgs.poetry2nix;

  # 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 [ ] ++ [ super.hatchling ]; });
      protobuf3 = super.protobuf3.overridePythonAttrs (old: {
        buildInputs = old.buildInputs or [ ] ++ [ super.setuptools ];
      });
      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 ]; });

      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=";
        };
      });
    });
  };
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
    python310Packages.setuptools
    finalEnv # Add the poetry environment here

    # optional dev libraries
    ccache

    # debugs libraries
    valgrind

    # Indirected dependencies for running tests
    bitcoind
  ];

  nativeBuildInputs = [ python310Packages.setuptools ];
  propagatedBuildInputs = [ python310Packages.setuptools ];
}

pyproject.toml: https://github.com/ElementsProject/lightning/blob/master/pyproject.toml
poetry.lock: https://github.com/ElementsProject/lightning/blob/master/poetry.lock

@vincenzopalazzo
Copy link
Author

Maybe this can be solved by #1322

I will check it out

@zeratax
Copy link
Contributor

zeratax commented Oct 12, 2023

how would i use a newer version of poetry2nix? especially in the context of shell.nix

@vincenzopalazzo
Copy link
Author

vincenzopalazzo commented Oct 12, 2023

@zeratax

I used this :)

  # Import nixpkgs
  pkgs = import <nixpkgs> { };

  # Import poetry2nix and its functions
  poetry2nixSrc = pkgs.fetchFromGitHub {
    owner = "nix-community";
    repo = "poetry2nix";
    rev = "e23218d1599e3369dfc878757e58974017e0ecc8"; # Fetch the latest master
    sha256 = "sha256-p6niqag7b4XEHvzWgG0X/xjoW/ZXbAxW8ggd8yReT3Y=";
  };

  poetry2nix = import poetry2nixSrc { };

@l0b0
Copy link
Contributor

l0b0 commented Oct 12, 2023

    rev = "master"; # Fetch the latest master

You probably want to specify the commit hash, so that the build doesn't break when the master branch gets more commits.

@vincenzopalazzo
Copy link
Author

@l0b0 yep I realize it :)

justuswilhelm added a commit to jwpconsulting/projectify that referenced this issue Feb 23, 2024
There is an issue with cryptography 42.0.3 not building:

nix-community/poetry2nix#1337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants