Skip to content

Commit

Permalink
Merge pull request #141 from ralexstokes/new-nix
Browse files Browse the repository at this point in the history
New nix
  • Loading branch information
ralexstokes authored Sep 29, 2023
2 parents cb54384 + b706f77 commit b43d864
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
local*
result
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ members = ["bin/mev", "mev-boost-rs", "mev-relay-rs", "mev-build-rs", "mev-rs"]
default-members = ["bin/mev"]

[workspace.package]
name = "mev-rs"
version = "0.3.0"

[workspace.dependencies]
Expand All @@ -25,3 +24,9 @@ revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
revm-primitives = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }

# NOTE: this is not strictly required to build
# but, it works better with the default nix rust build environment
# TODO: remove this patch once we have updated to at least `[email protected]`
[patch.'https://github.com/ethereum/c-kzg-4844']
c-kzg = "0.1.1"
134 changes: 128 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@
description = "flake for `mev-rs` repo";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, flake-utils, nixpkgs }:
outputs = { self, flake-utils, nixpkgs, rust-overlay, crane }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
mev = pkgs.callPackage ./nix/mev.nix { inherit pkgs; crane = craneLib; };
in
{
devShells.default = import ./shell.nix { inherit pkgs lib; };
packages.mev = mev;
devShells.default = import ./shell.nix { inherit pkgs rustToolchain; };
});
}
13 changes: 13 additions & 0 deletions nix/mev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs, crane }:
with pkgs;
let
commonArgs = {
pname = "mev-rs";
src = crane.cleanCargoSource (crane.path ../.);
buildInputs = [ ] ++ lib.optionals pkgs.stdenv.isDarwin [
darwin.apple_sdk.frameworks.Network
];
};
cargoArtifacts = crane.buildDepsOnly commonArgs;
in
crane.buildPackage (commonArgs // { inherit cargoArtifacts; })
10 changes: 4 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{ pkgs, lib }:
{ pkgs, rustToolchain }:
with pkgs;
mkShell {
buildInputs = lib.lists.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Network
] ++ [
iconv
buildInputs = [
just
mdbook
zlib
rustToolchain
];
}

0 comments on commit b43d864

Please sign in to comment.