From dcfefdb81c2e4d8512157dba3bde81b722f7633c Mon Sep 17 00:00:00 2001 From: David Millar-Durrant Date: Tue, 18 Apr 2023 13:46:08 +0100 Subject: [PATCH] Added a nix dev env for faster integration tests --- .envrc | 2 + README.md | 6 +++ flake.lock | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 29 ++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..60dc4cf21 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +use flake 'github:DavidM-D/workspaces?dir=rust' +use flake . diff --git a/README.md b/README.md index 90a11ef38..36a54d01e 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ git submodule update --init --recursive docker build . -t near/mpc-recovery ``` +alternatively if you have [nix](https://nixos.org/) and [direnv](https://direnv.net/) installed, you can set up a development environment by running: + +``` BASH +direnv allow +``` + Run tests with: ``` cargo test -p mpc-recovery diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..48a6d238d --- /dev/null +++ b/flake.lock @@ -0,0 +1,130 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1681648924, + "narHash": "sha256-pzi3HISK8+7mpEtv08Yr80wswyHKsz+RP1CROG1Qf6s=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f294325aed382b66c7a188482101b0f336d1d7db", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1681697975, + "narHash": "sha256-47DFtN5PX05eD8ObImkSu2W0hyyZ5cK1Tl9EvmW2NnU=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "ffe47b90076067ad5dc25fe739d95a463bdf3c59", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..a21d43f19 --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +# This is a simple deterministic rust development environment +# This exposes Cargo, rustfmt, rust-analyzer and clippy +# This does not allow you to build binaries using nix +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }: + + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + + # Pick what rust compiler to use + in { + devShell = pkgs.mkShell { + + # Everything in this list is added to your path + buildInputs = + with pkgs; [ + darwin.apple_sdk.frameworks.Security + protobuf + ]; + }; + }); +}