From cd96aa603e03a7daae84f737c638d1545dd2b9bc Mon Sep 17 00:00:00 2001 From: corduroy <130501039+corduroybera@users.noreply.github.com> Date: Thu, 18 Jan 2024 01:17:38 -0500 Subject: [PATCH 1/3] devenv --- .gitignore | 3 ++ flake.lock | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 34 ++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index dcff134f0..0304c0f03 100644 --- a/.gitignore +++ b/.gitignore @@ -216,6 +216,7 @@ node_modules .next next-env.d.ts .env +.envrc out # docker test @@ -226,3 +227,5 @@ out # integration testing coverage coverage-test-unit-cover.txt + +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..cae6e7e43 --- /dev/null +++ b/flake.lock @@ -0,0 +1,111 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "foundry": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1705309865, + "narHash": "sha256-HkTSsjmR3DE1xKr1M0bBWKyTl4f616166Przd2mwNxw=", + "owner": "shazow", + "repo": "foundry.nix", + "rev": "883243b30a4b8dbb1b515b79b750e2caf7df1a79", + "type": "github" + }, + "original": { + "owner": "shazow", + "ref": "monthly", + "repo": "foundry.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1666753130, + "narHash": "sha256-Wff1dGPFSneXJLI2c0kkdWTgxnQ416KE6X4KnFkgPYQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f540aeda6f677354f1e7144ab04352f61aaa0118", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1705466837, + "narHash": "sha256-iYVxjZqKd9Si4wuf5GO9aNKxqAn9P3bNN38vflIooHY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "757637581797f148c50977b6127147c5d298f9e9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "foundry": "foundry", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..e45d6debd --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "An EVM framework for Cosmos"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + foundry.url = "github:shazow/foundry.nix/monthly"; + }; + + + outputs = { self, nixpkgs, flake-utils, foundry, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ foundry.overlay ]; + }; + in { + devShell = with pkgs; mkShell { + name = "polaris-dev"; + nativeBuildInputs = [ + go + jq + foundry-bin + ]; + + + shellHook = '' + export PS1="[dev] $PS1" + ''; + }; + } + ); +} \ No newline at end of file From 0f57689c5c2f22ff425483ad9daef01b19c4b8f7 Mon Sep 17 00:00:00 2001 From: corduroy <130501039+corduroybera@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:53:59 -0500 Subject: [PATCH 2/3] build: add nix flake for hermetic dev environments --- README.md | 23 +++++++++++++++++++++++ flake.nix | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cde6241f..1029c4b6b 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ If you want to help contribute to the framework, check out the [Framework Specs] ## Build & Test +### Standard Development Environment + [Golang 1.20+](https://go.dev/doc/install) and [Foundry](https://book.getfoundry.sh/getting-started/installation) are required for Polaris. 1. Install [go 1.21+ from the official site](https://go.dev/dl/) or the method of your choice. Ensure that your `GOPATH` and `GOBIN` environment variables are properly set up by using the following commands: @@ -97,6 +99,27 @@ If you want to help contribute to the framework, check out the [Framework Specs] make start ``` +### Nix Flakes Development Environment + +Polaris also supports reproducible development environments using [Nix](https://nixos.org/) with [Flakes](https://nixos.wiki/wiki/Flakes). + +1. Install [Nix](https://github.com/DeterminateSystems/nix-installer). We recommend the Determinate Systems installer to automatically configure your system with Flakes turned on. +2. Clone, Setup and Test: + + ```sh + cd $HOME + git clone https://github.com/berachain/polaris + cd polaris + git checkout main + nix develop + make test-unit + ``` +3. Start a local development network: + + ```sh + make start + ``` + ## 🚧 WARNING: UNDER CONSTRUCTION 🚧 This project is work in progress and subject to frequent changes as we are still working on wiring up the final system. diff --git a/flake.nix b/flake.nix index e45d6debd..64ac8061a 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,7 @@ devShell = with pkgs; mkShell { name = "polaris-dev"; nativeBuildInputs = [ + gnumake go jq foundry-bin @@ -31,4 +32,4 @@ }; } ); -} \ No newline at end of file +} From 519f539c6fd9b375a532bd7f782535e21df50909 Mon Sep 17 00:00:00 2001 From: corduroy <130501039+corduroybera@users.noreply.github.com> Date: Thu, 18 Jan 2024 19:04:23 -0500 Subject: [PATCH 3/3] additional info --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 1029c4b6b..38b8288ea 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ If you want to help contribute to the framework, check out the [Framework Specs] Polaris also supports reproducible development environments using [Nix](https://nixos.org/) with [Flakes](https://nixos.wiki/wiki/Flakes). 1. Install [Nix](https://github.com/DeterminateSystems/nix-installer). We recommend the Determinate Systems installer to automatically configure your system with Flakes turned on. + 2. Clone, Setup and Test: ```sh @@ -114,12 +115,18 @@ Polaris also supports reproducible development environments using [Nix](https:// nix develop make test-unit ``` + 3. Start a local development network: ```sh make start ``` +Note: If you would prefer to automatically load this environment everytime you enter the Polaris directory, you can use `direnv`: + +- Create a `.envrc` file with the line `use flake` +- Run `direnv allow` + ## 🚧 WARNING: UNDER CONSTRUCTION 🚧 This project is work in progress and subject to frequent changes as we are still working on wiring up the final system.