diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..2f9c8df2 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +echo "Loading devShell from $(basename $(pwd))/flake.nix" +use flake . diff --git a/.gitignore b/.gitignore index 17d4923a..e9f9d788 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,8 @@ medusa # Medusa docs docs/book +# direnv cache +.direnv/ + # Build results result diff --git a/flake.lock b/flake.lock index d853ed8a..b4a980f7 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,41 @@ { "nodes": { - "flake-utils": { + "crytic": { "inputs": { - "systems": "systems" + "nixpkgs": "nixpkgs", + "utils": "utils" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "lastModified": 1737144574, + "narHash": "sha256-gtDiJT/kgZYTYGnDI3yGDBYV07zCcdtTV2mharK7I8w=", + "owner": "crytic", + "repo": "crytic.nix", + "rev": "d124ffa7897180de5a28127b6b5b13fd5ba2392a", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "crytic", + "repo": "crytic.nix", "type": "github" } }, "nixpkgs": { + "locked": { + "lastModified": 1726159525, + "narHash": "sha256-YQDGrIjCoNkcQAov8PznFVH+WtgeRLIAHfa3AEEPeQA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "856556b164d56f63434d2dd3e954f00f4b3a075f", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "856556b164d56f63434d2dd3e954f00f4b3a075f", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1735669367, "narHash": "sha256-tfYRbFhMOnYaM4ippqqid3BaLOXoFNdImrfBfCp4zn0=", @@ -35,8 +52,9 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "crytic": "crytic", + "nixpkgs": "nixpkgs_2", + "utils": "utils_2" } }, "systems": { @@ -53,6 +71,58 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + } + }, + "utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index fd31f4de..ac5b157d 100644 --- a/flake.nix +++ b/flake.nix @@ -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 + ]; }; + }; - } - ); + } + ); }