Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

build: add nix flake for hermetic dev environments #1442

Open
wants to merge 3 commits into
base: main
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ node_modules
.next
next-env.d.ts
.env
.envrc
out

# docker test
Expand All @@ -226,3 +227,5 @@ out

# integration testing coverage
coverage-test-unit-cover.txt

.direnv/
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -97,6 +99,34 @@ 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
```

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.
Expand Down
111 changes: 111 additions & 0 deletions flake.lock

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

35 changes: 35 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
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 = [
gnumake
go
jq
foundry-bin
];


shellHook = ''
export PS1="[dev] $PS1"
'';
};
}
);
}
Loading