Commit 074830ac authored by mitchmindtree's avatar mitchmindtree Committed by Moritz Sanft
Browse files

foundry: init at 0.3.0



Foundry is a portable, modular toolkit for Ethereum application
development written in Rust.

An `update-svm-lists.sh` script is included as a helper for myself /
other maintainers to periodically update the solidity binary lists
required by the `svm-rs` crate.

Co-authored-by: default avatarmitchmindtree <mail@mitchellnordine.com>
parent 4aa7d2d6
Loading
Loading
Loading
Loading
+68 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  darwin,
  fetchFromGitHub,
  libusb1,
  nix-update-script,
  pkg-config,
  rustPlatform,
  solc,
  versionCheckHook,
}:

rustPlatform.buildRustPackage rec {
  pname = "foundry";
  version = "0.3.0";

  src = fetchFromGitHub {
    owner = "foundry-rs";
    repo = "foundry";
    tag = "v${version}";
    hash = "sha256-SdxcNbe8/dNZ4JcxKksWmDBAvQorpC8ePvQgnyeKgxU=";
  };

  cargoHash = "sha256-PQbp9jZZB/dsyKAlckZwl8xOpXks3anqUm+Ld7IhMFI=";

  nativeBuildInputs = [ pkg-config ] ++ lib.optionals stdenv.isDarwin [ darwin.DarwinTools ];

  buildInputs = [ solc ] ++ lib.optionals stdenv.isDarwin [ libusb1 ];

  # Tests are run upstream, and many perform I/O
  # incompatible with the nix build sandbox.
  doCheck = false;

  nativeInstallCheckInputs = [
    versionCheckHook
  ];
  versionCheckProgram = "${placeholder "out"}/bin/forge";
  versionCheckProgramArg = [ "--version" ];
  doInstallCheck = true;

  passthru.updateScript = nix-update-script { };

  env = {
    SVM_RELEASES_LIST_JSON =
      if stdenv.isDarwin then
        # Confusingly, these are universal binaries, not amd64.
        # See: https://github.com/ethereum/solidity/issues/12291#issuecomment-1974771433
        "${./svm-lists/macosx-amd64.json}"
      else
        "${./svm-lists/linux-amd64.json}";
  };

  meta = {
    homepage = "https://github.com/foundry-rs/foundry";
    description = "Portable, modular toolkit for Ethereum application development written in Rust.";
    changelog = "https://github.com/foundry-rs/foundry/blob/v${version}/CHANGELOG.md";
    license = with lib.licenses; [
      asl20
      mit
    ];
    maintainers = with lib.maintainers; [
      mitchmindtree
      msanft
    ];
    platforms = lib.platforms.unix;
  };
}
+1015 −0

File added.

Preview size limit exceeded, changes collapsed.

+1147 −0

File added.

Preview size limit exceeded, changes collapsed.

+47 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

# This script updates the Solidity binary lists required by the svm-rs
# crate.
# TODO: Bundle this into an updater script

set -euo pipefail

# Get the directory of the current script
script_dir=$(dirname "$(realpath "$0")")

# Directory where the files will be downloaded
dir="${script_dir}/svm-lists"

# URLs of the files
urls=(
    "https://binaries.soliditylang.org/macosx-amd64/list.json"
    "https://binaries.soliditylang.org/linux-amd64/list.json"
)

# Create the directory (no error if it already exists)
mkdir -p "$dir"

# Function to extract filename from URL
extract_filename() {
    url=$1
    # Extract the parent directory name and append .json
    echo "$(basename "$(dirname "$url")").json"
}

# Function to fix line endings and remove trailing newline
ensure_unix_format() {
    file=$1
    # Convert to Unix LF line endings and ensure there's no trailing newline
    tr -d '\r' < "$file" | sed -e '$a\' > "${file}.tmp" && mv "${file}.tmp" "$file"
}

# Iterate over the URLs
for url in "${urls[@]}"; do
    # Extract filename from URL
    filename=$(extract_filename "$url")

    # Download the file and fix line endings
    echo "Fetching $url to $dir/$filename"
    curl -sL "$url" -o "${dir}/${filename}"
    ensure_unix_format "${dir}/${filename}"
done
+0 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
  pkgs,
  boost,
  cmake,
  coreutils,
  jq,
  ncurses,
  python3,