From 656665e86f685ab664ffb9f21f27e6365bcfd336 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:57:53 +0100 Subject: [PATCH] chore: remove last traces of nix (#4679) # Description ## Problem\* Resolves ## Summary\* We have a lot of tech debt from a partial removal of nix. As it's no longer in CI we cannot guarantee that the nix installation method works so we should just remove it so we can clean up the code. ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- .envrc | 20 -- .github/scripts/acvm_js-build.sh | 1 + .github/scripts/noir-wasm-build.sh | 1 + .github/scripts/noirc-abi-build.sh | 1 + .github/scripts/wasm-opt-install.sh | 2 +- .github/workflows/test-js-packages.yml | 17 +- .gitignore | 6 - .vscode/extensions.json | 1 - .vscode/settings.json | 11 - README.md | 20 -- acvm-repo/acvm_js/build.sh | 39 ++- acvm-repo/acvm_js/buildPhaseCargoCommand.sh | 42 --- acvm-repo/acvm_js/installPhase.sh | 10 - acvm-repo/acvm_js/package.json | 4 +- compiler/noirc_driver/build.rs | 3 +- compiler/wasm/README.md | 14 - default.nix | 13 - .../installation/other_install_methods.md | 160 +---------- flake.nix | 260 ------------------ package.json | 12 +- release-please-config.json | 3 +- shell.nix | 13 - tooling/debugger/build.rs | 3 +- tooling/nargo_cli/build.rs | 3 +- tooling/noirc_abi_wasm/README.md | 14 - tooling/noirc_abi_wasm/build.rs | 3 +- tooling/noirc_abi_wasm/build.sh | 39 ++- .../noirc_abi_wasm/buildPhaseCargoCommand.sh | 39 --- tooling/noirc_abi_wasm/installPhase.sh | 10 - tooling/noirc_abi_wasm/package.json | 4 +- wasm-bindgen-cli.nix | 43 --- 31 files changed, 61 insertions(+), 750 deletions(-) delete mode 100644 .envrc delete mode 100755 acvm-repo/acvm_js/buildPhaseCargoCommand.sh delete mode 100755 acvm-repo/acvm_js/installPhase.sh delete mode 100644 default.nix delete mode 100644 flake.nix delete mode 100644 shell.nix delete mode 100755 tooling/noirc_abi_wasm/buildPhaseCargoCommand.sh delete mode 100755 tooling/noirc_abi_wasm/installPhase.sh delete mode 100644 wasm-bindgen-cli.nix diff --git a/.envrc b/.envrc deleted file mode 100644 index b2f868b1898..00000000000 --- a/.envrc +++ /dev/null @@ -1,20 +0,0 @@ -# Based on https://github.com/direnv/direnv-vscode/blob/158e8302c2594cc0eaa5f8b4f0cafedd4e1c0315/.envrc - -# You can define your system-specific logic (like Git settings or GH tokens) in .envrc.local -# If that logic is usable by other people and might improve development environment, consider -# contributing it to this file! - -source_env_if_exists .envrc.local - -if [[ -z "${SKIP_NIX:-}" ]] && has nix; then - - if nix flake metadata &>/dev/null && has use_flake; then - # use flakes if possible - use flake - - else - # Otherwise fall back to pure nix - use nix - fi - -fi diff --git a/.github/scripts/acvm_js-build.sh b/.github/scripts/acvm_js-build.sh index 95bd1efc8b9..e79967e3a8f 100755 --- a/.github/scripts/acvm_js-build.sh +++ b/.github/scripts/acvm_js-build.sh @@ -2,4 +2,5 @@ set -eu .github/scripts/wasm-bindgen-install.sh +.github/scripts/wasm-opt-install.sh yarn workspace @noir-lang/acvm_js build diff --git a/.github/scripts/noir-wasm-build.sh b/.github/scripts/noir-wasm-build.sh index 48e3ad73769..6c0336ee0c5 100755 --- a/.github/scripts/noir-wasm-build.sh +++ b/.github/scripts/noir-wasm-build.sh @@ -2,5 +2,6 @@ set -eu .github/scripts/wasm-pack-install.sh +.github/scripts/wasm-opt-install.sh yarn workspace @noir-lang/types build yarn workspace @noir-lang/noir_wasm build diff --git a/.github/scripts/noirc-abi-build.sh b/.github/scripts/noirc-abi-build.sh index 23b8393088e..99de474eb75 100755 --- a/.github/scripts/noirc-abi-build.sh +++ b/.github/scripts/noirc-abi-build.sh @@ -2,4 +2,5 @@ set -eu .github/scripts/wasm-bindgen-install.sh +.github/scripts/wasm-opt-install.sh yarn workspace @noir-lang/noirc_abi build diff --git a/.github/scripts/wasm-opt-install.sh b/.github/scripts/wasm-opt-install.sh index cbdeb8f2bfe..218778edac6 100755 --- a/.github/scripts/wasm-opt-install.sh +++ b/.github/scripts/wasm-opt-install.sh @@ -5,4 +5,4 @@ cd $(dirname "$0") ./cargo-binstall-install.sh -cargo-binstall wasm-opt --version 0.116.0 -y +cargo-binstall wasm-opt --version 0.116.0 -y --force diff --git a/.github/workflows/test-js-packages.yml b/.github/workflows/test-js-packages.yml index b3908ee5d3e..06a96ee8932 100644 --- a/.github/workflows/test-js-packages.yml +++ b/.github/workflows/test-js-packages.yml @@ -66,9 +66,6 @@ jobs: - name: Install Yarn dependencies uses: ./.github/actions/setup - - name: Install wasm-opt - run: ./.github/scripts/wasm-opt-install.sh - - name: Build noirc_abi run: ./.github/scripts/noirc-abi-build.sh @@ -76,7 +73,9 @@ jobs: uses: actions/upload-artifact@v4 with: name: noirc_abi_wasm - path: ./tooling/noirc_abi_wasm/outputs/out/noirc_abi_wasm + path: | + ./tooling/noirc_abi_wasm/nodejs + ./tooling/noirc_abi_wasm/web retention-days: 10 @@ -100,9 +99,6 @@ jobs: - name: Install Yarn dependencies uses: ./.github/actions/setup - - name: Install wasm-opt - run: ./.github/scripts/wasm-opt-install.sh - - name: Build noir_js_types run: yarn workspace @noir-lang/types build @@ -138,9 +134,6 @@ jobs: - name: Install Yarn dependencies uses: ./.github/actions/setup - - name: Install wasm-opt - run: ./.github/scripts/wasm-opt-install.sh - - name: Build acvm_js run: ./.github/scripts/acvm_js-build.sh @@ -148,7 +141,9 @@ jobs: uses: actions/upload-artifact@v4 with: name: acvm-js - path: ./acvm-repo/acvm_js/outputs/out/acvm_js + path: | + ./acvm-repo/acvm_js/nodejs + ./acvm-repo/acvm_js/web retention-days: 3 test-acvm_js-node: diff --git a/.gitignore b/.gitignore index 5f41566c94b..9a829afab8b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,12 +17,6 @@ pkg/ # Noir.js tooling/noir_js/lib -# Nix stuff -**/outputs -result -.envrc.local -.direnv/ - # Nargo output *.proof *.acir diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 1fb1def7ce1..efb17cb0085 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,7 +4,6 @@ // List of extensions which should be recommended for users of this workspace. "recommendations": [ "mkhl.direnv", - "jnoortheen.nix-ide", "rust-lang.rust-analyzer", "redhat.vscode-yaml", "esbenp.prettier-vscode", diff --git a/.vscode/settings.json b/.vscode/settings.json index 171d36f4e04..fb8ea527881 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,17 +2,6 @@ "direnv.restart.automatic": true, "redhat.telemetry.enabled": false, "yaml.recommendations.show": false, - "nix.serverPath": "nil", - "nix.enableLanguageServer": true, - "nix.serverSettings": { - "nil": { - "formatting": { - "command": [ - "nixpkgs-fmt" - ] - } - } - }, "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": "${workspaceRoot}/.github/workflows/*.yml" }, diff --git a/README.md b/README.md index 5c93512ae26..adf68b290ef 100644 --- a/README.md +++ b/README.md @@ -56,26 +56,6 @@ Concretely the following items are on the road map: This crate's minimum supported rustc version is 1.73.0. -## Working on this project - -This project uses [Nix](https://nixos.org/) and [direnv](https://direnv.net/) to streamline the development experience. Please follow [our guidelines](https://noir-lang.org/docs/getting_started/installation/other_install_methods#option-3-compile-from-source) to setup your environment for working on the project. - -### Building against a different local/remote version of Barretenberg - -If you are working on this project and want a different version of Barretenberg (instead of the version this project is pinned against), you'll want to replace the lockfile version with your version. This can be done by running: - -```sh -nix flake lock --override-input barretenberg /absolute/path/to/your/barretenberg -``` - -You can also point at a fork and/or branch on GitHub using: - -```sh -nix flake lock --override-input barretenberg github:username/barretenberg/branch_name -``` - -__Note:__ You don't want to commit the updated lockfile, as it will fail in CI! - ## License Noir is free and open source. It is distributed under a dual license. (MIT/APACHE) diff --git a/acvm-repo/acvm_js/build.sh b/acvm-repo/acvm_js/build.sh index 24af149bcea..fe0b4dcbfff 100755 --- a/acvm-repo/acvm_js/build.sh +++ b/acvm-repo/acvm_js/build.sh @@ -6,13 +6,6 @@ function require_command { exit 1 fi } -function check_installed { - if ! command -v "$1" >/dev/null 2>&1; then - echo "$1 is not installed. Please install it." >&2 - return 1 - fi - return 0 -} function run_or_fail { "$@" local status=$? @@ -25,23 +18,29 @@ function run_or_fail { require_command jq require_command cargo require_command wasm-bindgen -check_installed wasm-opt +require_command wasm-opt self_path=$(dirname "$(readlink -f "$0")") -export pname=$(cargo read-manifest | jq -r '.name') -export CARGO_TARGET_DIR=$self_path/target +pname=$(cargo read-manifest | jq -r '.name') -rm -rf $self_path/outputs >/dev/null 2>&1 -rm -rf $self_path/result >/dev/null 2>&1 +NODE_DIR=$self_path/nodejs +BROWSER_DIR=$self_path/web -if [ -n "$out" ]; then - echo "Will install package to $out (defined outside installPhase.sh script)" -else - export out="$self_path/outputs/out" - echo "Will install package to $out" +# Clear out the existing build artifacts as these aren't automatically removed by wasm-bindgen. +if [ -d ./pkg/ ]; then + rm -r $NODE_DIR + rm -r $BROWSER_DIR fi -run_or_fail $self_path/buildPhaseCargoCommand.sh -run_or_fail $self_path/installPhase.sh +TARGET=wasm32-unknown-unknown +WASM_BINARY=${self_path}/../../target/$TARGET/release/${pname}.wasm + +NODE_WASM=${NODE_DIR}/${pname}_bg.wasm +BROWSER_WASM=${BROWSER_DIR}/${pname}_bg.wasm -ln -s $out $self_path/result +# Build the new wasm package +run_or_fail cargo build --lib --release --target $TARGET --package ${pname} +run_or_fail wasm-bindgen $WASM_BINARY --out-dir $NODE_DIR --typescript --target nodejs +run_or_fail wasm-bindgen $WASM_BINARY --out-dir $BROWSER_DIR --typescript --target web +run_or_fail wasm-opt $NODE_WASM -o $NODE_WASM -O +run_or_fail wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O diff --git a/acvm-repo/acvm_js/buildPhaseCargoCommand.sh b/acvm-repo/acvm_js/buildPhaseCargoCommand.sh deleted file mode 100755 index 6c710bc938f..00000000000 --- a/acvm-repo/acvm_js/buildPhaseCargoCommand.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -function run_or_fail { - "$@" - local status=$? - if [ $status -ne 0 ]; then - echo "Command '$*' failed with exit code $status" >&2 - exit $status - fi -} -function run_if_available { - if command -v "$1" >/dev/null 2>&1; then - "$@" - else - echo "$1 is not installed. Please install it to use this feature." >&2 - fi -} - -export self_path=$(dirname "$(readlink -f "$0")") - - -NODE_DIR=$self_path/nodejs/ -BROWSER_DIR=$self_path/web/ - -# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. -if [ -d ./pkg/ ]; then - rm -r $NODE_DIR - rm -r $BROWSER_DIR -fi - -TARGET=wasm32-unknown-unknown -WASM_BINARY=$CARGO_TARGET_DIR/$TARGET/release/${pname}.wasm - -NODE_WASM=${NODE_DIR}/${pname}_bg.wasm -BROWSER_WASM=${BROWSER_DIR}/${pname}_bg.wasm - -# Build the new wasm package -run_or_fail cargo build --lib --release --target $TARGET --package ${pname} -run_or_fail wasm-bindgen $WASM_BINARY --out-dir $NODE_DIR --typescript --target nodejs -run_or_fail wasm-bindgen $WASM_BINARY --out-dir $BROWSER_DIR --typescript --target web -run_if_available wasm-opt $NODE_WASM -o $NODE_WASM -O -run_if_available wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O diff --git a/acvm-repo/acvm_js/installPhase.sh b/acvm-repo/acvm_js/installPhase.sh deleted file mode 100755 index 34ddb8155e1..00000000000 --- a/acvm-repo/acvm_js/installPhase.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -export self_path=$(dirname "$(readlink -f "$0")") - -export out_path=$out/acvm_js - -mkdir -p $out_path -cp $self_path/README.md $out_path/ -cp $self_path/package.json $out_path/ -cp -r $self_path/nodejs $out_path/ -cp -r $self_path/web $out_path/ diff --git a/acvm-repo/acvm_js/package.json b/acvm-repo/acvm_js/package.json index 55345a2ddf6..44d99f13c31 100644 --- a/acvm-repo/acvm_js/package.json +++ b/acvm-repo/acvm_js/package.json @@ -34,9 +34,7 @@ "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0", "publish": "echo 📡 publishing `$npm_package_name` && yarn npm publish", "nightly:version": "jq --arg new_version \"-$(git rev-parse --short HEAD)$1\" '.version = .version + $new_version' package.json > package-tmp.json && mv package-tmp.json package.json", - "clean": "chmod u+w web nodejs || true && rm -rf web nodejs", - "build:nix": "nix build -L .#acvm_js", - "install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/acvm_js/nodejs ./ && cp -rL ./result/acvm_js/web ./" + "clean": "chmod u+w web nodejs || true && rm -rf web nodejs" }, "devDependencies": { "@esm-bundle/chai": "^4.3.4-fix.0", diff --git a/compiler/noirc_driver/build.rs b/compiler/noirc_driver/build.rs index 73a56142075..2ed109398a4 100644 --- a/compiler/noirc_driver/build.rs +++ b/compiler/noirc_driver/build.rs @@ -2,8 +2,7 @@ const GIT_COMMIT: &&str = &"GIT_COMMIT"; use std::path::Path; fn main() { - // Only use build_data if the environment variable isn't set - // The environment variable is always set when working via Nix + // Only use build_data if the environment variable isn't set. if std::env::var(GIT_COMMIT).is_err() { build_data::set_GIT_COMMIT(); build_data::set_GIT_DIRTY(); diff --git a/compiler/wasm/README.md b/compiler/wasm/README.md index 52f7e83e19e..fd534722622 100644 --- a/compiler/wasm/README.md +++ b/compiler/wasm/README.md @@ -26,17 +26,3 @@ for (const path of files) { } const myCompiledCode = await compile(fm); ``` - -## Building from source - -Outside of the [noir repo](https://github.com/noir-lang/noir), this package can be built using the command below: - -```bash -nix build -L github:noir-lang/noir/master#noir_wasm -``` - -If you are within the noir repo and would like to build local changes, you can use: - -```bash -nix build -L #noir_wasm -``` diff --git a/default.nix b/default.nix deleted file mode 100644 index 9e230590a61..00000000000 --- a/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - flakeCompatRev = lock.nodes.flake-compat.locked.rev; - flakeCompatHash = lock.nodes.flake-compat.locked.narHash; - flakeCompat = fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${flakeCompatRev}.tar.gz"; - sha256 = flakeCompatHash; - }; - compat = import flakeCompat { - src = ./.; - }; -in -compat.defaultNix diff --git a/docs/docs/getting_started/installation/other_install_methods.md b/docs/docs/getting_started/installation/other_install_methods.md index a35e34aaf9c..3634723562b 100644 --- a/docs/docs/getting_started/installation/other_install_methods.md +++ b/docs/docs/getting_started/installation/other_install_methods.md @@ -1,6 +1,6 @@ --- -title: Alternative Install Methods -description: There are different ways to install Nargo, the one-stop shop and command-line tool for developing Noir programs. This guide explains other methods that don't rely on noirup, such as compiling from source, installing from binaries, and using WSL for windows +title: Alternative Installations +description: There are different ways to install Nargo, the one-stop shop and command-line tool for developing Noir programs. This guide explains how to specify which version to install when using noirup, and using WSL for windows. keywords: [ Installation Nargo @@ -12,10 +12,7 @@ keywords: [ Linux Nix Direnv - Shell & editor experience - Building and testing Uninstalling Nargo - Noir vs code extension, ] sidebar_position: 1 --- @@ -86,146 +83,7 @@ With `noirup`, you can easily switch between different Nargo versions, including noirup --path ./path/to/local/source ``` -## Alternate Installation Methods (No Longer Recommended) - -While the following methods are available, they are no longer recommended. We advise using noirup for a more efficient and flexible installation experience. - -However, there are other methods for installing Nargo: - -- [Binaries](#option-1-installing-from-binaries) -- [Compiling from Source](#option-2-compile-from-source) -- [WSL for Windows](#option-3-wsl-for-windows) - -### Option 1: Installing from Binaries - -See [GitHub Releases](https://github.com/noir-lang/noir/releases) for the latest and previous -platform specific binaries. - -#### Step 1 - -Paste and run the following in the terminal to extract and install the binary: - -> **macOS / Linux:** If you are prompted with `Permission denied` when running commands, prepend -> `sudo` and re-run it. - -##### macOS (Apple Silicon) - -```bash -mkdir -p $HOME/.nargo/bin && \ -curl -o $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.24.0/nargo-aarch64-apple-darwin.tar.gz && \ -tar -xvf $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \ -echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \ -source ~/.zshrc -``` - -##### macOS (Intel) - -```bash -mkdir -p $HOME/.nargo/bin && \ -curl -o $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.24.0/nargo-x86_64-apple-darwin.tar.gz && \ -tar -xvf $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \ -echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \ -source ~/.zshrc -``` - -##### Linux (Bash) - -```bash -mkdir -p $HOME/.nargo/bin && \ -curl -o $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -L https://github.com/noir-lang/noir/releases/download/v0.24.0/nargo-x86_64-unknown-linux-gnu.tar.gz && \ -tar -xvf $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -C $HOME/.nargo/bin/ && \ -echo -e '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.bashrc && \ -source ~/.bashrc -``` - -#### Step 2 - -Check if the installation was successful by running `nargo --version`. You should get a version number. - -> **macOS:** If you are prompted with an OS alert, right-click and open the _nargo_ executable from -> Finder. Close the new terminal popped up and `nargo` should now be accessible. - -### Option 2: Compile from Source - -Due to the large number of native dependencies, Noir projects uses [Nix](https://nixos.org/) and [direnv](https://direnv.net/) to streamline the development experience. It helps mitigating issues commonly associated with dependency management, such as conflicts between required package versions for different projects (often referred to as "dependency hell"). - -Combined with direnv, which automatically sets or clears environment variables based on the directory, it further simplifies the development process by seamlessly integrating with the developer's shell, facilitating an efficient and reliable workflow for managing and deploying Noir projects with multiple dependencies. - -#### Setting up your environment - -For the best experience, please follow these instructions to setup your environment: - -1. Install Nix following [their guide](https://nixos.org/download.html) for your operating system. -2. Create the file `~/.config/nix/nix.conf` with the contents: - -```ini -experimental-features = nix-command -extra-experimental-features = flakes -``` - -3. Install direnv into your Nix profile by running: - -```sh -nix profile install nixpkgs#direnv -``` - -4. Add direnv to your shell following [their guide](https://direnv.net/docs/hook.html). - 1. For bash or zshell, add `eval "$(direnv hook bash)"` or `eval "$(direnv hook zsh)"` to your ~/.bashrc or ~/.zshrc file, respectively. -5. Restart your shell. - -#### Shell & editor experience - -Now that your environment is set up, you can get to work on the project. - -1. Clone the repository, such as: - -```sh -git clone git@github.com:noir-lang/noir -``` - -> Replacing `noir` with whichever repository you want to work on. - -2. Navigate to the directory: - -```sh -cd noir -``` - -> Replacing `noir` with whichever repository you cloned. - -3. You should see a **direnv error** because projects aren't allowed by default. Make sure you've reviewed and trust our `.envrc` file, then you need to run: - -```sh -direnv allow -``` - -4. Now, wait awhile for all the native dependencies to be built. This will take some time and direnv will warn you that it is taking a long time, but we just need to let it run. - -5. Once you are presented with your prompt again, you can start your editor within the project directory (we recommend [VSCode](https://code.visualstudio.com/)): - -```sh -code . -``` - -6. (Recommended) When launching VSCode for the first time, you should be prompted to install our recommended plugins. We highly recommend installing these for the best development experience. - -#### Building and testing - -Assuming you are using `direnv` to populate your environment, building and testing the project can be done -with the typical `cargo build`, `cargo test`, and `cargo clippy` commands. You'll notice that the `cargo` version matches the version we specify in `rust-toolchain.toml`, which is 1.73.0 at the time of this writing. - -If you want to build the entire project in an isolated sandbox, you can use Nix commands: - -1. `nix build .` (or `nix build . -L` for verbose output) to build the project in a Nix sandbox. -2. `nix flake check` (or `nix flake check -L` for verbose output) to run clippy and tests in a Nix sandbox. - -#### Without `direnv` - -If you have hesitations with using direnv, you can launch a subshell with `nix develop` and then launch your editor from within the subshell. However, if VSCode was already launched in the project directory, the environment won't be updated. - -Advanced: If you aren't using direnv nor launching your editor within the subshell, you can try to install Barretenberg and other global dependencies the package needs. This is an advanced workflow and likely won't receive support! - -### Option 3: WSL (for Windows) +## Installation on Windows The default backend for Noir (Barretenberg) doesn't provide Windows binaries at this time. For that reason, Noir cannot be installed natively. However, it is available by using Windows Subsystem for Linux (WSL). @@ -235,20 +93,10 @@ step 2: Follow the [Noirup instructions](#encouraged-installation-method-noirup) ## Uninstalling Nargo -### Noirup - -If you installed Nargo with `noirup` or through directly downloading binaries, you can uninstall Nargo by removing the files in `~/.nargo`, `~/nargo`, and `~/noir_cache`. This ensures that all installed binaries, configurations, and cache related to Nargo are fully removed from your system. +If you installed Nargo with `noirup`, you can uninstall Nargo by removing the files in `~/.nargo`, `~/nargo`, and `~/noir_cache`. This ensures that all installed binaries, configurations, and cache related to Nargo are fully removed from your system. ```bash rm -r ~/.nargo rm -r ~/nargo rm -r ~/noir_cache ``` - -### Nix - -If you installed Nargo with Nix or compiled it from source, you can remove the binary located at `~/.nix-profile/bin/nargo`. - -```bash -rm ~/.nix-profile/bin/nargo -``` diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 1cb421a49ef..00000000000 --- a/flake.nix +++ /dev/null @@ -1,260 +0,0 @@ -{ - description = "Build the Noir programming language"; - - # All of these inputs (a.k.a. dependencies) need to align with inputs we - # use so they use the `inputs.*.follows` syntax to reference our inputs - inputs = { - nixpkgs = { - url = "github:NixOS/nixpkgs/nixos-23.05"; - }; - - flake-utils = { - url = "github:numtide/flake-utils"; - }; - - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - fenix = { - url = "github:nix-community/fenix"; - inputs = { - nixpkgs.follows = "nixpkgs"; - }; - }; - - crane = { - url = "github:ipetkov/crane"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; - flake-compat.follows = "flake-compat"; - }; - }; - }; - - outputs = - { self, nixpkgs, crane, flake-utils, fenix, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - }; - - rustToolchain = fenix.packages.${system}.fromToolchainFile { - file = ./rust-toolchain.toml; - sha256 = "sha256-rLP8+fTxnPHoR96ZJiCa/5Ans1OojI7MLsmSqR2ip8o="; - }; - - craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; - - # The `self.rev` property is only available when the working tree is not dirty - GIT_COMMIT = if (self ? rev) then self.rev else "unknown"; - GIT_DIRTY = if (self ? rev) then "false" else "true"; - - extraBuildInputs = [ ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ - # Need libiconv and apple Security on Darwin. See https://github.com/ipetkov/crane/issues/156 - pkgs.libiconv - pkgs.darwin.apple_sdk.frameworks.Security - ]; - - environment = { - # We enable backtraces on any failure for help with debugging - RUST_BACKTRACE = "1"; - - # We download the Wasm version of `acvm_backend` in the barretenberg releases for the ACVM `blackbox_solver` - BARRETENBERG_ARCHIVE = pkgs.fetchurl { - url = "https://github.com/AztecProtocol/barretenberg/releases/download/barretenberg-v0.4.5/acvm_backend.wasm.tar.gz"; - sha256 = "sha256-xONt5pTKWf/YbVnX/NXl/VNBbtKd+CP7CLkB1jf0RHw="; - }; - }; - - # Configuration shared between builds - config = { - # x-release-please-start-version - version = "0.26.0"; - # x-release-please-end - - src = pkgs.lib.cleanSourceWith { - src = craneLib.path ./.; - # Custom filter with various file extensions that we rely upon to build packages - # Currently: `.nr`, `.sol`, `.sh`, `.json`, `.md` and `.wasm` - filter = path: type: - (builtins.match ".*\.(nr|sol|sh|json|md|wasm|txt)$" path != null) || (craneLib.filterCargoSources path type); - }; - - # TODO(#1198): It'd be nice to include these flags when running `cargo clippy` in a devShell. - cargoClippyExtraArgs = "--all-targets -- -D warnings"; - - # TODO(#1198): It'd be nice to include this flag when running `cargo test` in a devShell. - cargoTestExtraArgs = "--workspace"; - }; - - # Combine the environment and other configuration needed for Crane to build our Rust packages - nativeConfig = environment // config // { - nativeBuildInputs = [ ]; - - buildInputs = [ ] ++ extraBuildInputs; - }; - - # Combine the environmnet and other configuration needed for Crane to build our Wasm packages - wasmConfig = environment // config // { - CARGO_TARGET_DIR = "./target"; - - nativeBuildInputs = with pkgs; [ - which - git - jq - rustToolchain - wasm-bindgen-cli - binaryen - ]; - - buildInputs = [ ] ++ extraBuildInputs; - }; - - # Build *just* the cargo dependencies, so we can reuse all of that work between runs - native-cargo-artifacts = craneLib.buildDepsOnly (nativeConfig // { - pname = "nargo"; - }); - noirc-abi-wasm-cargo-artifacts = craneLib.buildDepsOnly (wasmConfig // { - pname = "noirc_abi_wasm"; - }); - acvm-js-cargo-artifacts = craneLib.buildDepsOnly (wasmConfig // { - pname = "acvm_js"; - }); - - nargo = craneLib.buildPackage (nativeConfig // { - pname = "nargo"; - - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = native-cargo-artifacts; - - # We don't want to run tests because they don't work in the Nix sandbox - doCheck = false; - }); - - noirc_abi_wasm = craneLib.buildPackage (wasmConfig // rec { - pname = "noirc_abi_wasm"; - - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = noirc-abi-wasm-cargo-artifacts; - - cargoExtraArgs = "--package ${pname} --target wasm32-unknown-unknown"; - - buildPhaseCargoCommand = '' - bash tooling/noirc_abi_wasm/buildPhaseCargoCommand.sh release - ''; - - installPhase = '' - bash tooling/noirc_abi_wasm/installPhase.sh - ''; - - # We don't want to run tests because they don't work in the Nix sandbox - doCheck = false; - }); - - acvm_js = craneLib.buildPackage (wasmConfig // rec { - pname = "acvm_js"; - - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = acvm-js-cargo-artifacts; - - cargoExtraArgs = "--package ${pname} --target wasm32-unknown-unknown"; - - buildPhaseCargoCommand = '' - bash acvm-repo/acvm_js/buildPhaseCargoCommand.sh release - ''; - - installPhase = '' - bash acvm-repo/acvm_js/installPhase.sh - ''; - - # We don't want to run tests because they don't work in the Nix sandbox - doCheck = false; - }); - - wasm-bindgen-cli = pkgs.callPackage ./wasm-bindgen-cli.nix { - rustPlatform = pkgs.makeRustPlatform { - rustc = rustToolchain; - cargo = rustToolchain; - }; - }; - in - { - # We use `checks` to run `cargo clippy` and `cargo fmt` since we disable checks in the primary derivations - checks = { - cargo-clippy = craneLib.cargoClippy (nativeConfig // { - pname = "noir"; - - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = native-cargo-artifacts; - }); - - cargo-fmt = craneLib.cargoFmt (nativeConfig // { - pname = "noir"; - - inherit GIT_COMMIT GIT_DIRTY; - - cargoArtifacts = native-cargo-artifacts; - }); - }; - - packages = { - default = nargo; - - # Nix flakes cannot build more than one derivation in one command (see https://github.com/NixOS/nix/issues/5591) - # so we use `symlinkJoin` to build everything as the "all" package. - all = pkgs.symlinkJoin { name = "all"; paths = [ nargo noirc_abi_wasm acvm_js ]; }; - all_wasm = pkgs.symlinkJoin { name = "all_wasm"; paths = [ noirc_abi_wasm acvm_js ]; }; - - # We also export individual packages to enable `nix build .#nargo -L`, etc. - inherit nargo; - inherit noirc_abi_wasm; - inherit acvm_js; - - # We expose the `*-cargo-artifacts` derivations so we can cache our cargo dependencies in CI - inherit native-cargo-artifacts; - inherit noirc-abi-wasm-cargo-artifacts; - inherit acvm-js-cargo-artifacts; - }; - - # Setup the environment to match the environment settings, the inputs from our checks derivations, - # and extra tooling via `nativeBuildInputs` - devShells.default = pkgs.mkShell (environment // { - inputsFrom = [ - nargo - noirc_abi_wasm - acvm_js - ]; - - # Additional tools that weren't included as `nativeBuildInputs` of any of the derivations in `inputsFrom` - nativeBuildInputs = with pkgs; [ - # Rust toolchain - rustToolchain - # Other tools - starship - yarn - nodejs-18_x - # Used by the `bb` binary - curl - gzip - # This ensures the right lldb is in the environment for running rust-lldb - llvmPackages.lldb - # Nix tools - nil - nixpkgs-fmt - ]; - - shellHook = '' - eval "$(starship init bash)" - ''; - }); - }); -} - diff --git a/package.json b/package.json index 049c1634dd2..30cac607010 100644 --- a/package.json +++ b/package.json @@ -17,19 +17,11 @@ "test": "yarn workspaces foreach --parallel --verbose run test", "test:integration": "yarn workspace integration-tests test", "clean:workspaces": "yarn workspaces foreach --exclude @noir-lang/root run clean", - "clean:root": "rm -rf ./result ./target ./packages", + "clean:root": "rm -rf ./target ./packages", "clean": "yarn clean:workspaces && yarn clean:root", "lint": "yarn workspaces foreach --verbose run lint", "spellcheck": "cspell '**/*.{md,rs}' -c ./cspell.json", - "install:acvm_js": "yarn workspace @noir-lang/acvm_js run install:from:nix", - "install:noir_wasm": "yarn workspace @noir-lang/noir_wasm run install:from:nix", - "install:noirc_abi_wasm": "yarn workspace @noir-lang/noirc_abi run install:from:nix", - "install:from:nix": "yarn install:acvm_js && yarn install:noir_wasm && yarn install:noirc_abi_wasm", - "build:types": "yarn workspace @noir-lang/types run build", - "build:backend_barretenberg": "yarn workspace @noir-lang/backend_barretenberg run build", - "build:noir_js": "yarn workspace @noir-lang/noir_js run build", - "build:js:only": "yarn workspaces foreach -vtp --from \"{@noir-lang/types,@noir-lang/backend_barretenberg,@noir-lang/noir_js,@noir-lang/noir_codegen}\" run build", - "prepare:publish": "yarn clean && yarn install:from:nix && yarn build:js:only", + "prepare:publish": "yarn clean && yarn build", "nightly:version": "yarn workspaces foreach run nightly:version", "publish:all": "yarn install && yarn workspaces foreach run publish" }, diff --git a/release-please-config.json b/release-please-config.json index 217a86303a1..0ba192754a0 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -13,7 +13,6 @@ "include-component-in-tag": false, "extra-files": [ "Cargo.toml", - "flake.nix", { "type": "json", "path": "compiler/wasm/package.json", @@ -82,4 +81,4 @@ "sentence-case" ], "bootstrap-sha": "690cfc0468de0b9aee53ccfe832c71c16e61e5fc" -} \ No newline at end of file +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index b72d4a4697b..00000000000 --- a/shell.nix +++ /dev/null @@ -1,13 +0,0 @@ -let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - flakeCompatRev = lock.nodes.flake-compat.locked.rev; - flakeCompatHash = lock.nodes.flake-compat.locked.narHash; - flakeCompat = fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${flakeCompatRev}.tar.gz"; - sha256 = flakeCompatHash; - }; - compat = import flakeCompat { - src = ./.; - }; -in -compat.shellNix diff --git a/tooling/debugger/build.rs b/tooling/debugger/build.rs index 26a8bc64b0e..ebdf2036894 100644 --- a/tooling/debugger/build.rs +++ b/tooling/debugger/build.rs @@ -7,8 +7,7 @@ use std::{env, fs}; const GIT_COMMIT: &&str = &"GIT_COMMIT"; fn main() { - // Only use build_data if the environment variable isn't set - // The environment variable is always set when working via Nix + // Only use build_data if the environment variable isn't set. if std::env::var(GIT_COMMIT).is_err() { build_data::set_GIT_COMMIT(); build_data::set_GIT_DIRTY(); diff --git a/tooling/nargo_cli/build.rs b/tooling/nargo_cli/build.rs index a796eeac326..16df29e6985 100644 --- a/tooling/nargo_cli/build.rs +++ b/tooling/nargo_cli/build.rs @@ -16,8 +16,7 @@ const GIT_COMMIT: &&str = &"GIT_COMMIT"; fn main() { check_rustc_version(); - // Only use build_data if the environment variable isn't set - // The environment variable is always set when working via Nix + // Only use build_data if the environment variable isn't set. if std::env::var(GIT_COMMIT).is_err() { build_data::set_GIT_COMMIT(); build_data::set_GIT_DIRTY(); diff --git a/tooling/noirc_abi_wasm/README.md b/tooling/noirc_abi_wasm/README.md index 77bc1f5fae2..2b0cf9b74d4 100644 --- a/tooling/noirc_abi_wasm/README.md +++ b/tooling/noirc_abi_wasm/README.md @@ -1,17 +1,3 @@ # Noir Lang ABI JavaScript Package This JavaScript package enables users to ABI encode inputs to a Noir program, i.e. generating an initial witness. - -## Building from source - -Outside of the [noir repo](https://github.com/noir-lang/noir), this package can be built using the command below: - -```bash -nix build -L github:noir-lang/noir/master#abi_wasm -``` - -If you are within the noir repo and would like to build local changes, you can use: - -```bash -nix build -L #abi_wasm -``` diff --git a/tooling/noirc_abi_wasm/build.rs b/tooling/noirc_abi_wasm/build.rs index 3b96be74ef3..7a6eb861de2 100644 --- a/tooling/noirc_abi_wasm/build.rs +++ b/tooling/noirc_abi_wasm/build.rs @@ -1,8 +1,7 @@ const GIT_COMMIT: &&str = &"GIT_COMMIT"; fn main() { - // Only use build_data if the environment variable isn't set - // The environment variable is always set when working via Nix + // Only use build_data if the environment variable isn't set. if std::env::var(GIT_COMMIT).is_err() { build_data::set_GIT_COMMIT(); build_data::set_GIT_DIRTY(); diff --git a/tooling/noirc_abi_wasm/build.sh b/tooling/noirc_abi_wasm/build.sh index 24af149bcea..fe0b4dcbfff 100755 --- a/tooling/noirc_abi_wasm/build.sh +++ b/tooling/noirc_abi_wasm/build.sh @@ -6,13 +6,6 @@ function require_command { exit 1 fi } -function check_installed { - if ! command -v "$1" >/dev/null 2>&1; then - echo "$1 is not installed. Please install it." >&2 - return 1 - fi - return 0 -} function run_or_fail { "$@" local status=$? @@ -25,23 +18,29 @@ function run_or_fail { require_command jq require_command cargo require_command wasm-bindgen -check_installed wasm-opt +require_command wasm-opt self_path=$(dirname "$(readlink -f "$0")") -export pname=$(cargo read-manifest | jq -r '.name') -export CARGO_TARGET_DIR=$self_path/target +pname=$(cargo read-manifest | jq -r '.name') -rm -rf $self_path/outputs >/dev/null 2>&1 -rm -rf $self_path/result >/dev/null 2>&1 +NODE_DIR=$self_path/nodejs +BROWSER_DIR=$self_path/web -if [ -n "$out" ]; then - echo "Will install package to $out (defined outside installPhase.sh script)" -else - export out="$self_path/outputs/out" - echo "Will install package to $out" +# Clear out the existing build artifacts as these aren't automatically removed by wasm-bindgen. +if [ -d ./pkg/ ]; then + rm -r $NODE_DIR + rm -r $BROWSER_DIR fi -run_or_fail $self_path/buildPhaseCargoCommand.sh -run_or_fail $self_path/installPhase.sh +TARGET=wasm32-unknown-unknown +WASM_BINARY=${self_path}/../../target/$TARGET/release/${pname}.wasm + +NODE_WASM=${NODE_DIR}/${pname}_bg.wasm +BROWSER_WASM=${BROWSER_DIR}/${pname}_bg.wasm -ln -s $out $self_path/result +# Build the new wasm package +run_or_fail cargo build --lib --release --target $TARGET --package ${pname} +run_or_fail wasm-bindgen $WASM_BINARY --out-dir $NODE_DIR --typescript --target nodejs +run_or_fail wasm-bindgen $WASM_BINARY --out-dir $BROWSER_DIR --typescript --target web +run_or_fail wasm-opt $NODE_WASM -o $NODE_WASM -O +run_or_fail wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O diff --git a/tooling/noirc_abi_wasm/buildPhaseCargoCommand.sh b/tooling/noirc_abi_wasm/buildPhaseCargoCommand.sh deleted file mode 100755 index 1188d00953e..00000000000 --- a/tooling/noirc_abi_wasm/buildPhaseCargoCommand.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -function run_or_fail { - "$@" - local status=$? - if [ $status -ne 0 ]; then - echo "Command '$*' failed with exit code $status" >&2 - exit $status - fi -} -function run_if_available { - if command -v "$1" >/dev/null 2>&1; then - "$@" - else - echo "$1 is not installed. Please install it to use this feature." >&2 - fi -} - -export self_path=$(dirname "$(readlink -f "$0")") - -# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. -if [ -d ./pkg/ ]; then - rm -rf $self_path/pkg/ -fi - -TARGET=wasm32-unknown-unknown -WASM_BINARY=$CARGO_TARGET_DIR/$TARGET/release/${pname}.wasm - -NODE_DIR=$self_path/nodejs/ -BROWSER_DIR=$self_path/web/ -NODE_WASM=${NODE_DIR}/${pname}_bg.wasm -BROWSER_WASM=${BROWSER_DIR}/${pname}_bg.wasm - -# Build the new wasm package -run_or_fail cargo build --lib --release --target $TARGET --package ${pname} -run_or_fail wasm-bindgen $WASM_BINARY --out-dir $NODE_DIR --typescript --target nodejs -run_or_fail wasm-bindgen $WASM_BINARY --out-dir $BROWSER_DIR --typescript --target web -run_if_available wasm-opt $NODE_WASM -o $NODE_WASM -O -run_if_available wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O \ No newline at end of file diff --git a/tooling/noirc_abi_wasm/installPhase.sh b/tooling/noirc_abi_wasm/installPhase.sh deleted file mode 100755 index d9b94f2d171..00000000000 --- a/tooling/noirc_abi_wasm/installPhase.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -export self_path=$(dirname "$(readlink -f "$0")") - -export out_path=$out/noirc_abi_wasm - -mkdir -p $out_path -cp $self_path/README.md $out_path/ -cp $self_path/package.json $out_path/ -cp -r $self_path/nodejs $out_path/ -cp -r $self_path/web $out_path/ diff --git a/tooling/noirc_abi_wasm/package.json b/tooling/noirc_abi_wasm/package.json index e93a8e6a5e3..14e528c3b15 100644 --- a/tooling/noirc_abi_wasm/package.json +++ b/tooling/noirc_abi_wasm/package.json @@ -33,9 +33,7 @@ "clean": "chmod u+w web nodejs || true && rm -rf ./nodejs ./web ./target ./result", "nightly:version": "jq --arg new_version \"-$(git rev-parse --short HEAD)$1\" '.version = .version + $new_version' package.json > package-tmp.json && mv package-tmp.json package.json", "publish": "echo 📡 publishing `$npm_package_name` && yarn npm publish", - "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0", - "build:nix": "nix build -L .#noirc_abi_wasm", - "install:from:nix": "yarn clean && yarn build:nix && cp -rL ./result/noirc_abi_wasm/nodejs ./ && cp -rL ./result/noirc_abi_wasm/web ./" + "lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" }, "dependencies": { "@noir-lang/types": "workspace:*" diff --git a/wasm-bindgen-cli.nix b/wasm-bindgen-cli.nix deleted file mode 100644 index 7c3910f032e..00000000000 --- a/wasm-bindgen-cli.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ lib -, rustPlatform -, fetchCrate -, nodejs -, pkg-config -, openssl -, stdenv -, curl -, darwin -, libiconv -, runCommand -}: - -rustPlatform.buildRustPackage rec { - pname = "wasm-bindgen-cli"; - version = "0.2.86"; - - src = fetchCrate { - inherit pname version; - sha256 = "sha256-56EOiLbdgAcoTrkyvB3t9TjtLaRvGxFUXx4haLwE2QY="; - }; - - cargoSha256 = "sha256-4CPBmz92PuPN6KeGDTdYPAf5+vTFk9EN5Cmx4QJy6yI="; - - nativeBuildInputs = [ pkg-config ]; - - buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ - curl - # Need libiconv and apple Security on Darwin. See https://github.com/ipetkov/crane/issues/156 - libiconv - darwin.apple_sdk.frameworks.Security - ]; - - doCheck = false; - - meta = with lib; { - homepage = "https://rustwasm.github.io/docs/wasm-bindgen/"; - license = with licenses; [ asl20 /* or */ mit ]; - description = "Facilitating high-level interactions between wasm modules and JavaScript"; - maintainers = with maintainers; [ nitsky rizary ]; - mainProgram = "wasm-bindgen"; - }; -}