diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..086ce9bd0 --- /dev/null +++ b/.envrc @@ -0,0 +1,16 @@ +NBS_ONLY_LOAD_ENV_VARS=1 source env.sh + +if command -v nix > /dev/null +then + export NIMBUS_NIX_ENV=1 + + cd nix + # watch_file tells direnv that changes to any of the watched files + # should trigger a re-evalution of the environment + watch_file flake.nix + watch_file flake.lock + watch_file shell.nix + + mkdir -p .flake-profiles + eval "$(nix print-dev-env --profile ".flake-profiles/profile")" +fi \ No newline at end of file diff --git a/nix/.gitignore b/nix/.gitignore new file mode 100644 index 000000000..0500e4799 --- /dev/null +++ b/nix/.gitignore @@ -0,0 +1,2 @@ +# Local file unique for each user +.flake-profiles/ \ No newline at end of file diff --git a/nix/flake.lock b/nix/flake.lock new file mode 100644 index 000000000..788369f5c --- /dev/null +++ b/nix/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1659446231, + "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-21.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/flake.nix b/nix/flake.nix new file mode 100644 index 000000000..d9f8a6c07 --- /dev/null +++ b/nix/flake.nix @@ -0,0 +1,15 @@ +{ + description = "nimbus-eth2"; + + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11; + flake-utils.url = github:numtide/flake-utils; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.simpleFlake { + inherit self nixpkgs; + name = "nimbus-eth2"; + shell = ./shell.nix; + }; +} \ No newline at end of file diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 000000000..80fedbcd2 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,23 @@ +{pkgs ? import {}}: +with pkgs; + mkShell { + buildInputs = + [ + figlet + git + gnumake + rocksdb + ] + ++ lib.optionals (!stdenv.isDarwin) [ + lsb-release + ]; + + shellHook = '' + # By default, the Nix wrapper scripts for executing the system compilers + # will erase `-march=native` because this introduces impurity in the build. + # For the purposes of compiling Nimbus, this behavior is not desired: + export NIX_ENFORCE_NO_NATIVE=0 + + figlet "Welcome to Nimbus-eth1" + ''; + }