diff --git a/flake.lock b/flake.lock index 96915962..875f0ae1 100644 --- a/flake.lock +++ b/flake.lock @@ -63,11 +63,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1682453498, - "narHash": "sha256-WoWiAd7KZt5Eh6n+qojcivaVpnXKqBsVgpixpV2L9CE=", + "lastModified": 1682526928, + "narHash": "sha256-2cKh4O6t1rQ8Ok+v16URynmb0rV7oZPEbXkU0owNLQs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c8018361fa1d1650ee8d4b96294783cf564e8a7f", + "rev": "d6b863fd9b7bb962e6f9fdf292419a775e772891", "type": "github" }, "original": { @@ -96,11 +96,11 @@ ] }, "locked": { - "lastModified": 1682475596, - "narHash": "sha256-hQS8kPq5mSIhLZTRlCt1LHMBJtrOkWiXtvtizaU1e1Q=", + "lastModified": 1682648393, + "narHash": "sha256-VH0/4PXTPHVc3E6NxuB51w2eW1/Yn8NGq+HkB8kA0cU=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "4d1bb70dd1231d0cd1d76deffe7bf0b6127185ea", + "rev": "2c22a41baadfac75a4af5303fc3ef8d4145b795b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5b868d12..824bb396 100644 --- a/flake.nix +++ b/flake.nix @@ -39,8 +39,15 @@ flake-parts.lib.mkFlake {inherit inputs;} { systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; imports = [./packages]; - perSystem = {final, ...}: { - devShells.default = import ./shell.nix {pkgs = final;}; + perSystem = { + final, + self', + ... + }: { + devShells.default = import ./shell.nix { + pkgs = final; + inherit self'; + }; }; }; } diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 00000000..8c2b3b43 --- /dev/null +++ b/overlay.nix @@ -0,0 +1,143 @@ +_finalNixpkgs: prevNixpkgs: let + solana-rust-artifacts = prevNixpkgs.callPackage ./packages/solana-rust-artifacts {}; + + solana-bpf-tools = prevNixpkgs.callPackage ./packages/solana-bpf-tools {}; + + solana-full-sdk = prevNixpkgs.callPackage ./packages/solana-full-sdk { + inherit solana-rust-artifacts solana-bpf-tools; + }; + + cosmos-theta-testnet = prevNixpkgs.callPackage ./packages/cosmos-theta-testnet {}; + + circom = prevNixpkgs.callPackage ./packages/circom/default.nix {}; + circ = prevNixpkgs.callPackage ./packages/circ/default.nix {}; + + wasmd = prevNixpkgs.callPackage ./packages/wasmd/default.nix {}; + + # erdpy depends on cattrs >= 22.2 + cattrs22-2 = prevNixpkgs.python3Packages.cattrs.overridePythonAttrs (previousAttrs: rec { + version = "22.2.0"; + + src = prevNixpkgs.fetchFromGitHub { + owner = "python-attrs"; + repo = "cattrs"; + rev = "v${version}"; + hash = "sha256-Qnrq/mIA/t0mur6IAen4vTmMIhILWS6v5nuf+Via2hA="; + }; + + patches = []; + }); + + # https://discourse.nixos.org/t/inconsistent-vendoring-in-buildgomodule-when-overriding-source/9225/6 + go-ethereum-capella = prevNixpkgs.go-ethereum.override rec { + buildGoModule = args: + prevNixpkgs.buildGoModule (args + // { + version = "1.11.1"; + src = prevNixpkgs.fetchFromGitHub { + owner = "ethereum"; + repo = "go-ethereum"; + rev = "v1.11.1"; + sha256 = "sha256-mYLxwJ0oiKfiz+NZ5bnlY0h2uq5wbeQKrwoCCw23Bg0="; + }; + subPackages = builtins.filter (x: x != "cmd/puppeth") args.subPackages; + vendorSha256 = "sha256-6yLkeT5DrAPUohAmobssKkvxgXI8kACxiu17WYbw+n0="; + }); + }; + + # copied from https://github.com/NixOS/nixpkgs/blob/8df7949791250b580220eb266e72e77211bedad9/pkgs/development/python-modules/cryptography/default.nix + cryptography36 = prevNixpkgs.callPackage ./packages/python-modules/cryptography36/default.nix {}; + + ledgercomm = prevNixpkgs.callPackage ./packages/python-modules/ledgercomm/default.nix {}; + requests-cache = prevNixpkgs.callPackage ./packages/python-modules/requests-cache/default.nix {}; + + erdpy = prevNixpkgs.callPackage ./packages/erdpy/default.nix {}; + elrond-go = prevNixpkgs.callPackage ./packages/elrond-go/default.nix {}; + elrond-proxy-go = prevNixpkgs.callPackage ./packages/elrond-proxy-go/default.nix {}; + + go-opera = prevNixpkgs.callPackage ./packages/go-opera/default.nix {}; + + leap = prevNixpkgs.callPackage ./packages/leap/default.nix {}; + eos-vm = prevNixpkgs.callPackage ./packages/eos-vm/default.nix {}; + cdt = prevNixpkgs.callPackage ./packages/cdt/default.nix {}; + + nimbus = prevNixpkgs.callPackage ./packages/nimbus/default.nix {}; + + pistache = prevNixpkgs.callPackage ./packages/pistache/default.nix {}; + ffiasm-src = prevNixpkgs.callPackage ./packages/ffiasm/src.nix {}; + zqfield = prevNixpkgs.callPackage ./packages/ffiasm/zqfield.nix { + inherit ffiasm-src; + }; + # Pairing Groups on BN-254, aka alt_bn128 + # Source: + # https://zips.z.cash/protocol/protocol.pdf (section 5.4.9.1) + # See also: + # https://eips.ethereum.org/EIPS/eip-196 + # https://eips.ethereum.org/EIPS/eip-197 + # https://hackmd.io/@aztec-network/ByzgNxBfd + # https://hackmd.io/@jpw/bn254 + zqfield-bn254 = prevNixpkgs.symlinkJoin { + name = "zqfield-bn254"; + paths = [ + (zqfield { + primeNumber = "21888242871839275222246405745257275088696311157297823662689037894645226208583"; + name = "Fq"; + }) + (zqfield + { + primeNumber = "21888242871839275222246405745257275088548364400416034343698204186575808495617"; + name = "Fr"; + }) + ]; + }; + ffiasm = prevNixpkgs.callPackage ./packages/ffiasm/default.nix { + inherit ffiasm-src zqfield-bn254; + }; + circom_runtime = prevNixpkgs.callPackage ./packages/circom_runtime/default.nix {}; + rapidsnark = prevNixpkgs.callPackage ./packages/rapidsnark/default.nix { + inherit ffiasm zqfield-bn254; + }; + rapidsnark-server = prevNixpkgs.callPackage ./packages/rapidsnark-server/default.nix { + inherit ffiasm zqfield-bn254 rapidsnark pistache; + }; +in { + metacraft-labs = rec { + solana = solana-full-sdk; + inherit cosmos-theta-testnet; + inherit circom; + + # Disabled until cvc4 compiles again + # inherit circ; + + inherit wasmd; + inherit ledgercomm; + inherit cryptography36; + inherit requests-cache; + inherit erdpy; + inherit cattrs22-2; + + # Disabled until elrond-go can build with Go >= 1.19 + # inherit elrond-go; + # inherit elrond-proxy-go; + inherit go-opera; + inherit leap; + inherit eos-vm; + inherit cdt; + + # Ethereum + inherit nimbus; + inherit go-ethereum-capella; + + inherit pistache; + inherit zqfield-bn254; + inherit zqfield; + inherit ffiasm; + inherit circom_runtime; + inherit rapidsnark; + inherit rapidsnark-server; + + inherit mythril; + inherit blake2b-py; + inherit py-solc-x; + }; +} diff --git a/packages/all-packages.nix b/packages/all-packages.nix index 17cec474..33f8159c 100644 --- a/packages/all-packages.nix +++ b/packages/all-packages.nix @@ -1,18 +1,18 @@ -{...}: { +{inputs, ...}: { + imports = [inputs.flake-parts.flakeModules.easyOverlay ./python-modules]; perSystem = { pkgs, self', ... }: let - inherit (pkgs) lib darwin hostPlatform symlinkJoin fetchFromGitHub; + inherit (pkgs) lib darwin hostPlatform symlinkJoin fetchFromGitHub python3Packages; inherit (pkgs.lib) optionalAttrs callPackageWith; - inherit (self'.legacyPackages) rustPlatformStable; - python3Packages = pkgs.python3Packages; - + inherit (self'.legacyPackages) rustPlatformStable rustPlatformNightly; callPackage = callPackageWith (pkgs // {rustPlatform = rustPlatformStable;}); darwinPkgs = { inherit (darwin.apple_sdk.frameworks) Foundation; }; + python-modules = self'.legacyPackages.python-modules; # RapidSnark ffiasm-src = callPackage ./ffiasm/src.nix {}; @@ -49,36 +49,20 @@ }; # Elrond / MultiversX - # copied from https://github.com/NixOS/nixpkgs/blob/8df7949791250b580220eb266e72e77211bedad9/pkgs/development/python-modules/cryptography/default.nix - cattrs22-2 = pkgs.python3Packages.cattrs.overrideAttrs (finalAttrs: previousAttrs: { - version = "22.2.0"; - - src = fetchFromGitHub { - owner = "python-attrs"; - repo = "cattrs"; - rev = "v22.2.0"; - hash = "sha256-Qnrq/mIA/t0mur6IAen4vTmMIhILWS6v5nuf+Via2hA="; - }; - - patches = []; - }); - cryptography36 = callPackage ./python-modules/cryptography36/default.nix {}; - py-ecc = callPackage ./python-modules/py-ecc/default.nix { - inherit (python3Packages) buildPythonPackage cached-property eth-typing eth-utils mypy-extensions pytestCheckHook pythonOlder; + erdpy = callPackage ./erdpy/default.nix { + inherit elrond-go elrond-proxy-go; + inherit (python-modules) cryptography36 ledgercomm requests-cache; }; - - ledgercomm = callPackage ./python-modules/ledgercomm/default.nix {}; - requests-cache = callPackage ./python-modules/requests-cache/default.nix {inherit cattrs22-2;}; - - corepack-shims = callPackage ./corepack-shims/default.nix {}; - - erdpy = callPackage ./erdpy/default.nix {inherit cryptography36 elrond-go elrond-proxy-go ledgercomm requests-cache;}; elrond-go = callPackage ./elrond-go/default.nix {}; elrond-proxy-go = callPackage ./elrond-proxy-go/default.nix {}; + + corepack-shims = callPackage ./corepack-shims/default.nix {}; in { legacyPackages.metacraft-labs = rec { + inherit (python-modules) mythril; + cosmos-theta-testnet = callPackage ./cosmos-theta-testnet {}; circom = callPackage ./circom/default.nix {}; @@ -131,9 +115,6 @@ inherit solana-rust-artifacts solana-bpf-tools; }; - inherit cryptography36; - - inherit py-ecc; inherit corepack-shims; # inherit erdpy elrond-go elrond-proxy-go; diff --git a/packages/default.nix b/packages/default.nix index 96fcf179..504bf9f4 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -12,6 +12,10 @@ extensions = ["rust-src"]; targets = ["wasm32-wasi" "wasm32-unknown-unknown"]; }; + rust-nightly = pkgs-extended.rust-bin.nightly.latest.default.override { + extensions = ["rust-src"]; + targets = ["wasm32-wasi" "wasm32-unknown-unknown"]; + }; in { packages = self'.legacyPackages.metacraft-labs; @@ -22,12 +26,16 @@ legacyPackages = { nix2container = inputs'.nix2container.packages.nix2container; - rust-stable = rust-stable; + inherit rust-stable rust-nightly; rustPlatformStable = pkgs.makeRustPlatform { rustc = rust-stable; cargo = rust-stable; }; + rustPlatformNightly = pkgs.makeRustPlatform { + rustc = rust-nightly; + cargo = rust-nightly; + }; }; }; } diff --git a/packages/python-modules/blake2b-py/Cargo.lock b/packages/python-modules/blake2b-py/Cargo.lock new file mode 100644 index 00000000..f8a77ada --- /dev/null +++ b/packages/python-modules/blake2b-py/Cargo.lock @@ -0,0 +1,271 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "blake2b-py" +version = "0.2.0" +dependencies = [ + "hex", + "pyo3", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "libc" +version = "0.2.141" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" +dependencies = [ + "paste-impl", + "proc-macro-hack", +] + +[[package]] +name = "paste-impl" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" +dependencies = [ + "proc-macro-hack", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + +[[package]] +name = "proc-macro2" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pyo3" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d41d50a7271e08c7c8a54cd24af5d62f73ee3a6f6a314215281ebdec421d5752" +dependencies = [ + "cfg-if", + "indoc", + "libc", + "parking_lot", + "paste", + "pyo3-build-config", + "pyo3-macros", + "unindent", +] + +[[package]] +name = "pyo3-build-config" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779239fc40b8e18bc8416d3a37d280ca9b9fb04bda54b98037bb6748595c2410" +dependencies = [ + "once_cell", +] + +[[package]] +name = "pyo3-macros" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b247e8c664be87998d8628e86f282c25066165f1f8dda66100c48202fdb93a" +dependencies = [ + "pyo3-macros-backend", + "quote", + "syn", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a8c2812c412e00e641d99eeb79dd478317d981d938aa60325dfa7157b607095" +dependencies = [ + "proc-macro2", + "pyo3-build-config", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unindent" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/packages/python-modules/blake2b-py/default.nix b/packages/python-modules/blake2b-py/default.nix new file mode 100644 index 00000000..9e106e09 --- /dev/null +++ b/packages/python-modules/blake2b-py/default.nix @@ -0,0 +1,60 @@ +{ + lib, + python3Packages, + fetchFromGitHub, + maturin, + gnumake, + git, + cargo, + rustPlatform, +}: +python3Packages.buildPythonPackage rec { + pname = "blake2b-py"; + version = "0.2.0"; + format = "gnumake"; + + disabled = python3Packages.pythonOlder "3.6"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "blake2b-py"; + rev = "v${version}"; + hash = "sha256-N5xnJf5MjJ+rNeeE0/B5ChHxgr8uxahV0bwHpP03LYw="; + }; + + postUnpack = '' + cp ${./Cargo.lock} ./source/Cargo.lock + ''; + + # cargoLock = let + # fixupLockFile = path: (builtins.readFile path); + # in { + # lockFileContents = fixupLockFile ./Cargo.lock; + # }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + sourceRoot = "source"; + name = "${pname}-${version}"; + sha256 = "sha256-BS3zqdCn7E/alj+rw23QKasTKiQuUdtDSuyNvB/wObI="; + postUnpack = '' + cp ${./Cargo.lock} ./source/Cargo.lock + ''; + }; + + nativeBuildInputs = [ + maturin + gnumake + git + python3Packages.python + rustPlatform.cargoSetupHook + rustPlatform.maturinBuildHook + python3Packages.setuptools-rust + ]; + + meta = with lib; { + description = "Blake2b hashing in Rust with Python bindings."; + homepage = "https://pypi.org/project/blake2b-py/"; + license = licenses.mit; + }; +} diff --git a/packages/python-modules/default.nix b/packages/python-modules/default.nix new file mode 100644 index 00000000..379c5e78 --- /dev/null +++ b/packages/python-modules/default.nix @@ -0,0 +1,477 @@ +{...}: { + perSystem = { + pkgs, + self', + ... + }: let + inherit (pkgs) lib darwin hostPlatform symlinkJoin fetchFromGitHub python3Packages; + inherit (pkgs.lib) optionalAttrs callPackageWith; + inherit (self'.legacyPackages) rustPlatformStable rustPlatformNightly; + callPackage = callPackageWith (pkgs // {rustPlatform = rustPlatformStable;}); + darwinPkgs = { + inherit (darwin.apple_sdk.frameworks) Foundation; + }; + + # Elrond / MultiversX + # copied from https://github.com/NixOS/nixpkgs/blob/8df7949791250b580220eb266e72e77211bedad9/pkgs/development/python-modules/cryptography/default.nix + cattrs22-2 = pkgs.python3Packages.cattrs.overrideAttrs (finalAttrs: previousAttrs: { + version = "22.2.0"; + + src = fetchFromGitHub { + owner = "python-attrs"; + repo = "cattrs"; + rev = "v22.2.0"; + hash = "sha256-Qnrq/mIA/t0mur6IAen4vTmMIhILWS6v5nuf+Via2hA="; + }; + + patches = []; + }); + cryptography36 = callPackage ./cryptography36/default.nix {}; + + ledgercomm = callPackage ./ledgercomm/default.nix {}; + requests-cache = callPackage ./requests-cache/default.nix {inherit cattrs22-2;}; + + jinja2_fixed = python3Packages.jinja2.override { + markupsafe = markupsafe-201; + }; + persistent_fixed = python3Packages.persistent.override { + sphinx = sphinx_fixed; + }; + sphinx_fixed = python3Packages.sphinx.override { + jinja2 = jinja2_fixed; + }; + factory_boy_fixed = python3Packages.factory_boy.override { + flask = flask-212; + flask-sqlalchemy = flask-sqlalchemy-251; + faker = faker_fixed; + }; + faker_fixed = python3Packages.faker.override { + pillow = pillow_fixed; + }; + pillow_fixed = python3Packages.pillow.override { + libtiff = libtiff_fixed; + lcms2 = lcms2_fixed; + libwebp = libwebp_fixed; + openjpeg = openjpeg_fixed; + }; + matplotlib_fixed = python3Packages.matplotlib.override { + pyparsing = pyparsing-247; + fonttools = fonttools_fixed; + }; + pytest-cov_fixed = python3Packages.pytest-cov.override { + coverage = coverage-650; + }; + virtualenv_fixed = python3Packages.virtualenv.override { + pytest-timeout = pytest-timeout_fixed; + }; + nose_fixed = python3Packages.nose.override { + coverage = coverage-650; + }; + fonttools_fixed = python3Packages.fonttools.override { + scipy = scipy_fixed; + }; + scipy_fixed = python3Packages.scipy.override { + nose = nose_fixed; + pythran = pythran_fixed; + }; + pythran_fixed = python3Packages.pythran.override { + networkx = networkx_fixed; + }; + networkx_fixed = python3Packages.networkx.override { + nose = nose_fixed; + }; + pytest-timeout_fixed = python3Packages.pytest-timeout.override { + pytest-cov = pytest-cov_fixed; + }; + lcms2_fixed = pkgs.lcms2.override { + libtiff = libtiff_fixed; + }; + openjpeg_fixed = pkgs.openjpeg.override { + libtiff = libtiff_fixed; + lcms2 = lcms2_fixed; + }; + libwebp_fixed = pkgs.libwebp.override { + libtiff = libtiff_fixed; + }; + libtiff_fixed = pkgs.libtiff.override { + sphinx = sphinx_fixed; + }; + + flask-212 = + (python3Packages.flask.override { + jinja2 = jinja2_fixed; + werkzeug = werkzeug-212; + }) + .overridePythonAttrs (old: rec { + version = "2.1.2"; + pname = "Flask"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-MV3tLd+KYoFWftsnOTAQ/jQGGIuvv+ZaMznVeH2J5Hc="; + }; + }); + + flask-sqlalchemy-251 = + (python3Packages.flask-sqlalchemy.override { + flask = flask-212; + }) + .overridePythonAttrs (old: rec { + pname = "Flask-SQLAlchemy"; + version = "2.5.1"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-K9pEtD58rLFdTgX/PMH4vJeTbMRkYjQkECv8LDXpWRI="; + }; + + propagatedBuildInputs = old.propagatedBuildInputs ++ [python3Packages.setuptools]; + doCheck = false; + }); + + werkzeug-212 = + (python3Packages.werkzeug.override { + markupsafe = markupsafe-201; + pytest-timeout = pytest-timeout_fixed; + }) + .overridePythonAttrs (old: rec { + version = "2.1.2"; + + src = python3Packages.fetchPypi { + pname = "Werkzeug"; + inherit version; + sha256 = "sha256-HOCOgJPtZ9Y41jh5/Rujc1gX96gN42dNKT9ZhPJftuY="; + }; + }); + + eth-typing-230 = python3Packages.eth-typing.overridePythonAttrs (old: rec { + version = "2.3.0"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-typing"; + rev = "c3210d5e2b867f781c297b5c01ada6c399bc402b"; # commit hash for v2.3.0, as nix has trouble fetching the tag. + sha256 = "sha256-cuA6vSfCfqgffEhSEuVeKJfxsGLw1mGID9liodE9wcU="; + }; + }); + + eth-utils-110 = + (python3Packages.eth-utils.override { + cytoolz = cytoolz-0112; + toolz = toolz-0112; + eth-typing = eth-typing-230; + }) + .overrideAttrs (old: rec { + version = "1.10.0"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-utils"; + rev = "v${version}"; + sha256 = "sha256-sq3H4HmUFUipqVYleZxWLG1gBsQEoNwcZAXiKckacek="; + }; + }); + + py-ecc-410 = + (python3Packages.py-ecc.override { + eth-typing = eth-typing-230; + eth-utils = eth-utils-110; + }) + .overridePythonAttrs (old: rec { + version = "4.1.0"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "py_ecc"; + rev = "v${version}"; + hash = "sha256-qs4dvfdrl6o74FAst6XBAvzjJ7ZCA58s447aCTGIt2Y="; + }; + }); + + eth-keys-034 = + (python3Packages.eth-keys.override (old: { + factory_boy = factory_boy_fixed; + eth-utils = eth-utils-110; + eth-typing = eth-typing-230; + })) + .overridePythonAttrs (old: rec { + version = "0.3.4"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-keys"; + rev = "v${version}"; + fetchSubmodules = true; + sha256 = "sha256-P/5v4fk6gtbXju+xyDE9enAsmch+gquzvYUIn4Kvs0Y="; + }; + + pythonImportsCheck = []; # workaround for issue with pythonImportsCheckPhase + + disabledTests = + old.disabledTests + ++ [ + "test_coincurve_to_native_invalid_signatures" + "test_get_abi_strategy_returns_certain_strategies_for_known_type_strings" + ]; + }); + + eth-keyfile-051 = + (python3Packages.eth-keyfile.override (old: { + eth-utils = eth-utils-110; + eth-keys = eth-keys-034; + })) + .overridePythonAttrs (old: rec { + version = "0.5.1"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-keyfile"; + rev = "v${version}"; + fetchSubmodules = true; + sha256 = "sha256-w3baJFYBn8N5UGjR4Bec8c1UH9O0vbmPpsMfw9KGHCg="; + }; + }); + + eth-abi-211 = + (python3Packages.eth-abi.override (old: { + eth-utils = eth-utils-110; + eth-typing = eth-typing-230; + parsimonious = parsimonious-081; + })) + .overridePythonAttrs (old: rec { + version = "2.1.1"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-abi"; + rev = "v${version}"; + fetchSubmodules = true; + sha256 = "sha256-b4rlmyCP1bg4O3gaRNWTPo4ALlidK4gUx0WrsJVHu4g="; + }; + }); + + eth-account-059 = + (python3Packages.eth-account.override (old: { + eth-abi = eth-abi-211; + eth-keyfile = eth-keyfile-051; + eth-keys = eth-keys-034; + eth-rlp = eth-rlp-021; + eth-utils = eth-utils-110; + hexbytes = hexbytes-023; + rlp = rlp-201; + })) + .overridePythonAttrs (old: rec { + version = "0.5.9"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-account"; + rev = "v${version}"; + sha256 = "sha256-ouIWVIHkEirF1Ryhp/DwIMtKyXWTcYTsszQjDUGP47M="; + }; + }); + + eth-rlp-021 = + (python3Packages.eth-rlp.override (old: { + hexbytes = hexbytes-023; + rlp = rlp-201; + })) + .overridePythonAttrs (old: rec { + version = "0.2.1"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-rlp"; + rev = "v${version}"; + sha256 = "sha256-BJsFsHyv1DcJ+nqvhDu3+mwYarn9V2rBg9PcpxDeEI8="; + }; + + propagatedBuildInputs = with python3Packages; [ + rlp-201 + hexbytes-023 + ]; + }); + + parsimonious-081 = python3Packages.eth-abi.overridePythonAttrs (old: rec { + pname = "parsimonious"; + version = "0.8.1"; + + src = python3Packages.fetchPypi { + inherit pname version; + hash = "sha256-Ot0ziJLVgODLOxo55KG0J/+faHhY/dYQlwU3Qjkan2s="; + }; + + pythonImportsCheck = []; # workaround for issue with pythonImportsCheckPhase + + propagatedBuildInputs = [ + python3Packages.six + python3Packages.regex + ]; + }); + + typing-extensions-31002 = python3Packages.typing-extensions.overridePythonAttrs (old: rec { + pname = "typing_extensions"; + version = "3.10.0.2"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"; + }; + + checkInputs = lib.optional (python3Packages.pythonOlder "3.5") python3Packages.typing; + nativeBuildInputs = with python3Packages; [ + flit-core + setuptools + ]; + }); + + pyparsing-247 = + (python3Packages.pyparsing.override (old: { + jinja2 = jinja2_fixed; + })) + .overridePythonAttrs ( + old: rec { + pname = "pyparsing"; + version = "2.4.7"; + src = fetchFromGitHub { + owner = "pyparsing"; + repo = pname; + rev = "pyparsing_${version}"; + sha256 = "sha256-0Dyzw3xiCGhLbXPcL2cq2fZuN1N5StSZ/I86gQHy7pI="; + }; + pythonImportsCheck = []; + passthru.tests = {}; + nativeBuildInputs = with python3Packages; [ + setuptools + ]; + } + ); + + markupsafe-201 = python3Packages.markupsafe.overridePythonAttrs (old: rec { + pname = "markupsafe"; + version = "2.0.1"; + + src = python3Packages.fetchPypi { + pname = "MarkupSafe"; + inherit version; + sha256 = "02k2ynmqvvd0z0gakkf8s4idyb606r7zgga41jrkhqmigy06fk2r"; + }; + }); + + coverage-650 = python3Packages.coverage.overridePythonAttrs (old: rec { + pname = "coverage"; + version = "6.5.0"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-9kLpB1TuPgaw5+UbzjN5WQ52t/drcI4acf8EP4cCXIQ="; + }; + }); + + rlp-201 = + (python3Packages.rlp.override (old: { + eth-utils = eth-utils-110; + })) + .overridePythonAttrs (old: rec { + pname = "rlp"; + version = "2.0.1"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "665e8312750b3fc5f7002e656d05b9dcb6e93b6063df40d95c49ad90c19d1f0e"; + }; + propagatedBuildInputs = [eth-utils-110]; + }); + + toolz-0112 = python3Packages.toolz.overridePythonAttrs (old: rec { + pname = "toolz"; + version = "0.11.2"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-azEtXhUThVLxvaik5mww4jbIMbYSsr8ABfih3xCkvDM="; + }; + }); + + cytoolz-0112 = + (python3Packages.cytoolz.override (old: { + toolz = toolz-0112; + })) + .overridePythonAttrs (old: rec { + pname = "cytoolz"; + version = "0.11.2"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-6iNmMVOAbt3c5+QVPR1AfWI1fAUSCk6Ehb3fG9WrIrQ="; + }; + }); + + hexbytes-023 = + (python3Packages.hexbytes.override (old: { + eth-utils = eth-utils-110; + })) + .overridePythonAttrs (old: rec { + pname = "hexbytes"; + version = "0.2.3"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "hexbytes"; + rev = "v${version}"; + sha256 = "sha256-bFk2TMZgwmTCr+jzfWfYd6F2v4a6/+kgk0IHxzoCccI="; + }; + }); + + mythril = callPackage ./mythril/default.nix { + inherit + eth-typing-230 + eth-utils-110 + py-ecc-410 + eth-keyfile-051 + parsimonious-081 + eth-keys-034 + eth-abi-211 + py-solc-x + typing-extensions-31002 + pyparsing-247 + markupsafe-201 + coverage-650 + blake2b-py + py-flags + rlp-201 + ethereum-input-decoder + eth-account-059 + pre-commit-2200 + cytoolz-0112 + py-evm + z3-solver + persistent_fixed + matplotlib_fixed + pytest-cov_fixed + ; + }; + py-solc-x = callPackage ./py-solc-x/default.nix {}; + blake2b-py = callPackage ./blake2b-py/default.nix {rustPlatform = rustPlatformNightly;}; + py-flags = callPackage ./py-flags/default.nix {}; + pre-commit-2200 = callPackage ./pre-commit-2200/default.nix {inherit virtualenv_fixed;}; + ethereum-input-decoder = callPackage ./ethereum-input-decoder/default.nix {inherit eth-abi-211 parsimonious-081;}; + py-evm = callPackage ./py-evm/default.nix {inherit py-ecc-410 rlp-201 pyethash eth-keys-034 eth-bloom-104 trie;}; + pyethash = callPackage ./pyethash/default.nix {}; + trie = callPackage ./trie/default.nix {inherit typing-extensions-31002 eth-utils-110 rlp-201 hexbytes-023;}; + eth-bloom-104 = callPackage ./eth-bloom-104/default.nix {}; + z3-solver = callPackage ./z3-solver/default.nix {inherit jinja2_fixed;}; + + py-ecc = callPackage ./py-ecc/default.nix { + inherit (python3Packages) buildPythonPackage cached-property eth-typing eth-utils mypy-extensions pytestCheckHook pythonOlder; + }; + in { + legacyPackages.python-modules = { + inherit cryptography36 ledgercomm requests-cache cattrs22-2; + + inherit mythril; + inherit blake2b-py; + inherit py-solc-x; + }; + }; +} diff --git a/packages/python-modules/eth-bloom-104/default.nix b/packages/python-modules/eth-bloom-104/default.nix new file mode 100644 index 00000000..575560d3 --- /dev/null +++ b/packages/python-modules/eth-bloom-104/default.nix @@ -0,0 +1,26 @@ +{ + lib, + python3Packages, + fetchFromGitHub, +}: +python3Packages.buildPythonPackage rec { + pname = " eth-bloom"; + version = "1.0.4"; + + src = fetchFromGitHub { + owner = "ethereum"; + repo = "eth-bloom"; + rev = "v${version}"; + sha256 = "sha256-I+533a+OVBThUegL9EXMQOPrYxaxiiPSwZr1CmYSn5w="; + }; + + preConfigure = '' + substituteInPlace setup.py --replace \'setuptools-markdown\' "" + ''; + + propagatedBuildInputs = with python3Packages; [ + setuptools + eth-hash + pycryptodome + ]; +} diff --git a/packages/python-modules/ethereum-input-decoder/default.nix b/packages/python-modules/ethereum-input-decoder/default.nix new file mode 100644 index 00000000..5ff33f85 --- /dev/null +++ b/packages/python-modules/ethereum-input-decoder/default.nix @@ -0,0 +1,23 @@ +{ + lib, + python3Packages, + eth-abi-211, + parsimonious-081, +}: +python3Packages.buildPythonPackage rec { + pname = "ethereum-input-decoder"; + version = "0.2.2"; + + src = python3Packages.fetchPypi { + pname = "ethereum_input_decoder"; + inherit version; + sha256 = "sha256-jPCfIhdvgmgqJb5UfkSTDpXvJw89F99edGDWUaM8hgY="; + }; + + propagatedBuildInputs = with python3Packages; [ + setuptools + requests + eth-abi-211 + parsimonious-081 + ]; +} diff --git a/packages/python-modules/mythril/default.nix b/packages/python-modules/mythril/default.nix new file mode 100644 index 00000000..e4813d1c --- /dev/null +++ b/packages/python-modules/mythril/default.nix @@ -0,0 +1,119 @@ +{ + lib, + pkgs, + python3Packages, + fetchFromGitHub, + py-ecc-410, + eth-utils-110, + eth-keyfile-051, + eth-keys-034, + eth-typing-230, + eth-abi-211, + parsimonious-081, + py-solc-x, + typing-extensions-31002, + pyparsing-247, + blake2b-py, + markupsafe-201, + coverage-650, + py-flags, + ethereum-input-decoder, + rlp-201, + eth-account-059, + pre-commit-2200, + cytoolz-0112, + py-evm, + z3-solver, + persistent_fixed, + matplotlib_fixed, + pytest-cov_fixed, +}: +python3Packages.buildPythonPackage rec { + pname = "mythril"; + version = "0.23.17"; + format = "setuptools"; + + disabled = python3Packages.pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "ConsenSys"; + repo = "mythril"; + rev = "v${version}"; + hash = "sha256-lzxAhaQfiGygxI98x1hWP8wrHVbf9DuZuEnjJcKMRCo="; + }; + + preConfigure = '' + substituteInPlace requirements.txt --replace py-solc py-solc-x + substituteInPlace requirements.txt --replace py-solc-x-x "" + #removing version specification, as for some reason nix has trouble finding them, even when they match the version specification + substituteInPlace requirements.txt --replace "cytoolz<0.12.0" cytoolz + substituteInPlace requirements.txt --replace "pyparsing<3,>=2.0.2" pyparsing + substituteInPlace requirements.txt --replace "coverage<7.0,>6.0" coverage + #the closest nix has is 4.8.5 + substituteInPlace requirements.txt --replace "z3-solver>=4.8.8.0" z3-solver + ''; + + propagatedBuildInputs = with pkgs; + with python3Packages; [ + setuptools + pytest-mock + requests + semantic-version + transaction + certifi + coincurve + configparser + coloredlogs + cython + gcc + pytest + + #custom packages + pyparsing-247 + py-ecc-410 + eth-typing-230 + eth-utils-110 + eth-keyfile-051 + eth-keys-034 + eth-abi-211 + parsimonious-081 + py-solc-x + typing-extensions-31002 + blake2b-py + markupsafe-201 + coverage-650 + py-flags + ethereum-input-decoder + rlp-201 + eth-account-059 + pre-commit-2200 + cytoolz-0112 + py-evm + z3-solver + persistent_fixed + matplotlib_fixed + + pytest-cov_fixed + ]; + nativeBuildInputs = propagatedBuildInputs; + + # postFixup = lib.optionalString withSolc '' + # wrapProgram $out/bin/myhtril \ + # --prefix PATH : "${lib.makeBinPath [solc]}" + # ''; + + # No Python tests + doCheck = false; + + meta = with lib; { + description = "Security analysis tool for EVM bytecode."; + longDescription = '' + Mythril is a security analysis tool for EVM bytecode. It detects security vulnerabilities in smart contracts built + for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains. It uses + symbolic execution, SMT solving and taint analysis to detect a variety of security vulnerabilities. It's also used + (in combination with other tools and techniques) in the MythX security analysis platform. + ''; + homepage = "https://github.com/ConsenSys/mythril"; + license = licenses.mit; + }; +} diff --git a/packages/python-modules/pre-commit-2200/default.nix b/packages/python-modules/pre-commit-2200/default.nix new file mode 100644 index 00000000..c748ed7d --- /dev/null +++ b/packages/python-modules/pre-commit-2200/default.nix @@ -0,0 +1,169 @@ +{ + lib, + python3Packages, + fetchFromGitHub, + # tests + cargo, + dotnet-sdk, + git, + go, + libiconv, + nodejs, + virtualenv_fixed, +}: +with python3Packages; + buildPythonPackage rec { + pname = "pre-commit"; + version = "2.20.0"; + format = "setuptools"; + + disabled = pythonOlder "3.6"; + + src = fetchFromGitHub { + owner = "pre-commit"; + repo = "pre-commit"; + rev = "refs/tags/v${version}"; + sha256 = "sha256-+JrnJz+wFbzVw9ysPX85DDE6suF3VU7gQZdp66x5TKY="; + }; + + patches = [ + ./languages-use-the-hardcoded-path-to-python-binaries.patch + ./hook-tmpl.patch + ]; + + propagatedBuildInputs = + [ + cfgv + identify + nodeenv + pyyaml + toml + virtualenv_fixed + ] + ++ lib.optional (pythonOlder "3.8") [ + importlib-metadata + ] + ++ lib.optional (pythonOlder "3.7") [ + importlib-resources + ]; + + checkInputs = [ + cargo + dotnet-sdk + git + go + nodejs + pytest-env + pytest-xdist + pytestCheckHook + re-assert + ]; + + buildInputs = [ + # Required for rust test on x86_64-darwin + libiconv + ]; + + nativeBuildInputs = checkInputs; + + doCheck = true; + + postPatch = '' + substituteInPlace pre_commit/resources/hook-tmpl \ + --subst-var-by pre-commit $out + substituteInPlace pre_commit/languages/python.py \ + --subst-var-by virtualenv ${virtualenv_fixed} + substituteInPlace pre_commit/languages/node.py \ + --subst-var-by nodeenv ${nodeenv} + + patchShebangs pre_commit/resources/hook-tmpl + ''; + + preCheck = '' + export GIT_AUTHOR_NAME=test GIT_COMMITTER_NAME=test \ + GIT_AUTHOR_EMAIL=test@example.com GIT_COMMITTER_EMAIL=test@example.com \ + VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 LANG=en_US.UTF-8 + + git init -b master + + export HOME=$(mktemp -d) + + python -m venv --system-site-packages venv + source "$PWD/venv/bin/activate" + #$out/bin/pre-commit install + python setup.py develop + ''; + + postCheck = '' + deactivate + ''; + + disabledTests = [ + # ERROR: The install method you used for conda--probably either `pip install conda` + # or `easy_install conda`--is not compatible with using conda as an application. + "test_conda_" + "test_local_conda_" + + # /build/pytest-of-nixbld/pytest-0/test_install_ruby_with_version0/rbenv-2.7.2/libexec/rbenv-init: + # /usr/bin/env: bad interpreter: No such file or directory + "ruby" + + # network + "test_additional_dependencies_roll_forward" + "test_additional_golang_dependencies_installed" + "test_additional_node_dependencies_installed" + "test_additional_rust_cli_dependencies_installed" + "test_additional_rust_lib_dependencies_installed" + "test_dart_hook" + "test_dotnet_hook" + "test_golang_hook" + "test_golang_hook_still_works_when_gobin_is_set" + "test_installs_without_links_outside_env" + "test_local_dart_additional_dependencies" + "test_local_golang_additional_dependencies" + "test_local_lua_additional_dependencies" + "test_local_perl_additional_dependencies" + "test_local_rust_additional_dependencies" + "test_lua_hook" + "test_perl_hook" + "test_r_hook" + "test_r_inline_hook" + "test_r_local_with_additional_dependencies_hook" + "test_r_with_additional_dependencies_hook" + "test_run_a_node_hook_default_version" + "test_run_versioned_node_hook" + + # python2, no explanation needed + "python2" + "test_switch_language_versions_doesnt_clobber" + + # docker + "test_run_a_docker_hook" + + # i don't know why these fail + "test_install_existing_hooks_no_overwrite" + "test_installed_from_venv" + "test_uninstall_restores_legacy_hooks" + "test_healthy_system_node" + "test_get_conflicted_files_in_submodule" + "test_is_in_merge_conflict_submodule" + "test_submodule_does_not_discard_changes" + "test_sub_staged" + "test_submodule_does_not_discard_changes_recurse" + "test_sub_nothing_unstaged" + "test_sub_something_unstaged" + "test_golang_with_recursive_submodule" + "test_install_in_submodule_and_run" + ]; + + pythonImportsCheck = [ + "pre_commit" + ]; + + meta = with lib; { + description = "A framework for managing and maintaining multi-language pre-commit hooks"; + homepage = "https://pre-commit.com/"; + license = licenses.mit; + maintainers = with maintainers; [borisbabic]; + }; + } diff --git a/packages/python-modules/pre-commit-2200/hook-tmpl.patch b/packages/python-modules/pre-commit-2200/hook-tmpl.patch new file mode 100644 index 00000000..124ff253 --- /dev/null +++ b/packages/python-modules/pre-commit-2200/hook-tmpl.patch @@ -0,0 +1,15 @@ +diff --git a/pre_commit/resources/hook-tmpl b/pre_commit/resources/hook-tmpl +index 53d29f9..66a8ad3 100755 +--- a/pre_commit/resources/hook-tmpl ++++ b/pre_commit/resources/hook-tmpl +@@ -10,9 +10,7 @@ ARGS=(hook-impl) + HERE="$(cd "$(dirname "$0")" && pwd)" + ARGS+=(--hook-dir "$HERE" -- "$@") + +-if [ -x "$INSTALL_PYTHON" ]; then +- exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}" +-elif command -v pre-commit > /dev/null; then ++if command -v pre-commit > /dev/null; then + exec pre-commit "${ARGS[@]}" + else + echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2 diff --git a/packages/python-modules/pre-commit-2200/languages-use-the-hardcoded-path-to-python-binaries.patch b/packages/python-modules/pre-commit-2200/languages-use-the-hardcoded-path-to-python-binaries.patch new file mode 100644 index 00000000..6d274aae --- /dev/null +++ b/packages/python-modules/pre-commit-2200/languages-use-the-hardcoded-path-to-python-binaries.patch @@ -0,0 +1,26 @@ +diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py +index 26f4919..4885ec1 100644 +--- a/pre_commit/languages/node.py ++++ b/pre_commit/languages/node.py +@@ -82,7 +82,7 @@ def install_environment( + envdir = fr'\\?\{os.path.normpath(envdir)}' + with clean_path_on_failure(envdir): + cmd = [ +- sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir, ++ '@nodeenv@/bin/nodeenv', '--prebuilt', '--clean-src', envdir, + ] + if version != C.DEFAULT: + cmd.extend(['-n', version]) +diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py +index 43b7280..f0f2338 100644 +--- a/pre_commit/languages/python.py ++++ b/pre_commit/languages/python.py +@@ -192,7 +192,7 @@ def install_environment( + additional_dependencies: Sequence[str], + ) -> None: + envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version)) +- venv_cmd = [sys.executable, '-mvirtualenv', envdir] ++ venv_cmd = ['@virtualenv@/bin/virtualenv', envdir] + python = norm_version(version) + if python is not None: + venv_cmd.extend(('-p', python)) diff --git a/packages/python-modules/py-ecc/default.nix b/packages/python-modules/py-ecc/default.nix deleted file mode 100644 index 6283104e..00000000 --- a/packages/python-modules/py-ecc/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ - lib, - buildPythonPackage, - fetchFromGitHub, - cached-property, - eth-typing, - eth-utils, - mypy-extensions, - pytestCheckHook, - pythonOlder, -}: -buildPythonPackage rec { - pname = "py-ecc"; - version = "6.0.0"; - disabled = pythonOlder "3.6"; - - src = fetchFromGitHub { - owner = "ethereum"; - repo = "py_ecc"; - rev = "v${version}"; - sha256 = "sha256-638otYA3e/Ld4mcM69yrqHQnGoK/Sfl/UA9FWnjgO/U="; - }; - - propagatedBuildInputs = [ - cached-property - eth-typing - eth-utils - mypy-extensions - ]; - - checkInputs = [ - pytestCheckHook - ]; - - pythonImportsCheck = ["py_ecc"]; - - meta = with lib; { - description = "ECC pairing and bn_128 and bls12_381 curve operations"; - homepage = "https://github.com/ethereum/py_ecc"; - license = licenses.mit; - maintainers = with maintainers; [SuperSandro2000]; - }; -} diff --git a/packages/python-modules/py-evm/default.nix b/packages/python-modules/py-evm/default.nix new file mode 100644 index 00000000..b34f194a --- /dev/null +++ b/packages/python-modules/py-evm/default.nix @@ -0,0 +1,32 @@ +{ + lib, + python3Packages, + py-ecc-410, + rlp-201, + pyethash, + eth-keys-034, + eth-bloom-104, + trie, +}: +python3Packages.buildPythonPackage rec { + pname = "py-evm"; + version = "0.5.0a1"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-NbEv1GrxmLbqPC54NAExGS3L6OMw2cYh26CTnLnckQM="; + }; + + propagatedBuildInputs = with python3Packages; [ + setuptools + lru-dict + py-ecc-410 + rlp-201 + pyethash + eth-keys-034 + eth-bloom-104 + trie + ]; + + doCheck = false; +} diff --git a/packages/python-modules/py-flags/default.nix b/packages/python-modules/py-flags/default.nix new file mode 100644 index 00000000..8af37639 --- /dev/null +++ b/packages/python-modules/py-flags/default.nix @@ -0,0 +1,18 @@ +{ + lib, + python3Packages, +}: +python3Packages.buildPythonPackage rec { + pname = "py-flags"; + version = "1.1.4"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-tqoYxz6OUybUVnkO+fXosoqPcrx2+GNqUZiN/KaQ900="; + }; + + propagatedBuildInputs = with python3Packages; [ + setuptools + dictionaries + ]; +} diff --git a/packages/python-modules/py-solc-x/default.nix b/packages/python-modules/py-solc-x/default.nix new file mode 100644 index 00000000..4e798d19 --- /dev/null +++ b/packages/python-modules/py-solc-x/default.nix @@ -0,0 +1,27 @@ +{ + lib, + python3Packages, + pandoc, +}: +python3Packages.buildPythonPackage rec { + pname = "py-solc-x"; + version = "1.1.1"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-2LC9KwT0fP9ukhgXOdnpTkGy1i8FaQB2HHl/pbq8drY="; + }; + + preConfigure = '' + substituteInPlace setup.py --replace \"setuptools-markdown\" "" + ''; + + propagatedBuildInputs = with python3Packages; [ + pandoc + setuptools + requests + semantic-version + ]; + + doCheck = false; +} diff --git a/packages/python-modules/pyethash/default.nix b/packages/python-modules/pyethash/default.nix new file mode 100644 index 00000000..d2b334b8 --- /dev/null +++ b/packages/python-modules/pyethash/default.nix @@ -0,0 +1,17 @@ +{ + lib, + python3Packages, +}: +python3Packages.buildPythonPackage rec { + pname = "pyethash"; + version = "0.1.27"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-/2YxnOJrnXffH2EJQmNNrJdC4hbywnsFHAosLeycKBg="; + }; + + propagatedBuildInputs = with python3Packages; [ + setuptools + ]; +} diff --git a/packages/python-modules/trie/default.nix b/packages/python-modules/trie/default.nix new file mode 100644 index 00000000..60ce675e --- /dev/null +++ b/packages/python-modules/trie/default.nix @@ -0,0 +1,26 @@ +{ + lib, + python3Packages, + typing-extensions-31002, + eth-utils-110, + rlp-201, + hexbytes-023, +}: +python3Packages.buildPythonPackage rec { + pname = "trie"; + version = "2.0.0a5"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-Y4X1QWWlfpluDdvjruaHeDVL5YzKGzYj6KmhpWaAxFs="; + }; + + propagatedBuildInputs = with python3Packages; [ + setuptools + sortedcontainers + hexbytes-023 + typing-extensions-31002 + eth-utils-110 + rlp-201 + ]; +} diff --git a/packages/python-modules/z3-solver/default.nix b/packages/python-modules/z3-solver/default.nix new file mode 100644 index 00000000..2db816cd --- /dev/null +++ b/packages/python-modules/z3-solver/default.nix @@ -0,0 +1,24 @@ +{ + lib, + pkgs, + python3Packages, + jinja2_fixed, +}: +python3Packages.buildPythonPackage rec { + pname = "z3-solver"; + version = "4.8.5.0"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-8naAICUcmPspvmjAWxySaUtgHea0uDUZSS5WutuF7mI="; + }; + + propagatedBuildInputs = with python3Packages; [setuptools jinja2_fixed]; + + setupPyBuildFlags = [ + "--plat-name x86_64-linux" + ]; + + # tests require other angr related components + doCheck = false; +} diff --git a/shell.nix b/shell.nix index 1ea646f9..74d3ed53 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,7 @@ -{pkgs}: +{ + pkgs, + self', +}: with pkgs; let example-container = nix2container.buildImage @@ -9,6 +12,7 @@ with pkgs; let entrypoint = ["${pkgs.lib.getExe pkgs.figlet}" "MCL"]; }; }; + python-modules = self'.legacyPackages.python-modules; in mkShell { packages = @@ -29,8 +33,14 @@ in metacraft-labs.go-ethereum-capella + # Mythril + metacraft-labs.mythril + # Test nix2container example-container.copyToDockerDaemon + + # For cachix caching + python3Packages.py-ecc ] ++ lib.optionals (stdenv.hostPlatform.isx86) [ metacraft-labs.rapidsnark @@ -48,7 +58,7 @@ in # Disabled until elrond-go can build with Go >= 1.19 # Elrond - metacraft-labs.cryptography36 + python-modules.cryptography36 # metacraft-labs.erdpy # metacraft-labs.elrond-go # metacraft-labs.elrond-proxy-go @@ -61,9 +71,6 @@ in # Ethereum metacraft-labs.nimbus - # py-ecc - metacraft-labs.py-ecc - # corepack-shims metacraft-labs.corepack-shims