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

Justify + Nixify #339

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.nix
*.pyc
.idea/
__pycache__/
Expand Down
42 changes: 42 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

161 changes: 161 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
description = "Cross-platform smart-contract compiler";

# Flake inputs
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

# Flake outputs
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
version = "0.2.5";
in
rec {

# Provide packages for selected system types.
packages = {

default = packages.crytic-compile;

crytic-compile = pkgs.callPackage pkgs.python38Packages.buildPythonPackage rec {
pname = "crytic-compile";
inherit version;
format = "pyproject";
src = ./.;
propagatedBuildInputs = with pkgs.python38Packages; [
cbor2
pycryptodome
setuptools
wheel
];
pythonRelaxDeps = true;
doCheck = false;
};

# Custom derivations to set linters to specific versions
black = pkgs.callPackage pkgs.python38Packages.buildPythonPackage rec {
pname = "black";
version = "22.3.0";
src = pkgs.python38Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk=";
};
doCheck = false;
propagatedBuildInputs = with pkgs.python38Packages; [
click
mypy-extensions
pathspec
platformdirs
setuptools_scm
tomli
typing-extensions
];
};

darglint = pkgs.callPackage pkgs.python38Packages.buildPythonPackage rec {
pname = "darglint";
version = "1.8.0";
src = pkgs.python38Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-qmBe9HgXptFHl9MrOQRm7atiF2jqTKXMDzxU9tjcrsg=";
};
doCheck = false;
};

mypy = pkgs.python39.withPackages(ps: with ps; [
types-setuptools
setuptools
(pkgs.python39Packages.buildPythonPackage rec {
pname = "mypy";
version = "0.942";
src = pkgs.python39Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-F+RGSf7JLp+CECtIo797SlUQrQzSL6IaEEgmtdtJA+I=";
};
doCheck = false;
propagatedBuildInputs = with pkgs.python39Packages; [
mypy-extensions
tomli
typing-extensions
];
})
]);

pylint = pkgs.callPackage pkgs.python39Packages.buildPythonPackage rec {
pname = "pylint";
version = "2.13.4";
src = pkgs.python39Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-fMbQxPYd/0QPnti2V/Ts1hXc/jU0WVPrex3HSv6QHXo=";
};
doCheck = false;
propagatedBuildInputs = with pkgs.python39Packages; [
isort
tomli
mccabe
platformdirs
dill
(pkgs.python39Packages.buildPythonPackage rec {
pname = "astroid";
version = "2.11.7";
src = pkgs.python39Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-uyRhXHf0g3xwdmnRaQczE3SuipZGUKZpmdo/XKaNyUY=";
};
doCheck = false;
propagatedBuildInputs = with pkgs.python39Packages; [
lazy-object-proxy
typing-extensions
wrapt
];
})
];
};

};

apps = {
default = {
type = "app";
program = "${self.packages.${system}.crytic-compile}/bin/crytic-compile";
};
};

# Development environment output
devShells = {
default = pkgs.mkShell {
# The Nix packages provided in the environment
src = ./crytic_compile;
packages = with pkgs; [
packages.black
packages.darglint
packages.mypy
packages.pylint
# not-reloadable version of crytic-compile (not ideal!)
packages.crytic-compile
# # hot-reloadable version of crytic-compile (hopefully!)
# # currently broken bc crytic_compile/platform clobbers the platform module of the std lib
# (pkgs.python38Packages.buildPythonPackage rec {
# name = "crytic-compile";
# src = ./crytic_compile;
# propagatedBuildInputs = with pkgs.python38Packages; [
# cbor2
# pycryptodome
# setuptools
# ];
# })
python38
virtualenv
python38Packages.pip
python38Packages.pycryptodome
python38Packages.setuptools
];
};
};

});
}
78 changes: 78 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

dev:
nix develop

build:
nix build .#crytic-compile

install:
nix-env -e $(nix-env -q | grep "crytic-compile")
nix-env -i ./result


lint: black darglint mypy pylint

black:
@echo
nix develop --command black --version
nix develop --command black crytic_compile --config pyproject.toml

darglint:
@echo
nix develop --command darglint --version
nix develop --command darglint crytic_compile

mypy:
@echo
nix develop --command mypy --version
nix develop --command mypy crytic_compile

pylint:
@echo
nix develop --command pylint --version
nix develop --command pylint crytic_compile --rcfile pyproject.toml


test: test-hardhat test-monorepo

test-brownie:
echo "brownie tests not supported yet"

test-buidler:
echo "buidler tests not supported yet"

test-dapp:
echo "dapp tests not supported yet"

test-embark:
echo "embark tests not supported yet"

test-etherlime:
echo "etherlime tests not supported yet"

test-etherscan:
echo "etherscan tests not supported yet"

test-foundry:
echo "foundry tests not supported yet"

test-hardhat:
@echo
nix develop --command bash scripts/ci_test_hardhat.sh

test-monorepo:
@echo
nix develop --command bash scripts/ci_test_monorepo.sh

test-solc:
echo "solc tests not supported yet"

test-standard:
echo "standard tests not supported yet"

test-truffle:
echo "truffle tests not supported yet"

test-waffle:
echo "waffle tests not supported yet"

54 changes: 54 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{ pkgs ? import <nixpkgs> {} }:

pkgs.python38Packages.buildPythonPackage rec {
name = "crytic-compile";
src = ./crytic_compile;
propagatedBuildInputs = with pkgs.python38Packages; [ pycryptodome setuptools ];
}

# let
# mach-nix = import (builtins.fetchGit {
# url = "https://github.com/DavHau/mach-nix";
# ref = "refs/tags/3.5.0";
# }) {};
# in
# mach-nix.mkPythonShell {
# requirements = ''
# pycryptodome
# setuptools
# '';
# }

# pkgs.mkShell {
# python = pkgs.python38.withPackages (ps: with ps; [
# pip
# ]);
#
# shellHook = ''
# echo hello crytic-compile shell
# '';
#
# packages = [
#
# # (pkgs.python38Packages.buildPythonPackage rec {
# # name = "crytic-compile";
# # src = ./crytic_compile;
# # propagatedBuildInputs = with pkgs.python38Packages; [ pycryptodome setuptools ];
# # })
#
# # (pkgs.python38Packages.buildPythonPackage rec {
# # pname = "crytic-compile";
# # version = "0.2.5";
# # format = "setuptools";
# # src = ./.;
# # propagatedBuildInputs = with pkgs.python38Packages; [ pycryptodome setuptools ];
# # doCheck = false;
# # pythonRelaxDeps = true;
# # })
#
# (pkgs.python38.withPackages (ps: with ps; [ pip ]))
# pkgs.black
# pkgs.pylint
# pkgs.solc-select
# ];
# }