arbi/flake.nix
Andrea Ciceri 7a1e03ee7a
Incomplete prototype
Things

WIP

Format

Work in progress

Work in progres

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress

Work in progress
2025-05-10 10:02:36 +02:00

115 lines
3.6 KiB
Nix

{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-root.url = "github:srid/flake-root";
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
forge-std = {
flake = false;
url = "github:foundry-rs/forge-std/v1.9.6";
};
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } ({ config, lib, ... }: {
systems = [ "x86_64-linux" ];
imports = [
inputs.git-hooks.flakeModule
inputs.treefmt-nix.flakeModule
inputs.flake-root.flakeModule
];
perSystem = { pkgs, config, ... }: {
treefmt.config = {
flakeFormatter = true;
flakeCheck = true;
programs = {
nixpkgs-fmt.enable = true;
rustfmt.enable = true;
};
};
pre-commit = {
check.enable = false;
settings.hooks = {
treefmt = {
enable = true;
package = config.treefmt.build.wrapper;
};
};
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [ cargo rustc rust-analyzer clippy foundry ];
inputsFrom = [ config.flake-root.devShell ];
shellHook = ''
# forge will use this directory to download the solc compilers
mkdir -p $HOME/.svm
# forge needs forge-std to work
mkdir -p $FLAKE_ROOT/onchain/lib/
ln -sf ${inputs.forge-std.outPath} $FLAKE_ROOT/onchain/lib/forge-std
if [ ! -f "$FLAKE_ROOT/offchain/config.kdl" ]; then \
cp ${config.packages.arbi_sample_config_kdl} $FLAKE_ROOT/offchain/config.kdl
fi
export ARBI_CONFIG="$FLAKE_ROOT/offchain/config.kdl"
${config.pre-commit.installationScript}
'';
env = {
OPENSSL_DIR = pkgs.openssl.dev;
OPENSSL_NO_VENDOR = true;
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig:$PKG_CONFIG_PATH";
RUST_BACKTRACE = true;
ARBI_LOG_LEVEL = "debug";
};
};
packages = {
default = config.packages.arbi;
arbi = pkgs.rustPlatform.buildRustPackage {
pname = "arbi";
version = "0.1.0";
cargoLock.lockFile = ./offchain/Cargo.lock;
src = ./offchain;
env = {
OPENSSL_DIR = pkgs.openssl.dev;
OPENSSL_NO_VENDOR = true;
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig:$PKG_CONFIG_PATH";
};
};
arbi_sample_config_kdl = pkgs.writeText "arbi-sample-config.kdl" ''
endpoint "wss://eth-mainnet.g.alchemy.com/v2/<REDACTED>"
pairs_file "pairs.json"
'';
};
checks = {
inherit (config.packages) arbi;
};
};
flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
checks = lib.getAttrs [ "x86_64-linux" ] config.flake.checks;
};
});
}