feat: added loader and appropriate build scripts

This commit is contained in:
Andrew Rioux
2025-01-21 03:11:19 -05:00
parent 489b1d380f
commit 78ac60ce60
9 changed files with 114 additions and 56 deletions
+24 -21
View File
@@ -22,7 +22,7 @@ let
freebsd-zig-libc = pkgs.writeText "freebsd-libc.txt" ''
include_dir=${freebsd-libs}/usr/include
sys_include_dir=${freebsd-libs}/usr/include
sys_include_dir=${freebsd-libs}/usr/lib
crt_dir=${freebsd-libs}/usr/lib
msvc_lib_dir=
kernel32_lib_dir=
gcc_dir=
@@ -51,6 +51,8 @@ let
./nl-sys/src/bridge.c
(craneLib.fileset.commonCargoSources ./packets)
(craneLib.fileset.commonCargoSources ./sparse-beacon)
(craneLib.fileset.commonCargoSources ./sparse-unix-beacon)
(craneLib.fileset.commonCargoSources ./sparse-windows-beacon)
];
};
@@ -89,7 +91,6 @@ let
};
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
@@ -130,6 +131,7 @@ let
});
sparse-beacon-freebsd-sysv = craneLib.buildPackage (freebsdArgs // {
src = fileSetForBeaconCrate;
cargoArtifacts = freebsdCargoArtifacts;
name = "sparse-beacon-freebsd";
cargoExtraArgs = "-p sparse-unix-beacon";
@@ -160,16 +162,16 @@ let
src = ./unix-loader;
buildPhase = ''
mkdir $out
export XDG_CACHE_HOME=$(mktemp -d)
zig build \
-Dtarget=x86_64-linux-musl
--summary all \
--prefix $out \
--release=small \
-Dbeacon=${sparse-beacon-linux}/bin/sparse-unix-beacon \
-Dtarget=x86_64-linux-musl \
--verbose
'';
installPhase = ''
mkdir -p $out/lib
cp zig-out/lib/libunix-loader.so $out/lib/unix-loader.so
'';
SPARSE_BEACON = "${sparse-beacon-linux}/bin/sparse-beacon";
};
freebsd-loader = pkgs.stdenv.mkDerivation {
@@ -180,18 +182,18 @@ let
src = ./unix-loader;
buildPhase = ''
mkdir $out
export XDG_CACHE_HOME=$(mktemp -d)
zig build \
--summary all \
--prefix $out \
--release=small \
-Dtarget=x86_64-freebsd \
-Dbeacon=${sparse-beacon-freebsd}/bin/sparse-unix-beacon \
--sysroot ${freebsd-libs} \
--libc ${freebsd-zig-libc}
--libc ${freebsd-zig-libc} \
--verbose
'';
installPhase = ''
mkdir -p $out/lib
cp zig-out/lib/libunix-loader.so $out/lib/unix-loader.so
'';
SPARSE_BEACON = "${sparse-beacon-freebsd}/bin/sparse-beacon";
};
sparse-installer-linux = craneLib.buildPackage (commonArgs // {
@@ -203,7 +205,7 @@ let
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
SPARSE_INSTALLER_LINUX = "${linux-loader}/lib/unix-loader.so";
SPARSE_INSTALLER_LINUX = "${linux-loader}/lib/libunix-loader.so";
});
sparse-installer-freebsd-sysv = craneLib.buildPackage (commonArgs // {
@@ -215,7 +217,7 @@ let
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-Ctarget-feature=+crt-static";
SPARSE_INSTALLER_FREEBSD = "${freebsd-loader}/lib/unix-loader.so";
SPARSE_INSTALLER_FREEBSD = "${freebsd-loader}/lib/libunix-loader.so";
});
sparse-installer-freebsd =
@@ -248,7 +250,8 @@ let
outputs = rec {
packages = {
inherit sparse-server sparse-beacon-linux sparse-beacon-windows
linux-loader freebsd-loader sparse-beacon-freebsd;
sparse-installer-linux sparse-installer-freebsd linux-loader
freebsd-loader sparse-beacon-freebsd;
inherit freebsd-zig-libc;