feat: added new packages

This commit is contained in:
Andrew Rioux
2025-02-01 15:59:56 -05:00
parent f5afd60086
commit b416f35b63
28 changed files with 425 additions and 358 deletions
+78 -57
View File
@@ -30,43 +30,44 @@ let
src = craneLib.cleanCargoSource ./.;
fileSetForBeaconCrate = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./.cargo/config.toml
./Cargo.toml
./Cargo.lock
./build_common.rs
./unix-loader/src/abi.h
(craneLib.fileset.commonCargoSources ./sparse-actions)
(craneLib.fileset.commonCargoSources ./pcap-sys)
(craneLib.fileset.commonCargoSources ./nl-sys)
./nl-sys/src/bridge.c
(craneLib.fileset.commonCargoSources ./packets)
(craneLib.fileset.commonCargoSources ./sparse-infector)
(craneLib.fileset.commonCargoSources ./sparse-beacon)
(craneLib.fileset.commonCargoSources ./sparse-unix-beacon)
(craneLib.fileset.commonCargoSources ./sparse-windows-beacon)
];
};
fileSetForBeaconCrate = beacon: infector:
pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./.cargo/config.toml
./Cargo.toml
./Cargo.lock
./build_common.rs
./unix-loader/src/abi.h
(craneLib.fileset.commonCargoSources ./sparse-actions)
(craneLib.fileset.commonCargoSources ./pcap-sys)
(craneLib.fileset.commonCargoSources ./nl-sys)
./nl-sys/src/bridge.c
(craneLib.fileset.commonCargoSources ./packets)
(craneLib.fileset.commonCargoSources infector)
(craneLib.fileset.commonCargoSources ./sparse-beacon)
(craneLib.fileset.commonCargoSources beacon)
];
};
fileSetForInstallerCrate = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./.cargo/config.toml
./Cargo.toml
./Cargo.lock
./build_common.rs
./unix-loader/src/abi.h
(craneLib.fileset.commonCargoSources ./sparse-actions)
(craneLib.fileset.commonCargoSources ./pcap-sys)
(craneLib.fileset.commonCargoSources ./nl-sys)
./nl-sys/src/bridge.c
(craneLib.fileset.commonCargoSources ./packets)
(craneLib.fileset.commonCargoSources ./sparse-infector)
(craneLib.fileset.commonCargoSources ./sparse-installer)
];
};
fileSetForInstallerCrate = installer: infector:
pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./.cargo/config.toml
./Cargo.toml
./Cargo.lock
./build_common.rs
./unix-loader/src/abi.h
(craneLib.fileset.commonCargoSources ./sparse-actions)
(craneLib.fileset.commonCargoSources ./pcap-sys)
(craneLib.fileset.commonCargoSources ./nl-sys)
./nl-sys/src/bridge.c
(craneLib.fileset.commonCargoSources ./packets)
(craneLib.fileset.commonCargoSources infector)
(craneLib.fileset.commonCargoSources installer)
];
};
fileSetForWebCrate = pkgs.lib.fileset.toSource {
root = ./.;
@@ -81,10 +82,10 @@ let
(craneLib.fileset.commonCargoSources ./nl-sys)
./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/.sqlx
./sparse-server/migrations
];
};
@@ -111,7 +112,6 @@ let
};
windowsArgs = commonArgs // {
src = fileSetForBeaconCrate;
doCheck = false;
nativeBuildInputs = buildTools.linux ++ buildTools.windows;
@@ -135,17 +135,17 @@ let
cargoArtifacts = linuxCargoArtifacts;
name = "sparse-beacon-linux";
cargoExtraArgs = "-p sparse-unix-beacon";
src = fileSetForBeaconCrate;
src = fileSetForBeaconCrate ./sparse-unix-beacon ./sparse-unix-infector;
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
});
sparse-beacon-freebsd-sysv = craneLib.buildPackage (freebsdArgs // {
src = fileSetForBeaconCrate;
cargoArtifacts = freebsdCargoArtifacts;
name = "sparse-beacon-freebsd";
cargoExtraArgs = "-p sparse-unix-beacon";
src = fileSetForBeaconCrate ./sparse-unix-beacon ./sparse-unix-infector;
nativeBuildInputs = buildTools.linux ++ buildTools.freebsd;
@@ -160,6 +160,8 @@ let
cargoArtifacts = windowsCargoArtifacts;
name = "sparse-beacon-windows";
cargoExtraArgs = "-p sparse-windows-beacon";
src =
fileSetForBeaconCrate ./sparse-windows-beacon ./sparse-windows-infector;
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
@@ -210,36 +212,57 @@ let
sparse-installer-linux = craneLib.buildPackage (commonArgs // {
cargoArtifacts = linuxCargoArtifacts;
name = "sparse-installer-linux";
cargoExtraArgs = "-p sparse-installer";
src = fileSetForInstallerCrate;
cargoExtraArgs = "-p sparse-unix-installer";
src =
fileSetForInstallerCrate ./sparse-unix-installer ./sparse-unix-infector;
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
SPARSE_INSTALLER_LINUX = "${linux-loader}/lib/libunix-loader.so";
SPARSE_LOADER_LINUX = "${linux-loader}/lib/libunix-loader.so";
});
sparse-installer-freebsd-sysv = craneLib.buildPackage (commonArgs // {
cargoArtifacts = linuxCargoArtifacts;
name = "sparse-installer-linux";
cargoExtraArgs = "-p sparse-installer";
src = fileSetForInstallerCrate;
name = "sparse-installer-freebsd";
cargoExtraArgs = "-p sparse-unix-installer";
src =
fileSetForInstallerCrate ./sparse-unix-installer ./sparse-unix-infector;
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
SPARSE_INSTALLER_FREEBSD = "${freebsd-loader}/lib/libunix-loader.so";
SPARSE_LOADER_FREEBSD = "${freebsd-loader}/lib/libunix-loader.so";
});
sparse-installer-freebsd =
patch-freebsd-elf sparse-installer-freebsd-sysv "bin/sparse-installer";
patch-freebsd-elf sparse-installer-freebsd-sysv "bin/sparse-unix-installer";
sparse-installer-windows = craneLib.buildPackage (windowsArgs // {
cargoArtifacts = windowsCargoArtifacts;
name = "sparse-installer-windows";
cargoExtraArgs = "-p sparse-windows-installer";
src = fileSetForInstallerCrate ./sparse-windows-installer
./sparse-windows-infector;
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
SPARSE_BEACON_WINDOWS =
"${sparse-beacon-windows}/bin/sparse-windows-beacon.exe";
});
sparse-server = craneLib.buildPackage (commonArgs // {
src = fileSetForWebCrate;
nativeBuildInputs = buildTools.linux ++ (with pkgs; [ glibc.static ]);
cargoArtifacts = linuxCargoArtifacts;
name = "sparse-server-webclient";
preBuild = ''
export DATABASE_URL=sqlite:./db.sqlite3
sqlx database setup --source=sparse-server/migrations
'';
buildPhaseCargoCommand = ''
cargo leptos build \
--release \
@@ -255,20 +278,18 @@ let
RUSTFLAGS = "-Ctarget-feature=+crt-static";
SPARSE_INSTALLER_LINUX = "${sparse-installer-linux}/bin/sparse-installer";
SPARSE_INSTALLER_LINUX =
"${sparse-installer-linux}/bin/sparse-unix-installer";
SPARSE_INSTALLER_FREEBSD =
"${sparse-installer-freebsd}/bin/sparse-installer";
SPARSE_BEACON_LINUX = "${sparse-beacon-linux}/bin/sparse-unix-beacon";
SPARSE_BEACON_FREEBSD = "${sparse-beacon-freebsd}/bin/sparse-unix-beacon";
SPARSE_BEACON_WINDOWS =
"${sparse-beacon-windows}/bin/sparse-windows-beacon.exe";
"${sparse-installer-freebsd}/bin/sparse-unix-installer";
SPARSE_INSTALLER_WINDOWS =
"${sparse-installer-windows}/bin/sparse-windows-installer.exe";
});
outputs = rec {
packages = {
inherit sparse-server sparse-beacon-linux sparse-beacon-windows
sparse-installer-linux sparse-installer-freebsd linux-loader
freebsd-loader sparse-beacon-freebsd;
inherit sparse-server sparse-installer-linux sparse-installer-freebsd
sparse-installer-windows;
inherit freebsd-zig-libc;