diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..28f1d9b --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +use_nix +eval "$(lorri direnv)" diff --git a/.gitignore b/.gitignore index dee6ee1..0f23d8a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,7 @@ .cargo # The cache for chain data in container -.local \ No newline at end of file +.local + +# direnv cache +.direnv diff --git a/README.md b/README.md index 3384534..e088f0e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ A fresh FRAME-based [Substrate](https://www.substrate.io/) node, ready for hacki Follow the steps below to get started with the Node Template, or get it up and running right from your browser in just a few clicks using [Playground](https://playground.substrate.dev/) :hammer_and_wrench: +### Using Nix + +Install [nix](https://nixos.org/) and optionally [direnv](https://github.com/direnv/direnv) and [lorri](https://github.com/target/lorri) for a fully plug +and play experience for setting up the development environment. To get all the correct dependencies activate direnv `direnv allow` and lorri `lorri shell`. + ### Rust Setup First, complete the [basic Rust setup instructions](./doc/rust-setup.md). diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..bc289fc --- /dev/null +++ b/shell.nix @@ -0,0 +1,33 @@ +let + mozillaOverlay = + import (builtins.fetchGit { + url = "https://github.com/mozilla/nixpkgs-mozilla.git"; + rev = "57c8084c7ef41366993909c20491e359bbb90f54"; + }); + pinned = builtins.fetchGit { + # Descriptive name to make the store path easier to identify + name = "nixos-unstable-2020-04-26"; + url = "https://github.com/nixos/nixpkgs/"; + # Commit hash for nixos-unstable as of 2020-04-26 + # `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable` + ref = "refs/heads/nixos-unstable"; + rev = "1fe6ed37fd9beb92afe90671c0c2a662a03463dd"; + }; + nixpkgs = import pinned { overlays = [ mozillaOverlay ]; }; + rust-nightly = with nixpkgs; ((rustChannelOf { date = "2021-03-01"; channel = "nightly"; }).rust.override { + targets = [ "wasm32-unknown-unknown" ]; + }); +in +with nixpkgs; pkgs.mkShell { + buildInputs = [ + clang + pkg-config + rust-nightly + ] ++ stdenv.lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + ]; + + LIBCLANG_PATH = "${llvmPackages.libclang}/lib"; + PROTOC = "${protobuf}/bin/protoc"; + ROCKSDB_LIB_DIR = "${rocksdb}/lib"; +}