File tree 2 files changed +61
-1
lines changed
2 files changed +61
-1
lines changed Original file line number Diff line number Diff line change
1
+ { lib
2
+ , stdenv
3
+ , rustPlatform
4
+ , fetchFromGitHub
5
+ , llvmPackages_16
6
+ , zlib
7
+ , ncurses
8
+ , libxml2
9
+ , useRustLlvm ? false
10
+ } :
11
+
12
+ rustPlatform . buildRustPackage rec {
13
+ pname = "bpf-linker" ;
14
+ version = "0.9.10" ;
15
+
16
+ src = fetchFromGitHub {
17
+ owner = "aya-rs" ;
18
+ repo = pname ;
19
+ rev = "v${ version } " ;
20
+ hash = "sha256-EIZqeqCCnRqJIuhX5Dj9ogZCgFGfA2ukoPwU8AzYupI=" ;
21
+ } ;
22
+
23
+ cargoHash = "sha256-jLbQ49fxLROEAgokbVAy8yDIRe/MhFJxutRzSEtlnEk=" ;
24
+
25
+ buildNoDefaultFeatures = ! useRustLlvm ;
26
+
27
+ nativeBuildInputs = lib . optional ( ! useRustLlvm ) llvmPackages_16 . llvm ;
28
+ buildInputs = [ zlib ncurses libxml2 ] ;
29
+
30
+ # aya-rustc-llvm-proxy will run cargo-metadata from $cargoDeps, so we need to fixup the .cargo/config there.
31
+ postPatch = lib . optionalString useRustLlvm ''
32
+ substituteInPlace $cargoDepsCopy/.cargo/config --replace @vendor@ $cargoDepsCopy
33
+ '' ;
34
+
35
+ # fails with: couldn't find crate `core` with expected target triple bpfel-unknown-none
36
+ # rust-src and `-Z build-std=core` are required to properly run the tests
37
+ doCheck = false ;
38
+
39
+ # Work around https://github.com/NixOS/nixpkgs/issues/166205.
40
+ env = lib . optionalAttrs stdenv . cc . isClang {
41
+ NIX_LDFLAGS = "-l${ stdenv . cc . libcxx . cxxabi . libName } " ;
42
+ } ;
43
+
44
+ meta = with lib ; {
45
+ description = "Simple BPF static linker" ;
46
+ homepage = "https://github.com/aya-rs/bpf-linker" ;
47
+ license = with licenses ; [ asl20 mit ] ;
48
+ maintainers = with maintainers ; [ nickcao ] ;
49
+ # llvm-sys crate locates llvm by calling llvm-config
50
+ # which is not available when cross compiling
51
+ broken = stdenv . buildPlatform != stdenv . hostPlatform ;
52
+ } ;
53
+ }
Original file line number Diff line number Diff line change 1
1
{ pkgs ? import <nixpkgs> { } } :
2
2
pkgs . mkShell {
3
3
buildInputs = with pkgs ; [ udev ] ;
4
- nativeBuildInputs = with pkgs ; [ rustup pkg-config ] ;
4
+ nativeBuildInputs = with pkgs ; [
5
+ rustup
6
+ pkg-config
7
+ ( pkgs . callPackage deps/bpf-linker.nix { useRustLlvm = true ; } )
8
+
9
+ # For llvm-objdump
10
+ llvmPackages . bintools
11
+ ] ;
5
12
}
You can’t perform that action at this time.
0 commit comments