Skip to content

Commit

Permalink
fixup! build: add a simple nix dev shell
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Oct 18, 2023
1 parent f6dd1cd commit 4a449a5
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions contrib/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,48 @@ 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 <url>`
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 {
python = pkgs.python310;
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 ]; });

Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 4a449a5

Please sign in to comment.