From 32dd33ba7bbf0bf6d09eb99ba5966f608cb53831 Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Tue, 19 Nov 2024 19:40:57 +0000 Subject: [PATCH] fix: add shell nix --- shell.nix | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..da5c8c6295 --- /dev/null +++ b/shell.nix @@ -0,0 +1,71 @@ +# Cross-platform Rust Setup: https://zeroes.dev/p/nix-recipe-for-rust/ + +let + # Pull new Rust packages + moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/9b11a87c0cc54e308fa83aac5b4ee1816d5418a2.tar.gz); + + # Overlay package + pkgs = import (fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz"; + }) { overlays = [ moz_overlay ]; }; +in + pkgs.mkShell { + name = "rivet"; + + buildInputs = with pkgs; [ + # Tools + cloc + curl + docker-client # Standardize client CLI since older clients have breaking changes + git-lfs + jq + openssh # ssh-keygen + + python310Packages.detect-secrets + + # Compilers + clang + llvm + lld + pkg-config + pkgs.latest.rustChannels.stable.rust + + # Libraries + openssl + + # Autocomplete + bashInteractive + bash-completion + + # Utilities + netcat + + # Fixes "cannot change locale" warning + glibcLocales + ] + ++ extraInputs + ++ ( + pkgs.lib.optionals stdenv.isDarwin [ + libiconv # See https://stackoverflow.com/a/69732679 + darwin.apple_sdk.frameworks.Security + darwin.apple_sdk.frameworks.CoreServices + darwin.apple_sdk.frameworks.CoreFoundation + darwin.apple_sdk.frameworks.Foundation + ] + ); + shellHook = '' + # Setup Git LFS + git lfs install --manual > /dev/null + + # Install autocomplete + source ${pkgs.bash-completion}/share/bash-completion/bash_completion + + # Fix dynamic library path to fix issue with Python + export LD_LIBRARY_PATH="${pkgs.clang}/resource-root/lib:${pkgs.lib.strings.makeLibraryPath [ pkgs.openssl ]}" + + # Set default Rust flags to match the Rust flags used inside of Bolt. + # + # If these don't match, then the build cache is purged any time Rust is ran from Bolt. + export RUSTFLAGS="--cfg tokio_unstable" + ''; + }