Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
64 changes: 64 additions & 0 deletions flake.lock

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

96 changes: 96 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};

crane.url = "github:ipetkov/crane";
};

outputs = { self, nixpkgs, rust-overlay, crane }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

mkPkgs = system: import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};

rustToolchain = pkgs: pkgs.rust-bin.stable."1.92.0".default.override {
extensions = [ "clippy" "rustfmt" ];
};

mkCraneLib = pkgs: (crane.mkLib pkgs).overrideToolchain (rustToolchain pkgs);
in
{
packages = forAllSystems (system:
let
pkgs = mkPkgs system;
craneLib = mkCraneLib pkgs;

commonArgs = {
pname = "ethlambda";
src = craneLib.cleanCargoSource ./.;
strictDeps = true;

nativeBuildInputs = with pkgs; [
pkg-config
];

buildInputs = with pkgs; [
llvmPackages.libclang
] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin (with pkgs; [
libiconv
apple-sdk_15
]);

LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";

# vergen-git2 falls back to env vars when .git is absent
VERGEN_GIT_SHA = self.shortRev or self.dirtyShortRev or "unknown";
VERGEN_GIT_BRANCH = "nix";
};

cargoArtifacts = craneLib.buildDepsOnly commonArgs;

ethlambda = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
# Only install the main binary
cargoExtraArgs = "--bin ethlambda";
});
in
{
default = ethlambda;
inherit ethlambda;
}
);

devShells = forAllSystems (system:
let
pkgs = mkPkgs system;
in
{
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(rustToolchain pkgs)
pkg-config
cargo-watch
];

buildInputs = with pkgs; [
llvmPackages.libclang
] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin (with pkgs; [
libiconv
apple-sdk_15
]);

LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
}
);
};
}