-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
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,53 @@ | ||
{ lib | ||
, stdenv | ||
, rustPlatform | ||
, fetchFromGitHub | ||
, llvmPackages_16 | ||
, zlib | ||
, ncurses | ||
, libxml2 | ||
, useRustLlvm ? false | ||
}: | ||
|
||
rustPlatform.buildRustPackage rec { | ||
pname = "bpf-linker"; | ||
version = "0.9.10"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "aya-rs"; | ||
repo = pname; | ||
rev = "v${version}"; | ||
hash = "sha256-EIZqeqCCnRqJIuhX5Dj9ogZCgFGfA2ukoPwU8AzYupI="; | ||
}; | ||
|
||
cargoHash = "sha256-jLbQ49fxLROEAgokbVAy8yDIRe/MhFJxutRzSEtlnEk="; | ||
|
||
buildNoDefaultFeatures = !useRustLlvm; | ||
|
||
nativeBuildInputs = lib.optional (!useRustLlvm) llvmPackages_16.llvm; | ||
buildInputs = [ zlib ncurses libxml2 ]; | ||
|
||
# aya-rustc-llvm-proxy will run cargo-metadata from $cargoDeps, so we need to fixup the .cargo/config there. | ||
postPatch = lib.optionalString useRustLlvm '' | ||
substituteInPlace $cargoDepsCopy/.cargo/config --replace @vendor@ $cargoDepsCopy | ||
''; | ||
|
||
# fails with: couldn't find crate `core` with expected target triple bpfel-unknown-none | ||
# rust-src and `-Z build-std=core` are required to properly run the tests | ||
doCheck = false; | ||
|
||
# Work around https://github.com/NixOS/nixpkgs/issues/166205. | ||
env = lib.optionalAttrs stdenv.cc.isClang { | ||
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; | ||
}; | ||
|
||
meta = with lib; { | ||
description = "Simple BPF static linker"; | ||
homepage = "https://github.com/aya-rs/bpf-linker"; | ||
license = with licenses; [ asl20 mit ]; | ||
maintainers = with maintainers; [ nickcao ]; | ||
# llvm-sys crate locates llvm by calling llvm-config | ||
# which is not available when cross compiling | ||
broken = stdenv.buildPlatform != stdenv.hostPlatform; | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
{pkgs ? import <nixpkgs> {}}: | ||
pkgs.mkShell { | ||
buildInputs = with pkgs; [udev]; | ||
nativeBuildInputs = with pkgs; [rustup pkg-config]; | ||
nativeBuildInputs = with pkgs; [ | ||
rustup | ||
pkg-config | ||
(pkgs.callPackage deps/bpf-linker.nix { useRustLlvm = true; }) | ||
|
||
# For llvm-objdump | ||
llvmPackages.bintools | ||
]; | ||
} |