118 lines
2.9 KiB
Nix
118 lines
2.9 KiB
Nix
{
|
|
description = "Sparse C2 framework";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
crane = {
|
|
url = "github:ipetkov/crane";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
libpcap-src = {
|
|
url = "git+https://github.com/the-tcpdump-group/libpcap";
|
|
flake = false;
|
|
};
|
|
libnl = {
|
|
url = "git+https://github.com/thom311/libnl";
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{ self, nixpkgs, flake-utils, crane, rust-overlay, libpcap-src, libnl }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ (import rust-overlay) ];
|
|
};
|
|
|
|
buildTools = with pkgs; [
|
|
autoconf
|
|
automake
|
|
bison
|
|
cmake
|
|
flex
|
|
libtool
|
|
libpcap
|
|
musl
|
|
pkg-config
|
|
];
|
|
|
|
toolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile
|
|
./rust-toolchain.toml;
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
|
|
|
src = craneLib.path ./.;
|
|
|
|
commonArgs = {
|
|
inherit src;
|
|
|
|
#strictDeps = true;
|
|
|
|
#CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
|
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
|
|
|
SPARSE_BUILD_LIBPCAP = "${libpcap-src}";
|
|
#SPARSE_BUILD_LIBNL = "${libnl}";
|
|
};
|
|
|
|
commonWindowsArgs = commonArgs // {
|
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
|
};
|
|
|
|
artifacts = craneLib.buildDepsOnly commonArgs;
|
|
windowsArtifacts = craneLib.buildDepsOnly commonWindowsArgs;
|
|
|
|
sparse-c2-linux-beacon = craneLib.buildPackage (commonArgs // {
|
|
inherit artifacts;
|
|
|
|
pname = "sparse-c2-beacon";
|
|
cargoExtraArgs = "-p sparse-c2-beacon --locked";
|
|
doCheck = false;
|
|
|
|
nativeBuildInputs = buildTools;
|
|
buildInputs = buildTools;
|
|
});
|
|
|
|
crate = craneLib.buildPackage (commonArgs // {
|
|
inherit artifacts;
|
|
buildInputs = buildTools;
|
|
});
|
|
in with pkgs; {
|
|
devShells.default = craneLib.devShell rec {
|
|
name = "sparse";
|
|
|
|
buildInputs = buildTools;
|
|
|
|
SPARSE_BUILD_LIBPCAP = "${libpcap-src}";
|
|
#SPARSE_BUILD_LIBNL = "${libnl}";
|
|
};
|
|
|
|
packages = rec {
|
|
inherit sparse-c2-linux-beacon;
|
|
|
|
default = sparse-c2-linux-beacon;
|
|
|
|
windows = craneLib.buildPackage (commonArgs // {
|
|
doCheck = false;
|
|
|
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
|
|
|
depsBuildBuild = [
|
|
pkgsCross.mingwW64.stdenv.cc
|
|
pkgsCross.mingwW64.windows.pthreads
|
|
];
|
|
|
|
artifacts = windowsArtifacts;
|
|
});
|
|
};
|
|
});
|
|
}
|