feat: fixed pcap linking and added nix packages
This commit is contained in:
@@ -10,6 +10,10 @@
|
||||
};
|
||||
crane.url = "github:ipetkov/crane";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
advisory-db = {
|
||||
url = "github:rustsec/advisory-db";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
libpcap-src = {
|
||||
url = "git+https://github.com/the-tcpdump-group/libpcap";
|
||||
@@ -35,8 +39,9 @@
|
||||
# echo '000007: 09' | xxd -r - target/x86_64-unknown-freebsd/debug/sparse-beacon
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay, libpcap-src
|
||||
, libnl-src, winpcap-libs, winpcap-installer, freebsd-libs-packed }:
|
||||
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay, advisory-db
|
||||
, libpcap-src, libnl-src, winpcap-libs, winpcap-installer
|
||||
, freebsd-libs-packed }:
|
||||
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
@@ -49,11 +54,10 @@
|
||||
freebsd-libs-packed;
|
||||
};
|
||||
inherit (system-libs)
|
||||
bsd-toolchain winpcap-drivers freebsd-libs libnl libpcap-linux
|
||||
libpcap-freebsd;
|
||||
bsd-toolchain winpcap-drivers freebsd-libs libnl libpcap-linux-gnu
|
||||
libpcap-linux-musl libpcap-freebsd;
|
||||
|
||||
buildTools = with pkgs; [
|
||||
mold
|
||||
lld
|
||||
zig
|
||||
clang
|
||||
@@ -64,7 +68,7 @@
|
||||
pkgsCross.mingwW64.windows.pthreads
|
||||
];
|
||||
|
||||
devShellTools = with pkgs; [ rust-analyzer ];
|
||||
devShellTools = with pkgs; [ rust-analyzer taplo cargo-deny ];
|
||||
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain (p:
|
||||
p.rust-bin.stable.latest.default.override {
|
||||
@@ -76,30 +80,33 @@
|
||||
];
|
||||
});
|
||||
|
||||
patch-elf = header: drv: path:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "elf-patch-${header}";
|
||||
buildEnvironment = {
|
||||
SPARSE_BUILD_WINPCAP_LIBS = "${winpcap-libs}/Lib";
|
||||
SPARSE_BUILD_WINPCAP_DRIVERS = "${winpcap-drivers}/npf.sys";
|
||||
SPARSE_BUILD_LIBPCAP_LINUX_GNU = libpcap-linux-gnu;
|
||||
SPARSE_BUILD_LIBPCAP_LINUX_MUSL = libpcap-linux-musl;
|
||||
SPARSE_BUILD_LIBPCAP_FREEBSD = libpcap-freebsd;
|
||||
SPARSE_BUILD_LIBNL = libnl;
|
||||
|
||||
buildInputs = with pkgs; [ vim ];
|
||||
};
|
||||
patch-freebsd-elf = patch-elf 9;
|
||||
FREEBSD_LIBS = freebsd-libs;
|
||||
GLIBC_LIBS = pkgs.glibc;
|
||||
GLIBC_LIBS_STATIC = pkgs.glibc.static;
|
||||
};
|
||||
|
||||
outputs = import ./packages.nix ({
|
||||
inherit pkgs buildTools buildEnvironment craneLib advisory-db
|
||||
winpcap-libs;
|
||||
} // system-libs);
|
||||
in {
|
||||
packages = outputs.packages;
|
||||
checks = outputs.checks;
|
||||
|
||||
devShells = {
|
||||
default = craneLib.devShell {
|
||||
default = craneLib.devShell (buildEnvironment // {
|
||||
name = "sparse-default";
|
||||
|
||||
packages = buildTools ++ devShellTools;
|
||||
|
||||
SPARSE_BUILD_WINPCAP_LIBS = "${winpcap-libs}/Lib";
|
||||
SPARSE_BUILD_WINPCAP_DRIVERS = "${winpcap-drivers}/npf.sys";
|
||||
SPARSE_BUILD_LIBPCAP_LINUX = libpcap-linux;
|
||||
SPARSE_BUILD_LIBPCAP_FREEBSD = libpcap-freebsd;
|
||||
SPARSE_BUILD_LIBNL = libnl;
|
||||
|
||||
FREEBSD_LIBS = freebsd-libs;
|
||||
|
||||
RUSTFLAGS = "-Ctarget-feature=+crt-static";
|
||||
};
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user