Skip to content

Commit

Permalink
Simplify flake (#544)
Browse files Browse the repository at this point in the history
* add direnv config file

* use crytic.nix

* read version from cmd/root.go

* upgrade to version 1.0.0

---------

Co-authored-by: Anish Naik <[email protected]>
  • Loading branch information
bohendo and anishnaik authored Feb 2, 2025
1 parent f61e8b4 commit c14c9ae
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 120 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Loading devShell from $(basename $(pwd))/flake.nix"
use flake .
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ medusa
# Medusa docs
docs/book

# direnv cache
.direnv/

# Build results
result
92 changes: 81 additions & 11 deletions flake.lock

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

160 changes: 51 additions & 109 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,122 +3,64 @@

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

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.python3Packages; [ pythonRelaxDepsHook ];
pythonRelaxDeps = true;
doCheck = false;
};
in
rec {

packages = rec {

solc-select = pkgs.python3Packages.buildPythonPackage (pyCommon // {
pname = "solc-select";
version = "1.0.4";
src = builtins.fetchGit {
url = "https://github.com/crytic/solc-select.git";
rev = "8072a3394bdc960c0f652fb72e928a7eae3631da";
};
propagatedBuildInputs = with pkgs.python3Packages; [
packaging
setuptools
pycryptodome
];
});

crytic-compile = pkgs.python3Packages.buildPythonPackage (pyCommon // rec {
pname = "crytic-compile";
version = "0.3.7";
src = builtins.fetchGit {
url = "https://github.com/crytic/crytic-compile.git";
rev = "20df04f37af723eaa7fa56dc2c80169776f3bc4d";
};
propagatedBuildInputs = with pkgs.python3Packages; [
cbor2
pycryptodome
setuptools
packages.solc-select
];
});

slither = pkgs.python3Packages.buildPythonPackage (pyCommon // rec {
pname = "slither";
version = "0.10.4";
format = "pyproject";
src = builtins.fetchGit {
url = "https://github.com/crytic/slither.git";
rev = "aeeb2d368802844733671e35200b30b5f5bdcf5c";
};
nativeBuildInputs = with pkgs.python3Packages; [ pythonRelaxDepsHook ];
pythonRelaxDeps = true;
doCheck = false;
propagatedBuildInputs = with pkgs.python3Packages; [
packaging
prettytable
pycryptodome
packages.crytic-compile
web3
];
});

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

default = medusa;
outputs = inputs: with inputs;
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
in rec {

packages = {
medusa = pkgs.buildGoModule {
pname = "medusa";
version = 1.0.0;
src = ./.;
vendorHash = "sha256-12Xkg5dzA83HQ2gMngXoLgu1c9KGSL6ly5Qz/o8U++8=";
nativeBuildInputs = [
crytic.packages.${system}.crytic-compile
crytic.packages.${system}.slither
pkgs.solc
pkgs.nodejs
];
doCheck = false; # tests require `npm install` which can't run in hermetic build env
};
default = packages.medusa;
};

apps = {
default = {
type = "app";
program = "${self.packages.${system}.medusa}/bin/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
gopkgs
gocode-gomod
godef
golint
];
};
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
packages.medusa
bashInteractive
# runtime dependencies
crytic.packages.${system}.crytic-compile
crytic.packages.${system}.slither
solc
# test dependencies
nodejs
# go development
go
gotools
go-tools
gopls
go-outline
gopkgs
gocode-gomod
godef
golint
];
};
};

}
);
}
);
}

0 comments on commit c14c9ae

Please sign in to comment.