diff --git a/m1/.cargo/config.toml b/m1/.cargo/config.toml index f93b5556..bff29e6e 100644 --- a/m1/.cargo/config.toml +++ b/m1/.cargo/config.toml @@ -1,33 +1,2 @@ -[alias] -xclippy = [ - "clippy", - "--workspace", - "--all-targets", - "--", - "-Dwarnings", - "-Wclippy::all", - "-Aclippy::upper_case_acronyms", - "-Aclippy::enum-variant-names", - "-Aclippy::result-large-err", - "-Aclippy::mutable-key-type", -] - [build] -rustflags = ["--cfg", "tokio_unstable", "-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes"] - -# TODO(grao): Figure out whether we should enable other cpu features, and whether we should use a different way to configure them rather than list every single one here. -[target.x86_64-unknown-linux-gnu] -rustflags = ["--cfg", "tokio_unstable", "-C", "link-arg=-fuse-ld=lld", "-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes", "-C", "target-feature=+sse4.2"] - -# 64 bit MSVC -[target.x86_64-pc-windows-msvc] -rustflags = [ - "--cfg", - "tokio_unstable", - "-C", - "force-frame-pointers=yes", - "-C", - "force-unwind-tables=yes", - "-C", - "link-arg=/STACK:8000000" # Set stack to 8 MB -] +rustflags = ["--cfg", "tokio_unstable"] diff --git a/m1/flake.lock b/m1/flake.lock new file mode 100644 index 00000000..420f3ea0 --- /dev/null +++ b/m1/flake.lock @@ -0,0 +1,130 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1707689078, + "narHash": "sha256-UUGmRa84ZJHpGZ1WZEBEUOzaPOWG8LZ0yPg1pdDF/yM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f9d39fb9aff0efee4a3d5f4a6d7c17701d38a1d8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "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": 1707790272, + "narHash": "sha256-KQXPNl3BLdRbz7xx+mwIq/017fxLRk6JhXHxVWCKsTU=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "8dfbe2dffc28c1a18a29ffa34d5d0b269622b158", + "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/m1/flake.nix b/m1/flake.nix new file mode 100644 index 00000000..95ba29b1 --- /dev/null +++ b/m1/flake.nix @@ -0,0 +1,56 @@ +{ + description = "A devShell example"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }@inputs: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + darwinFrameworks = if system == "x86_64-darwin" then with pkgs.darwin.apple_sdk.frameworks; [ + IOKit + SystemConfiguration + AppKit + ] else []; + in + with pkgs; + { + devShells.default = mkShell { + buildInputs = [ + pkgs.clang_14 + zlib + bzip2 + lz4 + snappy + zstd + rocksdb + openssl + pkg-config + eza + fd + rust-bin.beta.latest.default + ] ++ darwinFrameworks; + + shellHook = '' + alias ls=eza + alias find=fd + + echo "> Entered Nix-powered M1 simulator environment" + export OLD_PS1="$PS1" + PS1="(M1-nix) $PS1" + + # Set MACOSX_DEPLOYMENT_TARGET for compatibility + export MACOSX_DEPLOYMENT_TARGET="10.13" + echo "MACOSX_DEPLOYMENT_TARGET set to: $MACOSX_DEPLOYMENT_TARGET" + ''; + }; + } + ); +} diff --git a/m1/scripts/default.nix b/m1/scripts/default.nix deleted file mode 100644 index 02177a58..00000000 --- a/m1/scripts/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ pkgs ? import {}, darwin ? pkgs.darwin }: - -pkgs.mkShell rec { - name = "simulator"; - buildInputs = with pkgs; [ - clang - libiconv - rustup - zlib - ] ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.IOKit - darwin.apple_sdk.frameworks.SystemConfiguration - darwin.apple_sdk.frameworks.AppKit - libcxx - ]; - - RUSTC_VERSION = builtins.readFile ./rust-toolchain; - - shellHook = '' - export MACOSX_DEPLOYMENT_TARGET=10.13 - export CC="$(which clang)" - export CXX="$(which clang++)" - export RUSTFLAGS="-C link-arg=-stdlib=libc++ -C link-arg=-lc++" - export LDFLAGS="-stdlib=libc++ -lc++" - export LDFLAGS="$LDFLAGS -v" - - # Configure rustup to use the specified Rust version - rustup override set $RUSTC_VERSION - - echo "Welcome to the movement simulator for the M1 network" - - # Run 'env' to validate the environment variables setup - env - ''; -} diff --git a/m1/scripts/rust-toolchain b/m1/scripts/rust-toolchain deleted file mode 100644 index 5e3a4256..00000000 --- a/m1/scripts/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.73.0 diff --git a/m1/scripts/simulator.sh b/m1/scripts/simulator.sh index f736df0b..3444010e 100755 --- a/m1/scripts/simulator.sh +++ b/m1/scripts/simulator.sh @@ -1,7 +1,4 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash - -# Dummy function placeholders for actual commands that would be implemented +# run nix develop then call this script init_env() { echo "Initializing Environment"