Split flake into parts

This commit is contained in:
Pim Kunis 2024-12-25 12:02:54 +01:00
parent 95cf4c4270
commit 8aff4fee3f
3 changed files with 40 additions and 27 deletions

12
dev-shells.nix Normal file
View file

@ -0,0 +1,12 @@
{
flake-utils,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [bpftools bpftop];
};
})

View file

@ -6,31 +6,8 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: outputs = inputs @ {flake-utils, ...}: flake-utils.lib.meld inputs [
let ./dev-shells.nix
pkgs = inputs.nixpkgs.legacyPackages.${system}; ./packages.nix
];
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
'';
};
in
{
packages = {
dropworld = mkEbpfProg "dropworld" ./dropworld;
tcpfilter = mkEbpfProg "tcpfilter" ./tcpfilter;
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [bpftools bpftop];
};
}
);
} }

24
packages.nix Normal file
View file

@ -0,0 +1,24 @@
{
flake-utils,
nixpkgs,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = 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
'';
};
in {
packages = {
dropworld = mkEbpfProg "dropworld" ./dropworld;
tcpfilter = mkEbpfProg "tcpfilter" ./tcpfilter;
};
})