feat: fixed server comp, added ELF inject
I gave up and just put it in a Docker image, it's not as important as the beacons being statically compiled
This commit is contained in:
+49
-24
@@ -1,6 +1,6 @@
|
||||
{ pkgs, buildTools, buildEnvironment, craneLib, advisory-db, winpcap-libs
|
||||
, winpcap-drivers, freebsd-libs, libnl, libpcap-linux-musl, libpcap-linux-gnu
|
||||
, libpcap-freebsd }:
|
||||
, winpcap-drivers, freebsd-libs, libnl, libcap, libpcap-linux-musl
|
||||
, libpcap-linux-gnu, libpcap-freebsd }:
|
||||
let
|
||||
patch-elf = header: drv: path:
|
||||
let hdr = toString header;
|
||||
@@ -83,21 +83,29 @@ let
|
||||
./nl-sys/src/bridge.c
|
||||
(craneLib.fileset.commonCargoSources ./packets)
|
||||
(craneLib.fileset.commonCargoSources ./sparse-handler)
|
||||
(craneLib.fileset.commonCargoSources ./sparse-server)
|
||||
./sparse-server/style
|
||||
./sparse-server/public
|
||||
./sparse-server/migrations
|
||||
./sparse-server/.sqlx
|
||||
./sparse-handler/.sqlx
|
||||
(craneLib.fileset.commonCargoSources ./sparse-server)
|
||||
];
|
||||
};
|
||||
|
||||
commonArgs = buildEnvironment // {
|
||||
inherit src;
|
||||
strictDeps = true;
|
||||
#strictDeps = true;
|
||||
|
||||
nativeBuildInputs = buildTools.linux;
|
||||
buildInputs = buildTools.all;
|
||||
};
|
||||
|
||||
linuxArgs = commonArgs // {
|
||||
nativeBuildInputs = buildTools.linux ++ (with pkgs; [ musl ]);
|
||||
|
||||
#RUSTFLAGS = "-Ctarget-feature=+crt-static";
|
||||
};
|
||||
|
||||
freebsdArgs = commonArgs // {
|
||||
# Sigh...
|
||||
# For some reason, crane and cargo don't run the build script for FreeBSD
|
||||
@@ -117,21 +125,29 @@ let
|
||||
nativeBuildInputs = buildTools.linux ++ buildTools.windows;
|
||||
};
|
||||
|
||||
linuxCargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
|
||||
gnuLinuxCargoArtifacts = craneLib.buildDepsOnly (linuxArgs // {
|
||||
nativeBuildInputs = buildTools.linux ++ (with pkgs; [ glibc.static ]);
|
||||
name = "sparse-deps-gnu-linux";
|
||||
cargoExtraArgs =
|
||||
"--target=x86_64-unknown-linux-gnu --locked -p sparse-server";
|
||||
});
|
||||
linuxCargoArtifacts = craneLib.buildDepsOnly (linuxArgs // {
|
||||
name = "sparse-deps-linux";
|
||||
cargoExtraArgs = "--target=x86_64-unknown-linux-musl --locked";
|
||||
cargoExtraArgs =
|
||||
"--target=x86_64-unknown-linux-musl --locked -p sparse-unix-beacon -p sparse-unix-installer";
|
||||
});
|
||||
freebsdCargoArtifacts = craneLib.buildDepsOnly (freebsdArgs // {
|
||||
name = "sparse-deps-freebsd";
|
||||
cargoExtraArgs =
|
||||
"--target=x86_64-unknown-freebsd --locked -p sparse-beacon";
|
||||
"--target=x86_64-unknown-freebsd --locked -p sparse-unix-beacon -p sparse-unix-installer";
|
||||
});
|
||||
windowsCargoArtifacts = craneLib.buildDepsOnly (windowsArgs // {
|
||||
name = "sparse-deps-windows";
|
||||
cargoExtraArgs = "--target=x86_64-pc-windows-gnu --locked -p sparse-beacon";
|
||||
cargoExtraArgs =
|
||||
"--target=x86_64-pc-windows-gnu --locked -p sparse-windows-beacon -p sparse-windows-installer";
|
||||
});
|
||||
|
||||
sparse-beacon-linux = craneLib.buildPackage (commonArgs // {
|
||||
sparse-beacon-linux = craneLib.buildPackage (linuxArgs // {
|
||||
cargoArtifacts = linuxCargoArtifacts;
|
||||
name = "sparse-beacon-linux";
|
||||
cargoExtraArgs = "-p sparse-unix-beacon";
|
||||
@@ -178,6 +194,7 @@ let
|
||||
mkdir $out
|
||||
export XDG_CACHE_HOME=$(mktemp -d)
|
||||
zig build \
|
||||
--color off \
|
||||
--summary all \
|
||||
--prefix $out \
|
||||
--release=small \
|
||||
@@ -200,6 +217,7 @@ let
|
||||
mkdir $out
|
||||
export XDG_CACHE_HOME=$(mktemp -d)
|
||||
zig build \
|
||||
--color off \
|
||||
--summary all \
|
||||
--prefix $out \
|
||||
--release=small \
|
||||
@@ -213,7 +231,7 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
sparse-installer-linux = craneLib.buildPackage (commonArgs // {
|
||||
sparse-installer-linux = craneLib.buildPackage (linuxArgs // {
|
||||
cargoArtifacts = linuxCargoArtifacts;
|
||||
name = "sparse-installer-linux";
|
||||
cargoExtraArgs = "-p sparse-unix-installer";
|
||||
@@ -226,7 +244,7 @@ let
|
||||
SPARSE_LOADER = "${linux-loader}/lib/libunix-loader-linux.so";
|
||||
});
|
||||
|
||||
sparse-installer-freebsd-sysv = craneLib.buildPackage (commonArgs // {
|
||||
sparse-installer-freebsd-sysv = craneLib.buildPackage (freebsdArgs // {
|
||||
cargoArtifacts = linuxCargoArtifacts;
|
||||
name = "sparse-installer-freebsd";
|
||||
cargoExtraArgs = "-p sparse-unix-installer";
|
||||
@@ -256,32 +274,29 @@ let
|
||||
"${sparse-beacon-windows}/bin/sparse-windows-beacon.exe";
|
||||
});
|
||||
|
||||
sparse-server = craneLib.buildPackage (commonArgs // {
|
||||
src = fileSetForWebCrate;
|
||||
sparse-server = craneLib.mkCargoDerivation (commonArgs // {
|
||||
src = (builtins.trace "${fileSetForWebCrate}") fileSetForWebCrate;
|
||||
|
||||
cargoArtifacts = gnuLinuxCargoArtifacts;
|
||||
|
||||
nativeBuildInputs = buildTools.linux ++ (with pkgs; [ glibc.static ]);
|
||||
cargoArtifacts = linuxCargoArtifacts;
|
||||
name = "sparse-server-webclient";
|
||||
pname = "sparse-server-webclient";
|
||||
|
||||
preBuild = ''
|
||||
export DATABASE_URL=sqlite:./db.sqlite3
|
||||
sqlx database setup --source=sparse-server/migrations
|
||||
'';
|
||||
buildPhaseCargoCommand = ''
|
||||
cargo leptos build \
|
||||
--release \
|
||||
--project=sparse-server
|
||||
'';
|
||||
doNotPostBuildInstallCargoBinaries = true;
|
||||
installPhase = ''
|
||||
doInstallCartoArtifacts = false;
|
||||
installPhaseCommand = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
cp target/x86_64-unknown-linux-gnu/release/sparse-server $out/bin
|
||||
'';
|
||||
doCheck = false;
|
||||
|
||||
RUSTFLAGS = "-Ctarget-feature=+crt-static";
|
||||
|
||||
SPARSE_INSTALLER_LINUX =
|
||||
"${sparse-installer-linux}/bin/sparse-unix-installer";
|
||||
SPARSE_INSTALLER_FREEBSD =
|
||||
@@ -290,11 +305,21 @@ let
|
||||
"${sparse-installer-windows}/bin/sparse-windows-installer.exe";
|
||||
});
|
||||
|
||||
sparse-server-docker = pkgs.dockerTools.buildImage {
|
||||
name = "sparse-server-docker";
|
||||
tag = "latest";
|
||||
|
||||
copyToRoot = [ sparse-server ];
|
||||
|
||||
config = { Cmd = [ "${sparse-server}/bin/sparse-server" ]; };
|
||||
};
|
||||
|
||||
outputs = rec {
|
||||
packages = {
|
||||
inherit sparse-server sparse-beacon-linux sparse-beacon-freebsd
|
||||
sparse-beacon-windows linux-loader freebsd-loader sparse-installer-linux
|
||||
sparse-installer-freebsd sparse-installer-windows;
|
||||
inherit sparse-server sparse-server-docker sparse-beacon-linux
|
||||
sparse-beacon-freebsd sparse-beacon-windows linux-loader freebsd-loader
|
||||
sparse-installer-linux sparse-installer-freebsd
|
||||
sparse-installer-windows;
|
||||
|
||||
inherit freebsd-zig-libc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user