From 4a449a5f06d1df4aca0fa2b58bbd5f75e5ccab37 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Wed, 18 Oct 2023 09:49:06 +0200 Subject: [PATCH] fixup! build: add a simple nix dev shell Signed-off-by: Vincenzo Palazzo --- contrib/nix/default.nix | 51 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/contrib/nix/default.nix b/contrib/nix/default.nix index 099cc3097be7..3be4700f34d5 100644 --- a/contrib/nix/default.nix +++ b/contrib/nix/default.nix @@ -2,24 +2,11 @@ let # Import nixpkgs # To see why this is required please look at # https://discourse.nixos.org/t/nix-consumes-all-available-memory-evaluating-a-flake-using-recent-nixpkgs/33322 - pkgs = import (builtins.fetchTarball { - # Descriptive name to make the store path easier to identify - name = "nixpkgs-23.05"; - # Commit hash for nixos-unstable as of 2018-09-12 - url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz"; - # Hash obtained using `nix-prefetch-url --unpack ` - sha256 = "10wn0l08j9lgqcw8177nh2ljrnxdrpri7bp0g7nvrsn9rkawvlbf"; + pkgs = import (fetchTarball { + url = + "https://github.com/NixOS/nixpkgs/archive/3476a10478587dec90acb14ec6bde0966c545cc0.tar.gz"; }) { }; - - # 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 { }; + poetry2nix = pkgs.poetry2nix; # Create a Python environment using poetry2nix finalEnv = poetry2nix.mkPoetryEnv { @@ -27,14 +14,36 @@ let projectDir = ../../.; poetrylock = ../../poetry.lock; # Path to your poetry.lock file overrides = poetry2nix.overrides.withDefaults (self: super: { + cryptography = super.cryptography.overrideAttrs (oldAttrs: 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 = "${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; + }); + 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 ]; }); @@ -67,14 +76,6 @@ let 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 =