-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nix flake for subnet bundling avalanche
- Loading branch information
1 parent
77d8a0c
commit 6fe378a
Showing
3 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ pkgs ? import <nixpkgs> {} }: | ||
|
||
pkgs.buildGoModule rec { | ||
pname = "avalanche-network-runner"; | ||
version = "1.75"; | ||
|
||
src = pkgs.fetchFromGitHub { | ||
owner = "ava-labs"; | ||
repo = pname; | ||
rev = "v${version}"; | ||
sha256 = "A54KNB9BGKvGp2UsP46U5HteiCOOKrnYatDXUAc/BIg="; | ||
}; | ||
|
||
vendorHash = null; | ||
vendor = true; | ||
|
||
nativeBuildInputs = with pkgs; [git cacert blst]; | ||
buildInputs = with pkgs; [cacert blst]; | ||
|
||
buildPhase = '' | ||
export GOPROXY=direct | ||
go build -v -ldflags="-X 'github.com/ava-labs/avalanche-network-runner/cmd.Version=${version}'" -mod=readonly | ||
''; | ||
|
||
installPhase = '' | ||
install -Dm755 ./avalanche-network-runner $out/bin/avalanche-network-runner | ||
''; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{ | ||
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, | ||
... | ||
}: | ||
flake-utils.lib.eachSystem ["aarch64-darwin" "x86_64-linux"] ( | ||
system: let | ||
overlays = [(import rust-overlay)]; | ||
pkgs = import nixpkgs { | ||
inherit system overlays; | ||
}; | ||
avalanche-network-runner = import ./avalanche-network-runner.nix { inherit pkgs; }; | ||
|
||
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; | ||
|
||
rustPlatform = pkgs.makeRustPlatform { | ||
cargo = rust; | ||
rustc = rust; | ||
}; | ||
|
||
runtimeDependencies = with pkgs; [ | ||
openssl | ||
]; | ||
|
||
frameworks = pkgs.darwin.apple_sdk.frameworks; | ||
|
||
buildDependencies = with pkgs; [ | ||
libclang.lib | ||
libz | ||
clang | ||
pkg-config | ||
rustPlatform.bindgenHook] | ||
++ runtimeDependencies | ||
++ lib.optionals stdenv.isDarwin [ | ||
frameworks.Security | ||
frameworks.CoreServices | ||
frameworks.SystemConfiguration | ||
frameworks.AppKit | ||
]; | ||
|
||
developmentDependencies = with pkgs; [ | ||
rust | ||
avalanchego | ||
avalanche-network-runner | ||
] | ||
++ buildDependencies; | ||
|
||
subnet-cargo-toml = builtins.fromTOML (builtins.readFile ./subnet/Cargo.toml); | ||
in | ||
with pkgs; { | ||
packages = flake-utils.lib.flattenTree rec { | ||
subnet = rustPlatform.buildRustPackage { | ||
pname = subnet-cargo-toml.package.name; | ||
version = subnet-cargo-toml.package.version; | ||
|
||
env = { LIBCLANG_PATH = "${libclang.lib}/lib"; } | ||
// (lib.optionalAttrs (stdenv.cc.isClang && stdenv.isDarwin) { NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; }); | ||
|
||
src = ./.; | ||
cargoLock = { | ||
lockFile = ./Cargo.lock; | ||
}; | ||
|
||
nativeBuildInputs = buildDependencies; | ||
buildInputs = runtimeDependencies; | ||
|
||
doCheck = false; | ||
}; | ||
|
||
default = subnet; | ||
}; | ||
|
||
devShells.default = mkShell { | ||
NIX_LDFLAGS="-l${stdenv.cc.libcxx.cxxabi.libName}"; | ||
buildInputs = developmentDependencies; | ||
shellHook = '' | ||
export PATH=$PATH:${avalanche-network-runner}/bin | ||
export LIBCLANG_PATH="${pkgs.libclang.lib}/lib" | ||
''; | ||
}; | ||
} | ||
); | ||
} |