ebpf-sandbox/flake.nix

37 lines
928 B
Nix
Raw Normal View History

2024-12-24 15:46:35 +00:00
{
description = "eBPF sandbox";
2024-12-24 15:46:35 +00:00
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
mkEbpfProg = name: src: pkgs.clangStdenv.mkDerivation {
name = "ebpf-${name}";
inherit src;
hardeningDisable = [ "stackprotector" "zerocallusedregs" ];
dontFixup = true;
buildInputs = with pkgs; [ libbpf ];
buildPhase = ''
clang -O2 -target bpf -g -c ${src}/main.c -o $out
'';
};
2024-12-24 15:46:35 +00:00
in
{
2024-12-24 20:34:28 +00:00
packages = {
dropworld = mkEbpfProg "dropworld" ./dropworld;
tcpfilter = mkEbpfProg "tcpfilter" ./tcpfilter;
2024-12-24 20:34:28 +00:00
};
2024-12-24 15:50:16 +00:00
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [bpftools bpftop];
};
2024-12-24 15:46:35 +00:00
}
);
}