feat: added Leptos server
This commit is contained in:
+68
-23
@@ -29,7 +29,42 @@ let
|
||||
buildInputs = buildTools;
|
||||
};
|
||||
|
||||
fileSetForBeaconCrate = pkgs.lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = pkgs.lib.fileset.unions [
|
||||
./.cargo/config.toml
|
||||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
./build_common.rs
|
||||
(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-beacon)
|
||||
];
|
||||
};
|
||||
|
||||
fileSetForWebCrate = pkgs.lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = pkgs.lib.fileset.unions [
|
||||
./.cargo/config.toml
|
||||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
./build_common.rs
|
||||
(craneLib.fileset.commonCargoSources ./pcap-sys)
|
||||
(craneLib.fileset.commonCargoSources ./nl-sys)
|
||||
./nl-sys/src/bridge.c
|
||||
(craneLib.fileset.commonCargoSources ./packets)
|
||||
(craneLib.fileset.commonCargoSources ./sparse-actions)
|
||||
(craneLib.fileset.commonCargoSources ./sparse-server)
|
||||
./sparse-server/style
|
||||
./sparse-server/public
|
||||
];
|
||||
};
|
||||
|
||||
freebsdArgs = commonArgs // {
|
||||
src = fileSetForBeaconCrate;
|
||||
# Sigh...
|
||||
# For some reason, crane and cargo don't run the build script for FreeBSD
|
||||
# It runs it with the dev shell for all 3 targets, and runs it in the
|
||||
@@ -40,7 +75,10 @@ let
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
windowsArgs = commonArgs // { doCheck = false; };
|
||||
windowsArgs = commonArgs // {
|
||||
src = fileSetForBeaconCrate;
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
linuxCargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
|
||||
name = "sparse-deps-linux";
|
||||
@@ -48,40 +86,25 @@ let
|
||||
});
|
||||
freebsdCargoArtifacts = craneLib.buildDepsOnly (freebsdArgs // {
|
||||
name = "sparse-deps-freebsd";
|
||||
cargoExtraArgs = "--target=x86_64-unknown-freebsd --locked";
|
||||
cargoExtraArgs =
|
||||
"--target=x86_64-unknown-freebsd --locked -p sparse-beacon";
|
||||
});
|
||||
windowsCargoArtifacts = craneLib.buildDepsOnly (windowsArgs // {
|
||||
name = "sparse-deps-windows";
|
||||
cargoExtraArgs = "--target=x86_64-pc-windows-gnu --locked";
|
||||
cargoExtraArgs = "--target=x86_64-pc-windows-gnu --locked -p sparse-beacon";
|
||||
});
|
||||
|
||||
fileSetForCrate = crate:
|
||||
pkgs.lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = pkgs.lib.fileset.unions [
|
||||
./.cargo/config.toml
|
||||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
./build_common.rs
|
||||
(craneLib.fileset.commonCargoSources ./pcap-sys)
|
||||
(craneLib.fileset.commonCargoSources ./nl-sys)
|
||||
(craneLib.fileset.commonCargoSources ./packets)
|
||||
(craneLib.fileset.commonCargoSources crate)
|
||||
];
|
||||
};
|
||||
|
||||
sparse-beacon-linux = craneLib.buildPackage (commonArgs // {
|
||||
cargoArtifacts = linuxCargoArtifacts;
|
||||
name = "sparse-beacon-linux";
|
||||
cargoExtraArgs = "-p sparse-beacon";
|
||||
src = fileSetForCrate ./sparse-beacon;
|
||||
src = fileSetForBeaconCrate;
|
||||
|
||||
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
||||
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
|
||||
});
|
||||
|
||||
sparse-beacon-freebsd-sysv = craneLib.buildPackage (freebsdArgs // {
|
||||
inherit src;
|
||||
cargoArtifacts = freebsdCargoArtifacts;
|
||||
name = "sparse-beacon-freebsd";
|
||||
cargoExtraArgs = "-p sparse-beacon";
|
||||
@@ -99,16 +122,38 @@ let
|
||||
cargoArtifacts = windowsCargoArtifacts;
|
||||
name = "sparse-beacon-windows";
|
||||
cargoExtraArgs = "-p sparse-beacon";
|
||||
src = fileSetForCrate ./sparse-beacon;
|
||||
|
||||
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
||||
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
|
||||
});
|
||||
|
||||
sparse-server = craneLib.buildPackage (commonArgs // {
|
||||
src = fileSetForWebCrate;
|
||||
|
||||
cargoArtifacts = linuxCargoArtifacts;
|
||||
name = "sparse-server-webclient";
|
||||
|
||||
buildPhaseCargoCommand = ''
|
||||
cargo leptos build \
|
||||
--release \
|
||||
--project=sparse-server
|
||||
'';
|
||||
doNotPostBuildInstallCargoBinaries = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
cp target/x86_64-unknown-linux-musl/release/sparse-server $out/bin
|
||||
'';
|
||||
|
||||
SPARSE_BEACON_LINUX = "${sparse-beacon-linux}/bin/sparse-beacon";
|
||||
SPARSE_BEACON_WINDOWS = "${sparse-beacon-windows}/bin/sparse-beacon.exe";
|
||||
SPARSE_BEACON_FREEBSD = "${sparse-beacon-freebsd}/bin/sparse-beacon";
|
||||
});
|
||||
|
||||
outputs = rec {
|
||||
packages = {
|
||||
inherit sparse-beacon-linux sparse-beacon-windows
|
||||
sparse-beacon-freebsd-sysv sparse-beacon-freebsd;
|
||||
inherit sparse-beacon-linux sparse-beacon-windows sparse-beacon-freebsd
|
||||
sparse-server;
|
||||
};
|
||||
checks = outputs.packages // {
|
||||
rs-fmt = craneLib.cargoFmt { inherit src; };
|
||||
|
||||
Reference in New Issue
Block a user