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

Add Nix support #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

# Dependency directories (remove the comment below to include it)
# vendor/
*node_modules/

# PyCharm project dir
.idea/

*node_modules/
# Build results
result
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.

128 changes: 128 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
description = "Medusa smart-contract fuzzer";

inputs = {
nixpkgs.url = "nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
pyCommon = {
format = "pyproject";
nativeBuildInputs = with pkgs.python39Packages; [ pythonRelaxDepsHook ];
pythonRelaxDeps = true;
doCheck = false;
};
in
rec {

packages = rec {

solc-select = pkgs.python39Packages.buildPythonPackage (pyCommon // {
pname = "solc-select";
version = "1.0.3";
src = builtins.fetchGit {
url = "git+ssh://[email protected]/crytic/solc-select";
rev = "97f160611c39d46e27d6f44a5a61344e6218d584";
};
propagatedBuildInputs = with pkgs.python39Packages; [
packaging
setuptools
pycryptodome
];
});
Comment on lines +24 to +36
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-line addition of nix support to solc-select & other packages that don't feature a flake.nix file yet. If/when they do, these pieces of config can move into their respective repos & can be removed from this project.
In the meantime, they allow medusa to depend on a specific commit of crytic-compile, etc


crytic-compile = pkgs.python39Packages.buildPythonPackage (pyCommon // rec {
pname = "crytic-compile";
version = "0.3.1";
src = builtins.fetchGit {
url = "git+ssh://[email protected]/crytic/crytic-compile";
rev = "10104f33f593ab82ba5780a5fe8dd26385acd1c1";
};
propagatedBuildInputs = with pkgs.python39Packages; [
cbor2
pycryptodome
setuptools
packages.solc-select
];
});

slither = pkgs.python39Packages.buildPythonPackage (pyCommon // rec {
pname = "slither";
version = "0.9.3";
format = "pyproject";
src = builtins.fetchGit {
url = "git+ssh://[email protected]/crytic/slither";
rev = "e6b8af882c6419a9119bec5f4cfff93985a92f4e";
};
nativeBuildInputs = with pkgs.python39Packages; [ pythonRelaxDepsHook ];
pythonRelaxDeps = true;
doCheck = false;
propagatedBuildInputs = with pkgs.python39Packages; [
packaging
prettytable
pycryptodome
packages.crytic-compile
];
postPatch = ''
echo "web3 dependency depends on ipfs which is bugged, removing it from the listed deps"
sed -i 's/"web3>=6.0.0",//' setup.py
'';
});

medusa = pkgs.buildGoModule {
pname = "medusa";
version = "0.1.0"; # from cmd/root.go
src = ./.;
vendorSha256 = "sha256-odBzty8wgFfdSF18D15jWtUNeQPJ7bkt9k5dx+8EFb4=";
nativeBuildInputs = [
packages.crytic-compile
pkgs.solc
pkgs.nodejs
];
doCheck = false; # tests require `npm install` which can't run in hermetic build env
};

default = medusa;

};

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

devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
packages.medusa
bashInteractive
# runtime dependencies
packages.crytic-compile
packages.slither
solc
# test dependencies
nodejs
# go development
go
gotools
go-tools
gopls
go-outline
gocode
gopkgs
gocode-gomod
godef
golint
];
};
};

}
);
}